You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
unpack-trees: optimize walking same trees with cache-tree
In order to merge one or many trees with the index, unpack-trees code
walks multiple trees in parallel with the index and performs n-way
merge. If we find out at start of a directory that all trees are the
same (by comparing OID) and cache-tree happens to be available for
that directory as well, we could avoid walking the trees because we
already know what these trees contain: it's flattened in what's called
"the index".
The upside is of course a lot less I/O since we can potentially skip
lots of trees (think subtrees). We also save CPU because we don't have
to inflate and the apply deltas. The downside is of course more
fragile code since the logic in some functions are now duplicated
elsewhere.
"checkout -" with this patch on gcc.git:
baseline new
--------------------------------------------------------------------
0.018239226 0.019365414 s: read cache .git/index
0.052541655 0.049605548 s: preload index
0.001537598 0.001571695 s: refresh index
0.168167768 0.049677212 s: unpack trees
0.002897186 0.002845256 s: update worktree after a merge
0.131661745 0.136597522 s: repair cache-tree
0.075389117 0.075422517 s: write index, changed mask = 2a
0.111702023 0.032813253 s: unpack trees
0.000023245 0.000022002 s: update worktree after a merge
0.111793866 0.032933140 s: diff-index
0.587933288 0.398924370 s: git command: /home/pclouds/w/git/git
This command calls unpack_trees() twice, the first time on 2way merge
and the second 1way merge. In both times, "unpack trees" time is
reduced to one third. Overall time reduction is not that impressive of
course because index operations take a big chunk. And there's that
repair cache-tree line.
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
0 commit comments