Swap performance - Swap Partition or Swap File? - Android Software Development

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 . 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?

thanx for the interesting read

Your write test is flawed.
Flaw 1: You use /dev/urandom as a data source. Data generation from /dev/urandom is heavily affected by CPU usage AND by available entropy -- though it doesn't block, its speed does vary drastically.
Flaw 2: You only run the test ONCE. This means that issues from flaw 1 are totally visible rather than being averaged out over a large number of tests. You should do the test 100's of times and take the average over them.
Flaw 3: Implementation of the ext3 filesystem tend to hide the effects of disk latency. There are caches and journals that you haven't accounted for. In order to get the ACTUAL time that it takes to write to the ext3 filesystem, you need to follow the write test by a synchronization, which will *actually* write the data to the disk (i.e., it will BLOCK until the write is actually completed). Unfortunately though, this test will also synchronize OTHER write operations that are buffered, which will further skew your results. What you REALLY need to do is perform the tests on a completely empty partition. Should be starting sync, begin time, test write, finishing sync, finishing time. Elapsed time = finishing time - begin time.
In other words, I'm sorry, but your conclusions are not correct. What I *very strongly* suspect, is that if you do your tests correctly, you will find that the performance of swap-on-ext3 will actually be *lower* than swap-on-partition due to the extra overhead of the ext3 filesystem.

Note: the linux vfat filesystem implementation also buffers writes.
A little bit of fun trivia:
Back in the days when we actually used floppy disks, you could actually copy an entire disk worth of data over to a vfat floppy disk without it even BEGINNING to write to the disk. Usually, it would begin writing several seconds after the copy "completed". If you wanted to speed it along, a sync or umount would force the buffer immediately to write to disk.

ahhh...thanks for the info. I guess with buffer, it makes timing or calculating the write speed a bit difficult. I will have to think more about this.
This really makes me wonder how do SD card manufactures test their write speed and assign the card class.

I believe they do a test similar to yours without any buffering and write different amounts of data to simple file systems.
Then, according to http://en.wikipedia.org/wiki/Secure_Digital the class number is equal to the amount of minimum write megabytes per second that can be written to the disk when in a clean and unfragmented state. So a class 6 card would at it's slowest writing speed on a perfectly setup disk be able to write data at 6 megabytes per second or faster. Read speed isn't taken into account for the rating, but is generally faster than write speed.

I redid my test with raw write via if=/dev/zero and the write speed is now on-par with what was classified on the SD class. (7.4MBps write on my class 6). Playing around w/ the setting more, seems like the over-time degradation seems to be caused by my swappiness configuration.

Related

Apps2Sd + Hero

