diff options
author | Abhishek Kumar <abhishekkumar8222@gmail.com> | 2020-06-17 11:14:09 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-06-17 23:37:23 +0200 |
commit | 4844812b9ec9bc6ffdc2da2c54d9146ff4c97d94 (patch) | |
tree | b0df2ea1f12101e9ab2456820fc5b32a86db91ed /commit-graph.h | |
parent | object: drop parsed_object_pool->commit_count (diff) | |
download | git-4844812b9ec9bc6ffdc2da2c54d9146ff4c97d94.tar.xz git-4844812b9ec9bc6ffdc2da2c54d9146ff4c97d94.zip |
commit-graph: introduce commit_graph_data_slab
The struct commit is used in many contexts. However, members
`generation` and `graph_pos` are only used for commit-graph related
operations and otherwise waste memory.
This wastage would have been more pronounced as we transition to
generation number v2, which uses 64-bit generation number instead of
current 32-bits.
As they are often accessed together, let's introduce struct
commit_graph_data and move them to a commit_graph_data slab.
While the overall test suite runs just as fast as master,
(series: 26m48s, master: 27m34s, faster by 2.87%), certain commands
like `git merge-base --is-ancestor` were slowed by 40% as discovered
by Szeder Gábor [1]. After minimizing commit-slab access, the slow down
persists but is closer to 20%.
Derrick Stolee believes the slow down is attributable to the underlying
algorithm rather than the slowness of commit-slab access [2] and we will
follow-up in a later series.
[1]: https://lore.kernel.org/git/20200607195347.GA8232@szeder.dev/
[2]: https://lore.kernel.org/git/13db757a-9412-7f1e-805c-8a028c4ab2b1@gmail.com/
Signed-off-by: Abhishek Kumar <abhishekkumar8222@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit-graph.h')
-rw-r--r-- | commit-graph.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/commit-graph.h b/commit-graph.h index 3ba0da1e5f..28f89cdf3e 100644 --- a/commit-graph.h +++ b/commit-graph.h @@ -135,4 +135,14 @@ void free_commit_graph(struct commit_graph *); */ void disable_commit_graph(struct repository *r); +struct commit_graph_data { + uint32_t graph_pos; + uint32_t generation; +}; + +/* + * Commits should be parsed before accessing generation, graph positions. + */ +uint32_t commit_graph_generation(const struct commit *); +uint32_t commit_graph_position(const struct commit *); #endif |