aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem/reference.go
diff options
context:
space:
mode:
authorPaulo Gomes <pjbgf@linux.com>2023-07-20 21:19:28 +0100
committerPaulo Gomes <pjbgf@linux.com>2023-10-28 03:51:35 +0100
commit1c361adbc1f4b0e3d0743d11f187fb0b3ac4cb4d (patch)
treeb7eecbf517a8e1a59047cb98d414bf00ba1f4653 /storage/filesystem/reference.go
parent814abc098d033f77315d3bfb89ae5991aae10457 (diff)
downloadgo-git-1c361adbc1f4b0e3d0743d11f187fb0b3ac4cb4d.tar.gz
plumbing: Optimise memory consumption for filesystem storage
Previously, as part of building the index representation, the resolveObject func would create an interim plumbing.MemoryObject, which would then be saved into storage via storage.SetEncodedObject. This meant that objects would be unnecessarily loaded into memory, to then be saved into disk. The changes streamlines this process by: - Introducing the LazyObjectWriter interface which enables the write operation to take places directly against the filesystem-based storage. - Leverage multi-writers to process the input data once, while targeting multiple writers (e.g. hasher and storage). An additional change relates to the caching of object info children within Parser.get. The cache is now skipped when a seekable filesystem is being used. The impact of the changes can be observed when using seekable filesystem storages, especially when cloning large repositories. The stats below were captured by adapting the BenchmarkPlainClone test to clone https://github.com/torvalds/linux.git: pkg: github.com/go-git/go-git/v5 cpu: Intel(R) Core(TM) i9-10885H CPU @ 2.40GHz │ /tmp/old │ /tmp/new │ │ sec/op │ sec/op vs base │ PlainClone-16 41.68 ± 17% 48.04 ± 9% +15.27% (p=0.015 n=6) │ /tmp/old │ /tmp/new │ │ B/op │ B/op vs base │ PlainClone-16 1127.8Mi ± 7% 256.7Mi ± 50% -77.23% (p=0.002 n=6) │ /tmp/old │ /tmp/new │ │ allocs/op │ allocs/op vs base │ PlainClone-16 3.125M ± 0% 3.800M ± 0% +21.60% (p=0.002 n=6) Notice that on average the memory consumption per operation is over 75% smaller. The time per operation increased by 15%, which may actual be less on long running applications, due to the decreased GC pressure and the garbage collection costs. Signed-off-by: Paulo Gomes <pjbgf@linux.com>
Diffstat (limited to 'storage/filesystem/reference.go')
0 files changed, 0 insertions, 0 deletions