So I did a wipe on my phone and installed Hero. Whenever I try to install an app it says "insufficient storage". I only have 9Mb available in my internal memory.. why is it so little?
I just formatted my 4Gb sdcard to Fat32 and ran sdsplit and got the following::
Code:
$ su
# lucid -s
/data/app is not linked
/data/app-private is not linked
/data/data is not linked
/data/dalvik-cache is not linked
/system/media is not linked
-------------------------
-------------------------
2.0K /system/sd
# du -s /sdcard
16 /sdcard
# df /data
/data: 91904K total, 82108K used, 9796K available (block size 4096)
# /data/sdsplit -fs 3600M
--------------------------------------
+You have chosen to perform the following actions:
.BACKUP /sdcard contents to /data
.CONFIGURE system to mount EXT2 partition
!WARNING! Do NOT do this on JF1.5 builds!
.REPARTITION sdcard: 3600M FAT / EXT2
!WARNING! Will DELETE data on sdcard!
.MAKE FAT32 and EXT2 filesystems
.RESTORE /data to sdcard
ARE YOU SURE YOU WANT TO PROCEED? y/N
y
--------------------------------------
+Checking validity of mkdosfs
1+0 records in
1+0 records out
1 bytes transferred in 0.001 secs (1000 bytes/sec)
--------------------------------------
+Checking validity of mke2fs
--------------------------------------
+Backing up /sdcard to /data
--------------------------------------
+Backing up and Updating /system/init.rc
--------------------------------------
+Backing up and Updating /system/etc/mountd.conf
WARNING: /system/etc/mountd.conf backup /system/etc/mountd.conf.orig already exists!
Do you want to overwrite it? y/N
y
--------------------------------------
+Partitioning sdcard
--------------------------------------
+ Blank out the 4 first blocks of the sdcard so that mountd does not try to remount it on fdisk write preventing a kernel partition table re-read.
4+0 records in
4+0 records out
2048 bytes transferred in 0.006 secs (341333 bytes/sec)
--------------------------------------
+ Wipe partition table and create FAT32 3600M/EXT2 partitions
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that the previous content
won't be recoverable.
The number of cylinders for this disk is set to 125632.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that the previous content
won't be recoverable.
The number of cylinders for this disk is set to 125632.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): Command action
e extended
p primary partition (1-4)
Partition number (1-4): First cylinder (1-125632, default 1): Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-125632, default 125632):
Command (m for help): Selected partition 1
Hex code (type L to list codes): Changed system type of partition 1 to b (Win95 FAT32)
Command (m for help):
Disk /dev/block/mmcblk0: 4116 MB, 4116709376 bytes
4 heads, 16 sectors/track, 125632 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Device Boot Start End Blocks Id System
/dev/block/mmcblk0p1 1 109864 3515640 b Win95 FAT32
Command (m for help): Command action
e extended
p primary partition (1-4)
Partition number (1-4): First cylinder (109865-125632, default 109865): Using default value 109865
Last cylinder or +size or +sizeM or +sizeK (109865-125632, default 125632): Using default value 125632
Command (m for help): Partition number (1-4): Hex code (type L to list codes):
Command (m for help):
Disk /dev/block/mmcblk0: 4116 MB, 4116709376 bytes
4 heads, 16 sectors/track, 125632 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Device Boot Start End Blocks Id System
/dev/block/mmcblk0p1 1 109864 3515640 b Win95 FAT32
/dev/block/mmcblk0p2 109865 125632 504576 83 Linux
Command (m for help): The partition table has been altered!
Calling ioctl() to re-read partition table
--------------------------------------
+Creating FAT32 Filesystem
opening /dev/block/mmcblk0p1
/dev/block/mmcblk0p1: 7017536 sectors in 877192 FAT32 clusters (4096 bytes/cluster)
MBR type: 11
bps=512 spc=8 res=32 nft=2 mid=0xf0 spt=7031280 hds=0 hid=0 bsec=7031280 bspf=6854 rdcl=2 infs=1 bkbs=2
--------------------------------------
+Creating EXT2 Filesystem
mke2fs 1.41.3 (12-Oct-2008)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
126480 inodes, 504576 blocks
25228 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67633152
62 block groups
8192 blocks per group, 8192 fragments per group
2040 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 37 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
--------------------------------------
+Mounting FAT Filesystem
Usage: mount [-r] [-w] [-o options] [-t type] device directory
--------------------------------------
+Mounting EXT2 Filesystem
Did not find ext2.ko, (normal on JF1.5)
Usage: mount [-r] [-w] [-o options] [-t type] device directory
--------------------------------------
+You should now have a FAT partition on /sdcard and an EXT2 partition on /system/sd. If things worked, you should see an entry for /sdcard and /system/sd below:
--------------------------------------
+Restoring /data/sdcard to /sdcard
cp: cannot create directory '/sdcard/.footprints': Read-only file system
Permission setting errors are normal on a FAT system
===ERROR: restore failed!

Issues after accidental usb disconnect

