[Sony Cross-Device General] mionica:
release 3.0b

Highly recommended for people who are experiencing high-load crashes

!!!

Mandatory install

for those who flashed 2.4/2.5/2.5a over 2.3 or older !!!

I would also ask those who are experiencing such crashes to reply on the thread, posting their flimit.log and the 3 .log.bz2 files from /tmp

Okay, so after the legwork with the 2.x series, it's time to get smart.

Changelog for version 3.0b:

no change in functionality, but it prints a pretty nice view of the process tree of zygote, see below

Changelog for version 3.0a:

the installer didn't properly remove the old /system/etc/init.d/98_revert_flimit_after_boot file (or the 99_revert_flimit_after_boot from version 2.3 and older) - many thanks to [MENTION=6614818]--jenana--[/MENTION] for the quick and detailed report!

Note: if you flashed 2.4/2.5/2.5a over 2.3 or older, then 3.0a is also mandatory for you - as you probably have both a 98_revert_flimit_after_boot and a 99_revert_flimit_after_boot, which is a very wrong state to be in.

Changelog for version 3.0:

fully automated (.prop file was removed);

single-script;

when boot starts, the soft flimit for zygote and all its early descendants is set to the hard limit minus 1 (on my phone, that's 4095); the hard limit is left alone;

with 2.5a and below, only zygote was updated initially - which is bad, since it appears it would typically manage to spawn a few child processes by the time the flimit change takes place

when boot completes, the soft flimit is reverted to whatever zygote had as default, but only if it hadn't changed, and if that limit would be reasonably larger than the number of files that process had opened by that time

for processes that had a large number of files already opened, the limit is not reverted, but lowered to a reasonable value (which is a multiple of 256)

the way this works is, if(( zygote.default_flimit.soft - proc[pid].n_open_files )> threshold ) { proc[pid].flimit.soft = zygote.default_flimit.soft; } else { proc[pid].flimit.soft =(( proc[pid].n_open_files + threshold )+ 255 )& ~255; }

threshold is set in the $NMINFILES variable atop 01_flimit; I used a value of 512, feel free to customize;

if you don't understand a word of what I wrote above, if means you don't know C :), which is fine - just ignore the comment

the number of set/revert iterations is no longer set to 3; instead we iterate until the last step didn't find anything to change

got rid of logcat logging - now loging only to /tmp/flist.log

logcat is only sampled twice - once before waiting for boot to complete, once when we're done; dmesg is still sampled only once, when we're done;

these logs, in .log.bz2 format, are available in /tmp (copy them yourself somewhere else, if you need them)

massively cleaned up the code, in particular the code that dealt with progress logging

updated the installer to remove v2.x's 9*_revert_flimit_after_boot script

Sample log contents:

