yashsingh1/xdaforums huggingface dataset:
[G1 Android Development] defconoi:
yes you can enter it in via terminal emulator or ./adb shell, the echo'd settings are not permanent and will reset after reboot, so use the settings to test, then follow the directions to create a /etc/sysctl.conf file to make the settings permanent after you feel comfortable with the settings(if you notice improvement)

defcon
[G1 Android Development] free-sidux:
Wow, this is cool, thank you!

Could you maybe add some more comments, I don't really understand what the single commands do. Or some place, where the function of e.g. "dirty_expire_centisecs" is explained?

One more precise question though: If I don't have a swap file on sd, does the tweaking of the swappiness still change anything?

Greetings!
[G1 Android Development] ccpp0:
there is no swap space on G1, so settings related to the swap can be ignored.

echo 0 > /proc/sys/vm/dirty_expire_centisecs

echo 0 > /proc/sys/vm/dirty_writeback_centisecs

never writes out dirty pages ?
[G1 Android Development] defconoi:
http://tinyurl.com/nlb9ws

Note: The value of vm.swappiness=0 states that no swap space will be used at all, basically it can be ignored if you dont use swap though
[G1 Android Development] ccpp0:
set vfs_cache_pressure to 10 , gives more mem to cache fs dentry and inode to save cpu "wa".
[G1 Android Development] tshizzle:
how do i create a Sysctl.conf file with this script?

i tried the link of examples but all i could find was info about it.

everything else works but when i try

sysctl vm.block_dump=1

i get sysctl: error: 'vm.block_dump=1' is an unknown key

any ideas?
[G1 Android Development] defconoi:
actually ya know what I think we can just disable sysctl all together in menuconfig->Filesystems->Pseudo Filesystems->Proc->Sysctl Support when compiling a new kernel and setting these tweaks right in the kernel.

Says in menuconfig"As it is generally a good thing, you should say Y here unless

building a kernel for install/rescue disks or your system is very

limited in memory."

So I think we can gain some memory disabling this since we dont really need it
[G1 Android Development] defconoi:
disable /dev/mem

Also I think we can disable the Memory Device Driver, /dev/mem, it says it can be disabled for security conscious and can be disabled on memory tight systems, which we are definitely memory tight plus there's just no valid app that uses /dev/mem on actual memory.

Other popular users of /dev/mem are rootkits and the like.

(note: mmap access of memory via /dev/mem was already not allowed since

a really long time)

People who want to use /dev/mem for kernel debugging can enable the config

option.
[G1 Android Development] jroid:
I have the same exact questions that u do
[G1 Android Development] defconoi:
Unix98_ptys

Also do we really need UNIX98_PTYS enabled?

We can also use this to conserve memory if we dont need this as well...

menuconfig says:

"Unix98 PTY support UNIX98_PTYS

A pseudo terminal (PTY) is a software device consisting of two

halves: a master and a slave. The slave device behaves identical to

a physical terminal; the master device is used by a process to

read data from and write data to the slave, thereby emulating a

terminal. Typical programs for the master side are telnet servers

and xterms.

Linux has traditionally used the BSD-like names /dev/ptyxx for

masters and /dev/ttyxx for slaves of pseudo terminals. This scheme

has a number of problems. The GNU C library glibc 2.1 and later,

however, supports the Unix98 naming standard: in order to acquire a

pseudo terminal, a process opens /dev/ptmx; the number of the pseudo

terminal is then made available to the process and the pseudo

terminal slave can be accessed as /dev/pts/<number>. What was

traditionally /dev/ttyp2 will then be /dev/pts/2, for example.

All modern Linux systems use the Unix98 ptys. Say Y unless

you're on an embedded system and want to conserve memory."
[G1 Android Development] defconoi:
ahhhh it looks vm.block_dump=1 isnt a valid sysctl option, disregard that, gonna remove it from the first post
[G1 Android Development] jroid:
yea. all the other ones work though. how would we make the file??
[G1 Android Development] defconoi:
adb remount

create sysctl.conf on your system

then adb push sysctk.conf /etc and the settings will be set every reboot.
[G1 Android Development] jroid:
ok so it would be something like this?

adb remount

adb shell