So I was transferring some files to the large internal sdcard, when my computer keeled over from a sudden and unanticipated hardware failure. I unplugged the phone immediately and waited for the Media scanning to finish, and waited, and waited. So I shut down the phone, which may in retrospect have been a mistake.
Now the internal sdcard is bizarrely named "_PNG []-1" and Media scanning is currently hung after reattempting the file transfer (begun at 9:58 and still going).
Any advice on steps I should take in attempting to remedy the situation is greatly appreciated.
Magicked from my Vibrant by tube traversing XDA elves.
Well, I used the disktype utility and discovered that the internal memory is fat32. So I ran
Code:
dosfsck -vV /dev/sdc
and got the following for my trouble
Code:
dosfsck 3.0.9 (31 Jan 2010)
dosfsck 3.0.9, 31 Jan 2010, FAT32, LFN
Checking we can access the last sector of the filesystem
Boot sector contents:
System ID "android "
Media byte 0xf0 (5.25" or 3.5" HD floppy)
512 bytes per logical sector
32768 bytes per cluster
32 reserved sectors
First FAT starts at byte 16384 (sector 32)
2 FATs, 32 bit entries
1675264 bytes per FAT (= 3272 sectors)
Root directory start at cluster 2 (arbitrary size)
Data area starts at byte 3366912 (sector 6576)
418713 data clusters (13720387584 bytes)
16 sectors/track, 4 heads
0 hidden sectors
26804208 sectors total
Starting check/repair pass.
Checking for unused clusters.
Checking free cluster summary.
Starting verification pass.
Checking for unused clusters.
/dev/sdc: 32571 files, 130173/418713 clusters
Of course in spite of this happy results, Media scanning continues to hang. (I gave it a half hour before I plugged it in again to run this test, so... I don't think it was gonna snap out of it).

Partition information

Not really big news for anyone who's installed SDE and poked around a bit, but I thought I'd post this anyway.
Taken from a 16GB Archos 101. Your results may differ.
Code:
Disk /dev/mmcblk0: 536 MB, 536870912 bytes
4 heads, 16 sectors/track, 16384 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 5 1605 51200+ 83 Linux
/dev/mmcblk0p2 1605 5511 125023 83 Linux
/dev/mmcblk0p3 5512 6489 31296 83 Linux
/dev/mmcblk0p4 6490 16384 316640 83 Linux
Disk /dev/mmcblk1: 15.3 GB, 15388901376 bytes
4 heads, 16 sectors/track, 469632 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Device Boot Start End Blocks Id System
/dev/mmcblk1p1 1 469632 15028216 c Win95 FAT32 (LBA)
Being MMC rather than MTD devices, it ought to be possible to repartition to shuffle some space around, perhaps gaining as much as 50MB extra space for /data.
Additionally, for custom firmwares maybe even repartitioning mmcblk1 may be possible, to create an alternate partition to mount /data/ to.
Of course, for fear of ruining my 101 I have only used fdisk for read-only operations.
don't forget mmcblk2..
it's the external sdcard
Of course I was examining the internal flash storage of the device.
Having my 101 for just under 3 weeks I'm not quite brave enough to repartition mmcblk0, as it would be very difficult to recover an operational system if this were to not go as well as expected. :>
I'm hoping that someone with a little more insight or perhaps a little braver than I could chime in on the possibility.
why won't you repartition (shrink p1 and append other partitions) blk1? (8 / 16 GB storage)
don't touch blk0 when you don't have to
chulri said:
why won't you repartition (shrink p1 and append other partitions) blk1? (8 / 16 GB storage)
don't touch blk0 when you don't have to
Click to expand...
Click to collapse
This was of course my suggestion for alternate firmwares that can take advantage of this.
Moved to general as not android development

Photon sd card builds (partition coruption)

I faced an problem with sd card builds, need to see if it is only to me or is also present to you. Problem is with sd card (partition 1) coruption!
fdisk mmcmlk0 displayng no coruption!
Code:
fdisk /dev/block/mmcblk0
Command (m for help): p
p
Disk /dev/block/mmcblk0: 7948 MB, 7948206080 bytes
245 heads, 62 sectors/track, 1021 cylinders
Units = cylinders of 15190 * 512 = 7777280 bytes
Device Boot Start End Blocks Id System
/dev/block/mmcblk0p1 1 1021 7754464 b Win95 FAT32
but fdisk partition (mmcblkop1) displaying very very good coruption with 4 partitions inside partition
Code:
fdisk /dev/block/mmcblk0p1
The number of cylinders for this disk is set to 242327.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
p
Disk /dev/block/mmcblk0p1: 7940 MB, 7940571136 bytes
4 heads, 16 sectors/track, 242327 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Device Boot Start End Blocks Id System
/dev/block/mmcblk0p1p1 ? 12158374 29994462 570754815+ 72 Unknown
Partition 1 does not end on cylinder boundary
/dev/block/mmcblk0p1p2 ? 2635774 32886216 968014120 65 Unknown
Partition 2 does not end on cylinder boundary
/dev/block/mmcblk0p1p3 ? 29216898 59467339 968014096 79 Unknown
Partition 3 does not end on cylinder boundary
/dev/block/mmcblk0p1p4 ? 45088769 45089636 27749+ d Unknown
Partition 4 does not end on cylinder boundary
Partition table entries are not in disk order
So its like we have problem! Also I think this is all a result of problems we have with the file transfer to disk!
Also in log I see all time enter/leave (but phone is in sleep mode!):
Code:
<4>[ 568.114746] msmsdcc_resume enter
<4>[ 568.114928] msmsdcc_resume leave
<4>[ 568.114986] msmsdcc_resume enter
<4>[ 568.115103] msmsdcc_resume leave
I don't know whats wrong but we have coruption in sd card, initrd related? or kernel side related? or android side related??? I created two fat32 partitions this time, first is for all android files /bootsdcard, seccond is mounted as a /mnt/sdcard, initrd is edited allso! Got coruption in all partitions Why???
Code:
Disk /dev/block/mmcblk0p1: 6892 MB, 6892752384 bytes
4 heads, 16 sectors/track, 210350 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Device Boot Start End Blocks Id System
/dev/block/mmcblk0p1p1 ? 29215178 31850952 84344761 69 Unknown
Partition 1 does not end on cylinder boundary
/dev/block/mmcblk0p1p2 ? 26586242 55803140 934940732+ 73 Unknown
Partition 2 does not end on cylinder boundary
/dev/block/mmcblk0p1p3 ? 41 41 0 74 Unknown
Partition 3 does not end on cylinder boundary
/dev/block/mmcblk0p1p4 45088769 45089587 26207+ 0 Empty
Partition 4 does not end on cylinder boundary
Partition table entries are not in disk order
Command (m for help): q
q
# fdisk /dev/block/mmcblk0p2
fdisk /dev/block/mmcblk0p2
The number of cylinders for this disk is set to 32130.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
p
Disk /dev/block/mmcblk0p2: 1052 MB, 1052835840 bytes
4 heads, 16 sectors/track, 32130 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Device Boot Start End Blocks Id System
/dev/block/mmcblk0p2p1 ? 29215178 31850952 84344761 69 Unknown
Partition 1 does not end on cylinder boundary
/dev/block/mmcblk0p2p2 ? 26586242 55803140 934940732+ 73 Unknown
Partition 2 does not end on cylinder boundary
/dev/block/mmcblk0p2p3 ? 41 41 0 74 Unknown
Partition 3 does not end on cylinder boundary
/dev/block/mmcblk0p2p4 45088769 45089587 26207+ 0 Empty
Partition 4 does not end on cylinder boundary
Partition table entries are not in disk order
Anyone who use google page release want to confirm our problem? How to see if coruption exist in your sd card? Simply open android terminal emulator, type "su" press enter and confirm administrator, type "fdisk /dev/block/mmcblk0p1" and press enter, type "p" and press enter, to exit from fdisk type "q" and press enter. I waiting you reply
Code:
Disk /dev/block/mmcblk0p1: 1971 MB, 1971416576 bytes
4 heads, 16 sectors/track, 60162 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Device Boot Start End Blocks Id System
/dev/block/mmcblk0p1p1 ? 27627926 54209359 850605874+ 6e Unknown
Partition 1 does not end on cylinder boundary
/dev/block/mmcblk0p1p2 ? 30526934 45850528 490354992+ ff Unknown
Partition 2 does not end on cylinder boundary
/dev/block/mmcblk0p1p3 ? 28151302 30786496 84326194+ 74 Unknown
Partition 3 does not end on cylinder boundary
/dev/block/mmcblk0p1p4 1 55513776 1776440832 0 Empty
Partition 4 does not end on cylinder boundary
Partition table entries are not in disk order
Code:
# fdisk /dev/block/mmcblk0p1
The number of cylinders for this disk is set to 120880.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/block/mmcblk0p1: 3960 MB, 3960995840 bytes
4 heads, 16 sectors/track, 120880 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Device Boot Start End Blocks Id System
/dev/block/mmcblk0p1p1 ? 27627926 54209359 850605874+ 6e Unknown
Partition 1 does not end on cylinder boundary
/dev/block/mmcblk0p1p2 ? 30526934 45850528 490354992+ ff Unknown
Partition 2 does not end on cylinder boundary
/dev/block/mmcblk0p1p3 ? 28151302 30786496 84326194+ 74 Unknown
Partition 3 does not end on cylinder boundary
/dev/block/mmcblk0p1p4 45088769 45089616 27106 0 Empty
Partition 4 does not end on cylinder boundary
Partition table entries are not in disk order

Resize sdcard partition on mac

I am trying to resize the sdcard partition on the bootable cm7 sd card image. I am able to resize it using Windows and Linux, but haven't found an easy way to do it via Mac OS using the built in sdcard reader. Does anyone know how to accomplish this?
Have you tried disk utility?
Sent from my NookColor using XDA
I have. It doesn't allow me to change the size of the last partition on the card.
You can use the Sudo command to format your card on the mac from the command line. Just type Type sudo or su -
fdisk /dev/sda
mkfs -t vfat /dev/sda1
That should format your card. Just partition with fdisk. Be sure to choose the whole device (/dev/sdc), not a single partition (/dev/sdc1).
fdisk is started by typing (as root) fdisk device at the command prompt. device might be something like /dev/hda or /dev/sda.
To check the list of devices available type fdisk -l
The basic fdisk commands you need are:
p – Print the partition table.
n – Create a new partition.
d – Delete a partition.
q – Quit without saving changes.
a – Make a partition bootable.
w – Write the new partition table and exit.
Changes you make to the partition table do not take effect until you issue the write (w) command. Here is a sample partition table:
Disk /dev/sdb: 64 heads, 63 sectors, 621 cylinders
Units = cylinders of 4032 * 512 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 184 370912+ 83 Linux
/dev/sdb2 185 368 370944 83 Linux
/dev/sdb3 369 552 370944 83 Linux
/dev/sdb4 553 621 139104 82 Linux swap

Categories

Resources