Commit 02279de
committed
Sweep dead process slots only when slots are scarce
init_proc_slot_withlock() swept every occupied slot for liveness on every
join. The sweep reads /proc/<pid>/stat once per slot and runs with the
region lock held, so N processes starting together perform O(N^2)
serialised filesystem work. On the harness from #252, init p50 grows from
0.35ms to 6.06ms going from 1 to 64 concurrent processes.
Reclaiming a slot whose process already died is not needed for a join to
be correct: oom_check() sweeps before it reports OOM, which is where a
stale slot actually changes an outcome. Sweep on join only once occupancy
reaches three quarters of the table, and do it before the capacity check
so a table filled with dead slots is recovered instead of being fatal.
Slots that exit cleanup already marked with PID 0 are still compacted on
every join; that path reads no files.
With this change init p50 at 64 concurrent processes is 1.11ms.
Signed-off-by: keshav9926 <kkakani160@gmail.com>1 parent de6ce39 commit 02279de
2 files changed
Lines changed: 23 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1072 | 1072 | | |
1073 | 1073 | | |
1074 | 1074 | | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
1075 | 1089 | | |
1076 | 1090 | | |
1077 | 1091 | | |
| |||
1123 | 1137 | | |
1124 | 1138 | | |
1125 | 1139 | | |
1126 | | - | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
1127 | 1143 | | |
1128 | 1144 | | |
1129 | 1145 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
43 | 49 | | |
44 | 50 | | |
45 | 51 | | |
| |||
0 commit comments