mkdir /system/sysctl.conf

adb push sysctl.conf /system/etc
[G1 Android Development] defconoi:
no, adb push sysctl.conf /etc
[G1 Android Development] jroid:
this isn't working. i created the dir sysctl.conf in /system then tried adb pushing it but says no such file or dir. then i tried in adb shell cp /system/sysctl.conf /etc

it says cp: omitting sysctl.conf is a directory"

couldnt i just create it directly in /etc?

like this mkdir /system/etc/sysctl.conf
[G1 Android Development] andonnguyen:
on android /etc is within the /system/etc directory.
[G1 Android Development] andonnguyen:
you would actually have to create a sysctl.conf file with the commands you want in it. all your doing above is pushing nothing, and making a sysctl.conf folder in /system.
[G1 Android Development] jroid:
lol that's the thing, idk how to do that..any help?
[G1 Android Development] wootroot:
this may be a dumb question

does android already have this file on it? if so, i cant find it, if not, then nvm

if it doesnt already have this file, will it automatically read the file upon bootup even though the file wasnt there before?

or am i totally missing the whole point
[G1 Android Development] ccpp0:
no original sysctl.conf there.

not read the file auto. i've appended a few lines to a2sd script (i'm on cm rom).
[G1 Android Development] andonnguyen:
I'm also on the cm rom, mind sharing which file your modifying (location and name) and what lines you appending to the file to get sysctl.conf to be read?
[G1 Android Development] ccpp0:
adb remount

adb pull /system/bin/a2sd

# edit a2sd with notepad

append following three lines:

-------cut---------

if [ -e /etc/sysctl.conf ]; then

busybox sysctl -p /etc/sysctl.conf

fi

-------cut---------

adb push a2sd /system/bin/

#edit your sysctl.conf with notepad

-------cut-------

vm.vfs_cache_pressure=10

vm.dirty_ratio=95

vm.dirty_background_ratio=60

vm.swappiness=1

-------cut-------

adb push sysctl.conf /etc/sysctl.conf

adb shell reboot

to check whether control variables modified automatically ,

adb shell

#cat /proc/sys/vm/dirty_ratio

the value should be 95
[G1 Android Development] dixxa:
and what about this one is it no good enough to be implemented ?

By default when Linux runs out of memory it goes through the process list and starts killing off processes that it thinks are using too much memory. This sysctl makes Linux kill the runaway process that made the system run out of memory instead, which is usually what you want.(this will also reduce cpu time and increase battery usage).

Code:

sysctl -w vm.oom_kill_allocating_task=1

If i want it I just have to add "vm.oom_kill_allocating_task=1" to sysctl.conf but I wann be sure it's useful before :)
[G1 Android Development] dwang:
What kind of performance improvements are you seeing with this?
[G1 Android Development] bilclintonsdaman:
articles i'm currently reading to figure this stuff out lol, prolly will be useful to others on here as well:

http://hep.kbfi.ee/index.php/IT/KernelTuning

http://www.linuxhq.com/guides/TLK/mm/memory.html
[G1 Android Development] knaries2000:
don't mean to be a contrarian, but I don't see how most of these tweaks help. all the dirty_xxx configs only affect write back cache. on general phone use, we don't write often. And setting the dirty ratio so high will eat all the memory by the page cache and not allow vm to do work.

This also applies to vfs_cache_pressure, I would rather set vfs_cache_pressure to be high like 200, so that the inodes and dentries doesn't stay in the cache and gets cleaned out so that vm can have more memory to play with. I've been running with vfs_cache_pressure set to 200 for a while now, and have notice less problems with going back to home from a memory intensive app. Having inodes stay in inode hash only helps if you will come back very soon to read them again. But most of the time, say browser (writing/reading cached files), pic, etc, or even apk files we read it once and not read it again for a long time. So I rather kick those inodes out and leave the vm more memory so that Home or other currently running apps won't be killed.

as for sysctl -w vm.oom_kill_allocating_task tweak. the allocating task may easily be the app that you're currently running, so it could potentially whatever app that i am currently running i.e. browser, pic viewer, anything that could use lots of memory.

those are just my opinion with very little data to back up my claims. really don't mean to disrespect anyone, just for discussion.
[G1 Android Development] dwang:
setting cache_pressure to 200 makes sense.

