git/list[1] front-page[2] threads[3] people[4] search[5] about
 

git gc memory usage

From
王王小建 <littlejian8@gmail.com>
Date
Aug 26, 2022, 07:45 UTC
Message-ID
<CADmGLV2sAaq2PHJoiBAasmimXvBwO9jU-6iWhKhiKAnnecg8mQ@mail.gmail.com>
I have a question about git gc memory usage。

I execute git gc in a git repository, in the information below top, we can see it uses res 1.5g, Why does it use so much res. We all know that res does not contain cache. I think git gc should use cache more.

top - 15:08:50 up 6 days, 23:22,  0 users,  load average: 2.11, 2.69, 2.80
Tasks:   8 total,   2 running,   6 sleeping,   0 stopped,   0 zombie
%Cpu(s): 18.9 us,  3.4 sy,  0.0 ni, 74.2 id,  2.7 wa,  0.0 hi,  0.8 si,  0.0 st
MiB Mem :  31346.3 total,   1760.7 free,  23487.9 used,   6097.8 buff/cache
MiB Swap:      0.0 total,      0.0 free,      0.0 used.   5312.7 avail Mem
    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+
COMMAND
    288 root      20   0 2274.2m   1.5g   1.0g R  74.7   4.7   0:14.40
git
      1 root      20   0    2.5m   0.1m   0.0m S   0.0   0.0   0:00.01
sh
      6 root      20   0 1895.3m  46.5m   9.8m S   0.0   0.1   0:03.88
bin
    270 root      20   0    4.1m   3.4m   2.8m S   0.0   0.0   0:00.01
bash
    278 root      20   0    4.1m   3.4m   2.9m S   0.0   0.0   0:00.00
bash
    283 root      20   0    6.9m   3.1m   2.6m R   0.0   0.0   0:00.00
top
    284 root      20   0    6.6m   3.6m   3.3m S   0.0   0.0   0:00.00
git
    287 root      20   0    6.6m   3.6m   3.3m S   0.0   0.0   0:00.00 git

I am using git service in docker container(memory limit is 1.5g) The following is the memory usage in the container before and after executing git gc. From the stat information, the cache is indeed used. This confuses me why res uses 1.5g in top.

before: # cat memory.usage_in_bytes 62099456

#cat memory.stat cache 22167552 rss 39739392 rss_huge 0 shmem 0 mapped_file 8921088 dirty 0 writeback 0 swap 0 workingset_refault_anon 0 workingset_refault_file 23384064 workingset_activate_anon 0 workingset_activate_file 675840 workingset_restore_anon 0 workingset_restore_file 135168 workingset_nodereclaim 0 pgpgin 55803 pgpgout 40624 pgfault 58542 pgmajfault 396 inactive_anon 39739392 active_anon 0 inactive_file 15781888 active_file 6529024 unevictable 0 hierarchical_memory_limit 1610612736 hierarchical_memsw_limit 1610612736 total_cache 22167552 total_rss 39739392 total_rss_huge 0 total_shmem 0 total_mapped_file 8921088 total_dirty 0 total_writeback 0 total_swap 0 total_workingset_refault_anon 0 total_workingset_refault_file 23384064 total_workingset_activate_anon 0 total_workingset_activate_file 675840 total_workingset_restore_anon 0 total_workingset_restore_file 135168 total_workingset_nodereclaim 0 total_pgpgin 55803 total_pgpgout 40624 total_pgfault 58542 total_pgmajfault 396 total_inactive_anon 39739392 total_active_anon 0 total_inactive_file 15781888 total_active_file 6529024 total_unevictable 0

after: cat memory.usage_in_bytes 1610506240

# cat memory.stat cache 1391554560 rss 218566656 rss_huge 0 shmem 0 mapped_file 917385216 dirty 135168 writeback 270336 swap 0 workingset_refault_anon 0 workingset_refault_file 1296396288 workingset_activate_anon 0 workingset_activate_file 57040896 workingset_restore_anon 0 workingset_restore_file 135168 workingset_nodereclaim 0 pgpgin 2551098 pgpgout 2157961 pgfault 1536942 pgmajfault 627 inactive_anon 218431488 active_anon 135168 inactive_file 979427328 active_file 412348416 unevictable 0 hierarchical_memory_limit 1610612736 hierarchical_memsw_limit 1610612736 total_cache 1391554560 total_rss 218566656 total_rss_huge 0 total_shmem 0 total_mapped_file 917385216 total_dirty 135168 total_writeback 270336 total_swap 0 total_workingset_refault_anon 0 total_workingset_refault_file 1296396288 total_workingset_activate_anon 0 total_workingset_activate_file 57040896 total_workingset_restore_anon 0 total_workingset_restore_file 135168 total_workingset_nodereclaim 0 total_pgpgin 2551098 total_pgpgout 2157961 total_pgfault 1536942 total_pgmajfault 627 total_inactive_anon 218431488 total_active_anon 135168 total_inactive_file 979427328 total_active_file 412348416 total_unevictable 0

Looking forward to your reply, Thanks very much!
Message 1 of 1 in “git gc memory usage”
  1. 王小建Aug 26, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.