[i] 01_flimit starting...
[i] =====================
[v]
[i] waiting for the zygote process to spawn...
[i] > found at PID 659 after 1900ms
[v]
[d] checking for byeselinux...
[d] > already loaded
[v]
[i] zygote's initial flimits: soft=1024 hard=4096
[i] seting flimit.soft to 4095
[v]
[i] applying flimit.soft=4095 - iteration #1
[i] 5 processes to check
[d] > PIDs: [659 1002 1003 1004 1008]
[i] 5 processes had their flimits changed
[d] > PIDs: [659 1002 1003 1004 1008]
[v]
[i] applying flimit.soft=4095 - iteration #2
[i] no processes to check
[v]
[i] application of flimit.soft=4095 took 2 iterations
[v]
[i] waiting for boot to finish...
[i] > boot completed after 25900ms
[v]
[i] reverting flimit.soft to 1024 - iteration #1
[i] 50 processes to check
[d] > PIDs: [659 1002 1003 1004 1008 1680 2244 2268 2296 2436 2448 2475 2501 2620 2636 2666 2724 2732 2742 2760 2781 2800 2819 2833 2855 2872 2895 2908 2946 2996 3054 3077 3239 3251 3269 3317 3356 3454 3624 3765 3835 3879 3916 3946 3973 4034 4087 4122 4176 4235]
[i] 49 processes had their flimit.soft reverted
[d] > PIDs: [659 1002 1003 1004 1008 2244 2268 2296 2436 2448 2475 2501 2620 2636 2666 2724 2732 2742 2760 2781 2800 2819 2833 2855 2872 2895 2908 2946 2996 3054 3077 3239 3251 3269 3317 3356 3454 3624 3765 3835 3879 3916 3946 3973 4034 4087 4122 4176 4235]
[i] 1 process had its flimit.soft otherwise changed: [1680:1536]
[v]
[i] reverting flimit.soft to 1024 - iteration #2
[i] 12 processes to check
[d] > PIDs: [4396 4461 4491 4522 4577 4619 4642 4754 4832 4973 5076 5136]
[i] 7 processes had their flimit.soft reverted
[d] > PIDs: [4396 4461 4491 4522 4577 4619 4642]
[i] no processes had their flimit.soft otherwise changed
[v]
[i] reverting flimit.soft to 1024 - iteration #3
[i] 3 processes to check
[d] > PIDs: [5200 5278 5457]
[i] no processes had their flimit.soft reverted
[i] no processes had their flimit.soft otherwise changed
[v]
[i] reversion of flimit.soft took 3 iterations
[v]
[d] PID FILES TASKS CONTEXT [CMDLINE] EXECUTABLE
[d] 659 55 6 u:r:zygote:s0 [zygote] /system/bin/app_process32_xposed
[d] 1002 7 1 u:r:untrusted_app:s0 [logcat-vtime-sXposedStartupMarker:DXposed:Iappproc:IXposedInstaller:Iart:Flibc:FDEBUG:I] /system/bin/logcat
[d] 1003 9 3 u:r:system_server:s0 [xposed_service_system] /system/bin/app_process32_xposed
[d] 1004 9 4 u:r:untrusted_app:s0 [xposed_service_app] /system/bin/app_process32_xposed
[d] 1008 8 1 u:r:untrusted_app:s0 [xposed_logcat] /system/bin/app_process32_xposed
[d] 1680 951 111 u:r:system_server:s0 [system_server] /system/bin/app_process32_xposed
[d] 2244 125 35 u:r:platform_app:s0 [com.android.systemui] /system/bin/app_process32_xposed
[d] 2268 68 13 u:r:platform_app:s0 [com.sonyericsson.capabilities] /system/bin/app_process32_xposed
[d] 2296 88 21 u:r:untrusted_app:s0 [android.process.media] /system/bin/app_process32_xposed
[d] 2436 129 30 u:r:untrusted_app:s0 [com.google.android.wearable.app] /system/bin/app_process32_xposed
[d] 2448 394 24 u:r:untrusted_app:s0 [com.getpebble.android:framework] /system/bin/app_process32_xposed
[d] 2475 63 13 u:r:platform_app:s0 [com.sonymobile.coverapp] /system/bin/app_process32_xposed
[d] 2501 76 15 u:r:untrusted_app:s0 [com.anddoes.notifier] /system/bin/app_process32_xposed
[d] 2620 64 14 u:r:system_app:s0 [com.sonyericsson.usbux] /system/bin/app_process32_xposed
[d] 2636 64 16 u:r:untrusted_app:s0 [org.pocketworkstation.pckeyboard] /system/bin/app_process32_xposed
[d] 2724 105 29 u:r:untrusted_app:s0 [com.google.android.gms.wearable] /system/bin/app_process32_xposed
[d] 2732 72 14 u:r:radio:s0 [com.android.server.telecom] /system/bin/app_process32_xposed
[d] 2742 73 21 u:r:nfc:s0 [com.android.nfc] /system/bin/app_process32_xposed
[d] 2760 64 13 u:r:platform_app:s0 [com.sonymobile.xtp.android] /system/bin/app_process32_xposed
[d] 2781 61 15 u:r:system_app:s0 [com.sonymobile.mirrorlink.system] /system/bin/app_process32_xposed
[d] 2800 68 13 u:r:system_app:s0 [com.sonyericsson.devicemonitor] /system/bin/app_process32_xposed
[d] 2819 61 17 u:r:platform_app:s0 [com.sonymobile.googleanalyticsproxy] /system/bin/app_process32_xposed
[d] 2833 178 53 u:r:radio:s0 [com.android.phone] /system/bin/app_process32_xposed
[d] 2855 62 14 u:r:system_app:s0 [com.sonyericsson.android.wakeup] /system/bin/app_process32_xposed
[d] 2872 61 13 u:r:system_app:s0 [com.sonymobile.prototypeprotection] /system/bin/app_process32_xposed
[d] 2895 109 31 u:r:untrusted_app:s0 [com.anddoes.launcher] /system/bin/app_process32_xposed
[d] 2908 65 14 u:r:untrusted_app:s0 [com.android.providers.calendar] /system/bin/app_process32_xposed
[d] 2946 61 14 u:r:untrusted_app:s0 [com.android.printspooler] /system/bin/app_process32_xposed
[d] 3054 86 22 u:r:untrusted_app:s0 [com.google.process.gapps] /system/bin/app_process32_xposed
[d] 3077 70 16 u:r:untrusted_app:s0 [android.process.acore] /system/bin/app_process32_xposed
[d] 3239 144 20 u:r:untrusted_app:s0 [com.google.android.gms] /system/bin/app_process32_xposed
[d] 3251 64 13 u:r:system_app:s0 [com.sonyericsson.android.bootinfo:remote] /system/bin/app_process32_xposed
[d] 3269 61 14 u:r:untrusted_app:s0 [com.android.smspush] /system/bin/app_process32_xposed
[d] 3317 69 25 u:r:untrusted_app:s0 [com.google.android.googlequicksearchbox:search] /system/bin/app_process32_xposed
[d] 3356 65 15 u:r:untrusted_app:s0 [com.google.android.keep] /system/bin/app_process32_xposed
[d] 3835 61 15 u:r:platform_app:s0 [com.sony.smallapp.managerservice] /system/bin/app_process32_xposed
[d] 4034 73 16 u:r:platform_app:s0 [com.sonymobile.dlna] /system/bin/app_process32_xposed
[d] 4087 74 17 u:r:untrusted_app:s0 [com.sonyericsson.extras.liveware] /system/bin/app_process32_xposed
[d] 4122 61 13 u:r:untrusted_app:s0 [com.gnuc.thoth.pro] /system/bin/app_process32_xposed
[d] 4176 141 23 u:r:untrusted_app:s0 [com.android.email] /system/bin/app_process32_xposed
[d] 4235 91 27 u:r:untrusted_app:s0 [com.google.android.gms.persistent] /system/bin/app_process32_xposed
[d] 4396 61 13 u:r:platform_app:s0 [com.android.externalstorage] /system/bin/app_process32_xposed
[d] 4461 61 13 u:r:system_app:s0 [com.sonymobile.devicesecurity.service] /system/bin/app_process32_xposed
[d] 4491 78 17 u:r:untrusted_app:s0 [com.android.exchange] /system/bin/app_process32_xposed
[d] 4522 73 18 u:r:untrusted_app:s0 [com.android.calendar] /system/bin/app_process32_xposed
[d] 4577 61 13 u:r:untrusted_app:s0 [com.sonymobile.storagechecker] /system/bin/app_process32_xposed
[d] 4619 68 14 u:r:platform_app:s0 [com.sonymobile.tasks] /system/bin/app_process32_xposed
[d] 4642 70 13 u:r:untrusted_app:s0 [com.sonymobile.moviecreator.rmm] /system/bin/app_process32_xposed
[d] 4754 61 13 u:r:untrusted_app:s0 [com.sonymobile.photoanalyzer] /system/bin/app_process32_xposed
[d] 4832 61 14 u:r:platform_app:s0 [com.sonymobile.synchub] /system/bin/app_process32_xposed
[d] 4973 61 13 u:r:system_app:s0 [com.qualcomm.timeservice] /system/bin/app_process32_xposed
[d] 5076 61 13 u:r:platform_app:s0 [com.sonymobile.protectedmedia] /system/bin/app_process32_xposed
[d] 5136 61 13 u:r:untrusted_app:s0 [com.anddoes.fancywidgets] /system/bin/app_process32_xposed
[d] 5200 61 14 u:r:untrusted_app:s0 [com.anod.calendarpro] /system/bin/app_process32_xposed
[d] 5278 61 14 u:r:platform_app:s0 [com.sonyericsson.metadatacleanup] /system/bin/app_process32_xposed
[d] 5457 104 36 u:r:untrusted_app:s0 [com.eclipsim.gpsstatus2] /system/bin/app_process32_xposed
[v]
[i] 01_flimit done.

Note the

[i] 1 process had its flimit.soft otherwise changed: [1680:1536]

line: that means, process with PID=1680 had its soft flimit set to 1536 instead of 1024; loowing lower in the process tab, you see that 1680 had 951 open files, so we set its limit to 1536, which is next multiple of 256 after 1463 (= 951, the number of already opened files, + 512, the safety threshold).

Enjoy.