What I've noticed is over time, the OS seems to get less responsive and slower. Maybe its because the vfs cache isn't getting cleared out often enough. And less memory is made available to other applications?

Is there a way to find out how much memory is allocated to the vfs cache?
[G1 Android Development] ccpp0:
I/O is the most expensive operate (both battery and time) during system running. vfs_cache doesn't means low mem for apps, when apps running, system will drop cache if there is not enough mem for apps.

you can start adb shell to run vmstat under console to check "wa" value, different vfs_cache value cause diff. wa cost.
[G1 Android Development] knaries2000:
on a system with very low memory, there is always contention for it. Apps will run with high vfs_cache but it affects performance because in order for another app to start or a running app to do anything that requires more memory, it will need to free up some instead of just grabbing free memory, if its too low. Also cache is only useful if you get a decent hit rate, for example, apps running on the phone reading the same files over and over again, otherwise there is no need to cache them. There may be a few files that would be nice to be kept in cache, but not enough to have vfs_cache using many times more than apps.
[G1 Android Development] knaries2000:
I don't know if there is a simple and clear way to see what is used by vfs_cache. vfs_cache keeps dentry and inodes around, if you do cat "/proc/slabinfo" you can see how many dentry and ext2 or fat inodes are cached, but each inode could have pages (data) cached along with it.
[G1 Android Development] dwang:
What you say is true for data, but what about applications? I use browser, market, twidroid, and dxtop the most.

If those are cached, then switching between them would be faster, so wouldn't that benefit from having a lower vfs cache value?

I think both sides are making some good arguments. :-)

So here's a scenario:

I have twidroid running in memory. I switch from twidroid to the browser and open up a "large" website. This uses up a lot of memory, so twidrod gets bumped out.

If twidroid is in the vfs cache, then when I switch back to twidroid, the application will load up much faster.

Of course the other argument would be is if the vfs cache was small, then twidroid would have never been bumped out of memory and then switching back to twidroid would be even faster.

dave
[G1 Android Development] knaries2000:
applications are the reason why I would want vfs_cache_pressure value high. Having low vfs_cache_pressure means we want more vfs_cache. vfs_cache is caching of inodes and dentries along with some data for those files; it is a filesystem cache. So more memory used for filesystem cache, means less for applications. It is true that when memory is needed for applications, vfs cache will get reclaimed, so it's not that we won't have memory for the applications but we won't have free memory, readily available. So in your example, having high vfs cache (low pressure), the oom killer or garbage collector may decide to kill your apps like browser, home, instead of reclaiming fs cache. If these caches have a good chance of being used later, then maybe it's worth it, but most of the time, they won't be used.
[G1 Android Development] knaries2000:
If twidroid is running in memory, then that memory is application memory. So in that example, you would not gain much from vfs cache. if anything high vfs cache can cause your twidroid app to be killed. But vfs cache could help in the case where the twidroid is not running but the app files (.dex) file is in vfs cache. say you ran it but closed it. then open up browser and load the large website. theoretically, when you want to run twidroid you may get a vfs cache hit, and not have to read the files from disk. The thing is with android, you don't really close the applications when you exit, and even if you do. You don't get to chose what stays in vfs cache. So when you load the large website, it could still kick out the twidroid files, but less chance of it happening if vfs cache is larger (low pressure). And even if you do get a cache hit you'll more likely need to reclaim memory in order to get enough to start your twidroid app. That's I believe having less memory in vfs and more for apps (vm) is more beneficial.
[G1 Android Development] unrafa:
Sorry to say again, but this is bull**** (again, as in previous post)

Another post translating a computer tweak to a phone who doesnt have enough power or RAM to make the tweak make a difference. hence, here it is.....

1st: This settings can ONLY save battery if there is a rotating disk involved, because if you press the filesystem to write soon rather than later, you would afford many secconds with a rotating disk wasting energy. But there is no rotating disk on G1, just flash memory.

so this settings are USELESS at best.

Sysctl filesystem settings, has nothing to do with battery. Those settings specifies the way the filesystem read/write data to internal memory and memory card. How much time wait until data is write etc.

