Commit ea23f90
committed
macOS: queue for munmap operations
Executing many mmap/munmap calls alternately can cause a huge load on
macOS. In order to reduce it, we should temporarily store munmap
operations in a queue and process them all at once when the queue is
filled. When the program terminates, we can discard any remaining munmap
operations as corresponding mmaped regions are automatically reclaimed.
Add a queue for munmap operations to perform them all at once.
Here are some example timings. On the Linux kernel repository that
requires about 1700 mmap/munmap calls:
time git ls-tree -r -l --full-tree 211ddde > /dev/null
Before:
real 0m2.083s
user 0m0.201s
sys 0m1.873s
After:
real 0m0.243s
user 0m0.179s
sys 0m0.052s
On a private repository that requires about 943000 mmap/munmap calls:
time git ls-tree -r -l --full-tree xxxxxxx > /dev/null
Before:
real 27m15.138s
user 0m5.084s
sys 27m9.636s
After:
real 0m24.209s
user 0m3.055s
sys 0m21.123s
Signed-off-by: Koji Nakamaru <koji.nakamaru@gree.net>1 parent 4253630 commit ea23f90
3 files changed
+57
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1654 | 1654 | | |
1655 | 1655 | | |
1656 | 1656 | | |
| 1657 | + | |
1657 | 1658 | | |
1658 | 1659 | | |
1659 | 1660 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
278 | 278 | | |
279 | 279 | | |
280 | 280 | | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
281 | 288 | | |
282 | 289 | | |
283 | 290 | | |
| |||
0 commit comments