[Optimus One, P500, V General] leaird.wedd:
There are already several guides on how to accomplish this on the forums but to me they all use unacceptable methods for doing so or are to be used to in conjunction with App2SD-type setups. I do not use App2SD currently and I'm interested in discovering the benefits of Dalvik Cache in tmpfs by itself which will make it easier test the performance gain.

To start off here is the script which I name /system/bin/dalvik-tmpfs:

#!/system/bin/sh

# Create a directory with the same ownership and permissions as
# /data/dalvik-cache which will be used to save the contents at shutdown,
# thereby avoiding rebuilding the cache at every boot
if [ ! -d /data/dalvik-tmpfs ]; then
mkdir /data/dalvik-tmpfs
chown 1000:1000 /data/dalvik-tmpfs
chmod 0771 /data/dalvik-tmpfs
fi

# If /data/dalvik-cache/.dalvik-tmpfs DOES NOT exist then...
#
# 1) If /data/dalvik-cache contains no *.dex files then Dalvik Cache has been
# wiped and we'll respect this by wiping /data/dalvik-tmpfs
# 2) Copy *.dex files (if any) in /data/dalvik-tmpfs to /data/dalvik-cache
# so that if the script is not being used at next startup we only lose
# one "cycle" of settings
# 3) Mount tmpfs at /data/dalvik-cache
# 4) Copy *.dex files (if any) in /data/dalvik-tmpfs to /data/dalvik-cache
# (which is now in tmpfs) while preserving ownership and permissions
# 5) Create /data/dalvik-cache/.dalvik-tmpfs so that when the script is run
# at shutdown it knows Dalvik Cache is in tmpfs. When tmpfs is unmounted
# at shutdown this file will be autmagically removed.
#
# If /data/dalvik-cache/.dalvik-tmpfs DOES exist then...
#
# 1) Wipe /data/dalvik-tmpfs so that any *.dex files that aren't in
# /data/dalvik-cache (possibly from uninstalled programs or cleared
# settings) will not be present at next boot
# 2) Copy *.dex files (if any) in /data/dalvik-cache (in tmpfs) to
# /data/dalvik-tmpfs while preserving ownership and permissions
if [ ! -e /data/dalvik-cache/.dalvik-tmpfs ]; then

if [ $(find /data/dalvik-cache/ -name '*.dex' | wc -l) -lt 1 ]; then
rm -f /data/dalvik-tmpfs/*.dex
fi

cp -p /data/dalvik-tmpfs/*.dex /data/dalvik-cache
mount -t tmpfs -o size=96m,mode=0771,uid=1000,gid=1000 tmpfs /data/dalvik-cache
cp -p /data/dalvik-tmpfs/*.dex /data/dalvik-cache
touch /data/dalvik-cache/.dalvik-tmpfs
else
rm -f /data/dalvik-tmpfs/*.dex
cp -p /data/dalvik-cache/*.dex /data/dalvik-tmpfs
fi

Since the script is in /system/bin it will end up in system.img. In my opinion a script like this should not be started by placing in /system/init.d but should instead be started in /init.rc as a service (therefore part of the init ramdisk in boot.img). This allows it to be automatically run at startup and shutdown so that it may be coordinated with zygote (Dalvik VM).

/init.rc then, should look something like this (most important here is dalvik-tmpfs being started before zygote, thanks to andy572 for this information):

...
service ril-daemon /system/bin/rild
socket rild stream 660 root radio
socket rild-debug stream 660 radio system
user root
group radio cache inet misc audio sdcard_rw net_admin net_raw

[COLOR="Red"]service dalvik-tmpfs /system/bin/dalvik-tmpfs
user root[/COLOR]

service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server
socket zygote stream 666
onrestart write /sys/android_power/request_state wake
onrestart write /sys/power/state on
onrestart restart media
onrestart restart netd
...

Pre-emptive FAQ

Is this dangerous? What are the risks?

Probably not at all. The risk you face is having Dalvik Cache wiped (boo hoo!) and if you don't plan ahead maybe some corruption of a *.dex file if you don't give Dalvik Cache enough room in tmpfs. This can be fixed with a Dalvik Cache wipe from recovery (more tears!). If you decide to stop using this script later the worst that will happen is that whatever is in Dalvik Cache from the beginning of last boot will be used.

What do I need to do to prepare for this?

First, you should check the size of all the data in /data/dalvik-cache and make sure the mount command in the script is leaving you enough room. Note that the size you specify is only the maximum size tmpfs will occupy, otherwise it will scale down to only what is necessary. The default is 96MB or about 12% of the LG P500's RAM which should be more than enough, but if that's not true I can always edit this post later to cover my butt.

Second, since the script itself is in system.img but init.rc is in boot.img you will likely have to prepare your own ROM to accomplish this. Unless you want to do some sketchy on-the-fly terminal work which I won't help you with.

Third, the first time you boot with this script Dalvik Cache will be rebuilt from scratch. To avoid this you should run these commands in a terminal after remounting /system read-write:

mkdir /data/dalvik-tmpfs
chown 1000:1000 /data/dalvik-tmpfs
chmod 0771 /data/dalvik-tmpfs
cp -p /data/dalvik-cache/*.dex /data/dalvik-tmpfs

And last but not least, make sure you PM me for a copy of my credit card number so I can replace your phone if you break it, haha!

Will my Quadrant/Neocore/etc score improve?

Probably not at all. this only affects Dalvik Cache read/write so you may have faster program and phone startup but not much else.

Will this use more battery?

Probably not at all, as far as I know RAM is either all on or all off.

Will this use some of the space in my RAM up?

Absolutely, yes. However, as stated above the size of tmpfs specified in the mount command is only the maximum size tmpfs will use. tmpfs is smart enough to scale itself as necessary.