Those settings are set by enginers who write down the exact values based on the speed of the disk, the available memory among other factors.

Changing those values most of the times will only carry an overall slowdown in the phone or what is worse, file system corruption and / or data loss.

I am not wishing changing those settings neither in my laptop, with 2 GB RAM and enough power to really have margin to tweak those settings, neither in G1.

defconoi you harming everyone's who listen to you, you should know how things works instead of googling and copy paste tweaks made for fast computers with lots of ram, not a phone with almost 0 Free RAM, and not a rotating disk, so this tweaks are completely counter productive.
[G1 Android Development] knaries2000:
I think you are going way overboard about harming our devices. The option that exists for battery saving with spinning disk head is "laptop_mode", which is not enabled on the G1 and should not be. Most of the options that are changed in this thread has to the with filesystem read and write caching. I know how they work and they will not damage anything. They are tweaks exposed by developers because in certain situations will help. Most of the defaults has nothing to do with how fast, slow, how much ram, the device has, because linux developers, who wrote this, is defaulting for general hardware, and those defaults aren't changed in our G1s by android. So it is possible to benefit from tweaking various nobs, especially for performance given the nature of our phones. But doing it for battery saving is questionable.
[G1 Android Development] bilclintonsdaman:
getting great performance results.

i enabled a couple of these tweaks in /etc/sysctl.conf and have the folllowing in my /system/init.rc to apply the settings on startup:

here's my sysctl.conf:

this has made my phone feel much, much quicker. there is seems to be no lag in waking up from sleep, switching home screens, opening programs, or any other things where i used to perceive a lag. the only place i've seen it lag is going to the home screen, e.g. hitting the home key while using the browser. all in all, i'm extremely happy with this.

Edit: I just got an extended life battery so i can't really tell how this is affecting my battery life. i'm getting 2-3 days out of a 2600mAh battery with heavy usage, like using youtube as a radio for a party
[G1 Android Development] defconoi:
yea with these settings my phone is much snappier as well, I'd like to see what others say
[G1 Android Development] Booker-T:
I am doubting if these scripts damage my phone:confused:
[G1 Android Development] andonnguyen:
I edited init.rc in ubuntu, looks like the following:

Everything feels faster (528mHz, cyanogen 3.4, aufs). There used to be a little lag before utilizing sysctl.conf, now I basically don't have any.
[G1 Android Development] dwang:
Surprisingly, it does feel faster. I was pretty skeptical, but I'm listening to a podcast on sdcard and surfing the web at the same time, and it feels snappier than before.

Could be placebo and because I had to reboot (which makes the phone faster by default). I'll keep it at this setting for a while and see.
[G1 Android Development] Booker-T:
I've just tried it, it is great and fast for me.

Sadly, I don't know how to make it permanent.

Can anyone give me some advices?
[G1 Android Development] humble:
give a try

im wrong please forgive me you need linux to see every thing in init.rc

and Props to defconoi thank you for sharing
[G1 Android Development] NeoBlade:
I wouldn't have thought so, could open it in notepad and edit it, save then push it back to phone. Don't forget to make a backup first though.
[G1 Android Development] jroid:
ok so i've made my sysctl.conf and pushed it. seems pretty smooth on jac 1.62 anyway of actually checking to see if the process is working?
[G1 Android Development] humble:
Well

i think that init.rc gets renewed every time you reboot your phone how did i come to this conclusion(trial and error) i think you have to modify init.rc in the update.zip(before you up date your G1). I think:confused:
[G1 Android Development] justanothercrowd:
It depends...most modified ramdisks that these ROMS's use call from /init.rc (all the roms even stock look here)

which cannot be changed without unpacking the boot.img...BUT ALSO for ease of changing startup configs there are usually also modifications made that trigger calls to userdata (/data) and system (/system) that look for an init.rc file in either of these locations and then parse it.

