{"thread":{"id":"58364","subject":"git gc memory usage","startedAt":"2022-08-26T07:45:48Z","lastAt":"2022-08-26T07:45:48Z","messageCount":1,"participants":["王小建"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"461981","messageId":"CADmGLV2sAaq2PHJoiBAasmimXvBwO9jU-6iWhKhiKAnnecg8mQ@mail.gmail.com","threadId":"58364","inReplyTo":null,"subject":"git gc memory usage","fromName":"王小建","fromEmail":"littlejian8@gmail.com","sentAt":"2022-08-26T07:45:25Z","receivedAt":"2022-08-26T07:45:48Z","isPatch":false,"sender":{"key":"littlejian8@gmail.com","avatar":null},"body":"I have a question about git gc memory usage。\n\nI execute git gc in a git repository, in the information below top,\nwe can see it uses res 1.5g, Why does it use so much res.\nWe all know that res does not contain cache. I think git gc should use\ncache more.\n\ntop - 15:08:50 up 6 days, 23:22,  0 users,  load average: 2.11, 2.69, 2.80\nTasks:   8 total,   2 running,   6 sleeping,   0 stopped,   0 zombie\n%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\nMiB Mem :  31346.3 total,   1760.7 free,  23487.9 used,   6097.8 buff/cache\nMiB Swap:      0.0 total,      0.0 free,      0.0 used.   5312.7 avail Mem\n\n    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+\nCOMMAND\n    288 root      20   0 2274.2m   1.5g   1.0g R  74.7   4.7   0:14.40\ngit\n      1 root      20   0    2.5m   0.1m   0.0m S   0.0   0.0   0:00.01\nsh\n      6 root      20   0 1895.3m  46.5m   9.8m S   0.0   0.1   0:03.88\nbin\n    270 root      20   0    4.1m   3.4m   2.8m S   0.0   0.0   0:00.01\nbash\n    278 root      20   0    4.1m   3.4m   2.9m S   0.0   0.0   0:00.00\nbash\n    283 root      20   0    6.9m   3.1m   2.6m R   0.0   0.0   0:00.00\ntop\n    284 root      20   0    6.6m   3.6m   3.3m S   0.0   0.0   0:00.00\ngit\n    287 root      20   0    6.6m   3.6m   3.3m S   0.0   0.0   0:00.00 git\n\nI am using git service in docker container(memory limit is 1.5g)\nThe following is the memory usage in the container before and after\nexecuting git gc.\nFrom the stat information, the cache is indeed used.\nThis confuses me why res uses 1.5g in top.\n\nbefore:\n# cat memory.usage_in_bytes\n62099456\n\n#cat memory.stat\ncache 22167552\nrss 39739392\nrss_huge 0\nshmem 0\nmapped_file 8921088\ndirty 0\nwriteback 0\nswap 0\nworkingset_refault_anon 0\nworkingset_refault_file 23384064\nworkingset_activate_anon 0\nworkingset_activate_file 675840\nworkingset_restore_anon 0\nworkingset_restore_file 135168\nworkingset_nodereclaim 0\npgpgin 55803\npgpgout 40624\npgfault 58542\npgmajfault 396\ninactive_anon 39739392\nactive_anon 0\ninactive_file 15781888\nactive_file 6529024\nunevictable 0\nhierarchical_memory_limit 1610612736\nhierarchical_memsw_limit 1610612736\ntotal_cache 22167552\ntotal_rss 39739392\ntotal_rss_huge 0\ntotal_shmem 0\ntotal_mapped_file 8921088\ntotal_dirty 0\ntotal_writeback 0\ntotal_swap 0\ntotal_workingset_refault_anon 0\ntotal_workingset_refault_file 23384064\ntotal_workingset_activate_anon 0\ntotal_workingset_activate_file 675840\ntotal_workingset_restore_anon 0\ntotal_workingset_restore_file 135168\ntotal_workingset_nodereclaim 0\ntotal_pgpgin 55803\ntotal_pgpgout 40624\ntotal_pgfault 58542\ntotal_pgmajfault 396\ntotal_inactive_anon 39739392\ntotal_active_anon 0\ntotal_inactive_file 15781888\ntotal_active_file 6529024\ntotal_unevictable 0\n\n\nafter:\ncat memory.usage_in_bytes\n1610506240\n\n# cat memory.stat\ncache 1391554560\nrss 218566656\nrss_huge 0\nshmem 0\nmapped_file 917385216\ndirty 135168\nwriteback 270336\nswap 0\nworkingset_refault_anon 0\nworkingset_refault_file 1296396288\nworkingset_activate_anon 0\nworkingset_activate_file 57040896\nworkingset_restore_anon 0\nworkingset_restore_file 135168\nworkingset_nodereclaim 0\npgpgin 2551098\npgpgout 2157961\npgfault 1536942\npgmajfault 627\ninactive_anon 218431488\nactive_anon 135168\ninactive_file 979427328\nactive_file 412348416\nunevictable 0\nhierarchical_memory_limit 1610612736\nhierarchical_memsw_limit 1610612736\ntotal_cache 1391554560\ntotal_rss 218566656\ntotal_rss_huge 0\ntotal_shmem 0\ntotal_mapped_file 917385216\ntotal_dirty 135168\ntotal_writeback 270336\ntotal_swap 0\ntotal_workingset_refault_anon 0\ntotal_workingset_refault_file 1296396288\ntotal_workingset_activate_anon 0\ntotal_workingset_activate_file 57040896\ntotal_workingset_restore_anon 0\ntotal_workingset_restore_file 135168\ntotal_workingset_nodereclaim 0\ntotal_pgpgin 2551098\ntotal_pgpgout 2157961\ntotal_pgfault 1536942\ntotal_pgmajfault 627\ntotal_inactive_anon 218431488\ntotal_active_anon 135168\ntotal_inactive_file 979427328\ntotal_active_file 412348416\ntotal_unevictable 0\n\nLooking forward to your reply, Thanks very much!\n"}]}