[Android Software Development] Grooby97:
Hi All,

I have been trying to find the best way to configure my swap for my android phone, currently the G1. I had started out with the regular swap partition but find my phone performance degraded over time thus I decided to test the usual read/write for my Class 6 Micro SDHC card.

Configure the SD card via fdisk and setup 3 partitions (like everyone else).

Command (m for help): p

Disk /dev/sdm: 8166 MB, 8166309888 bytes

224 heads, 56 sectors/track, 1271 cylinders

Units = cylinders of 12544 * 512 = 6422528 bytes

Disk identifier: 0x3114df25

Device Boot Start End Blocks Id System

/dev/sdm1 1 800 5017572 c W95 FAT32 (LBA)

/dev/sdm2 801 1100 1881600 83 Linux

/dev/sdm3 1101 1271 1072512 82 Linux swap / Solaris

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: If you have created or modified any DOS 6.x

partitions, please see the fdisk manual page for additional

information.

Syncing disks.

Afterward, format the drive as vfat, ext3, swap

localhost ~ # mkfs.vfat /dev/sdm1

mkfs.vfat 3.0.1 (23 Nov 2008)

localhost ~ # mkfs.ext3 /dev/sdm2

mke2fs 1.41.3 (12-Oct-2008)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

117600 inodes, 470400 blocks

23520 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=482344960

15 block groups

32768 blocks per group, 32768 fragments per group

7840 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912

Writing inode tables: done

Creating journal (8192 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 26 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

localhost ~ # mkswap /dev/sdm3

Setting up swapspace version 1, size = 1072508 KiB

no label, UUID=2046ef6b-ac5a-47a2-9484-ea2a356cc7fa

now the read performance via "hdparm -t /dev/sdxxx"

sdm1 (fat) = Timing buffered disk reads: 26 MB in 3.12 seconds = 8.34 MB/sec

sdm2 (ext3) = Timing buffered disk reads: 26 MB in 3.11 seconds = 8.35 MB/sec

sdm3 (swap) = Timing buffered disk reads: 26 MB in 3.08 seconds = 8.45 MB/sec

as you can see, reading is more or less the same across the board.

now the fun part of write. for fat and ext3, I decided to write to a file, for the swap partition, I decided to write directly to the partition.

FAT:

localhost ~ # dd count=30 bs=1M if=/dev/urandom of=sdm1/test.write

30+0 records in

30+0 records out

31457280 bytes (31 MB) copied, 4.9464 s, 6.4 MB/s

EXT3:

localhost ~ # dd count=30 bs=1M if=/dev/urandom of=sdm2/test.write

30+0 records in

30+0 records out

31457280 bytes (31 MB) copied, 4.94644 s, 6.4 MB/s

SWAP:

localhost ~ # dd count=30 bs=1M if=/dev/urandom of=/dev/sdm3

30+0 records in

30+0 records out

31457280 bytes (31 MB) copied, 8.79714 s, 3.6 MB/s

As you can see, write to a FAT or EXT3 partition seems to be faster than writing to a swap partition. Of course, this is assuming I have done my test correctly :D. If writing to FAT or EXT3 is faster and reads are the same, would it mean that you get better SWAP performance via a swap file on an EXT3 partition?