This is how Marcus's APPS2SD scripts are designed to be called on from a modified ramdisk that looks to userdata or system for the init.rc file
[G1 Android Development] humble:
interesting..... so one could do all optimization(Marcus's APPS2SD{as you stated}, defconoi tweaks, removal of unwanted "things",additional{custom}services)

by simply modifying init.rc file?

i think all the chefs/cooks do this(its a must) including you

but this all has to be before the update.zip(ROM) is installed(Flashed) this must be.. Why? now im pretty sure init.rc file renews it self

oyeah im just thinking aloud:cool:

but is there a way to stop init.rc file boot renews, is this plausible?

no flames please:D
[G1 Android Development] dwang:
seems to destabilize my phone. Phone has rebooted by itself twice since I did this.
[G1 Android Development] Chahk:
Ditto on the speed of the phone after applying these changes. Don't know exactly what this does, but the phone is much snappier.
[G1 Android Development] andonnguyen:
Were you changing the settings in the earlier posts to different values? I used the ones posted a few back, and my phone has been stable.
[G1 Android Development] jbomxda:
I used those too and my phone does feel much quicker and responsive. Thanks defconoi for this great tweak!
[G1 Android Development] Proxin:
Thanks, I've been noticing severe lag and force closes lately so I hope these will help.
[G1 Android Development] Booker-T:
Can anyone just release a [Easy Installation Guide] for those who are not familiar with Lunix?

I really want to make it permanently. Thanks
[G1 Android Development] ccpp0:
try these:

adb remount

adb push sysctl.conf /etc/sysctl.conf

adb pull /system/init.rc

edit init.rc with notepad, append following line to the end of file

/system/xbin/busybox sysctl -p /etc/sysctl.conf

adb push init.rc /system/init.rc
[G1 Android Development] Booker-T:
Where should I put the sysctl.conf?
[G1 Android Development] ccpp0:
adb push sysctl.conf /etc/sysctl.conf <-- push sysctl.conf into phone /etc/ directory, the file can be placed anywhere on ur pc, just write the full path to ur sysctl.conf when pushing .
[G1 Android Development] i1fang:
seem like your guide just corrupted my EXT3
[G1 Android Development] i1fang:
beg of defconoi to edit 1st post with layman installation guide.
[G1 Android Development] Chahk:
Highly unlikely that pushing a file could've corrupted an SD card. You didn't give any details, so it would be impossible to diagnose your problem.
[G1 Android Development] Ohsaka:
I had to try a couple times to finally get the changes to stick after reboots. Here is how I did it. I am using JF 1.5.1

1) Create file named sysctl.conf with the following in it:

vm.swappiness=0

vm.dirty_expire_centisecs=0

vm.dirty_writeback_centisecs=0

vm.dirty_background_ratio=60

vm.dirty_ratio=95

vm.oom_kill_allocating_task=1

vm.vfs_cache_pressure=10

2) Execute adb pull /system/init.rc init.rc

3) Add the following line to the end of the init.rc file: (-p option makes it read from /system/etc/sysctl.conf automatically)

service sysctl /system/xbin/bb/sysctl -p

4) Execute adb push sysctl.conf /system/etc/sysctl.conf

5) Execute adb push init.rc /system/init.rc

6) Reboot the phone

7) Execute adb shell and then execute cat /proc/sys/vm/dirty_ratio

If you get 95, the changes are saved, if you get 10 then you messed up.

Try again.
[G1 Android Development] ccpp0:
how to delete a post ?
[G1 Android Development] ccpp0:
what wrong with your ext3 fs ?
[G1 Android Development] namsir:
i did get 95, thanks man......how long will the battery last after this hack?
[G1 Android Development] i1fang:
All of the apps are unlaunchable & need reinstallation. Files exist with correct data size but corrupted
[G1 Android Development] Chahk:
I've had that happen to me on a few occasions, it seemed at the time after flashing a new ROM. Re-installing the apps works to an extent, but the problem creeps back in after a few reboots. I'd recommend re-formatting the SD card and starting from scratch with A2SD (I assume that's what you're running).
[G1 Android Development] Pichingo:
Every one should follow these steps. My phone is faster then ever, currently running The Dude's Cupcake1.3RC1

Very happy with this.
[G1 Android Development] bilclintonsdaman:
uh, you shouldn't be touching your ext3 partition to do this. did you run e2fsck from the recovery console? it's in cyanogen's pimped out recovery image. make sure the file system isn't mounted or you WILL corrupt your ext3
[G1 Android Development] dwang:
Nevermind...