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-bite generation number instead of current 32-bits. Abhishek Kumar (4): commit-graph: introduce commit_graph_data_slab commit: move members graph_pos, generation to a slab commit-graph: use generation directly when writing commit-graph commit-graph: minimize commit_graph_data_slab access alloc.c | 2 - blame.c | 2 +- bloom.c | 7 +- commit-graph.c | 127 ++++++++++++++++++++++++-------- commit-graph.h | 10 +++ commit-reach.c | 69 ++++++++++------- commit.c | 8 +- contrib/coccinelle/commit.cocci | 18 +++++ revision.c | 20 +++-- 9 files changed, 190 insertions(+), 73 deletions(-) -- 2.27.0 Thanks to Dr. Stolee, Dr. Narebski and Junio for their excellent suggestions. Changes in v2: - Introduce struct commit_graph_data. - Merge `graph_pos`, `generation` slabs into a single, `commit_graph_data` slab. - Use graph position for an intermediate check for generation, saving the cost of initializing generation numbers. - Add an follow-up patch caching results of slab access in local variables. - Move coccinelle transformation to commit.coccinelle instead of creating new scripts. - Elaborate on removing default values from init_commit_node(). - Revert moving macro constants (e.g. COMMIT_NOT_FROM_GRAPH, GENERATION_NUMBER_ZERO) from commit.h to commit-graph.h About the failing diff-submodule related tests, I came up with a plausible explanation but could be wrong on this: Commit slabs rely on uniqueness of commit->index to access data. But submodules are repositories on their own, alloc_commit_index(), which relies on repository->parsed_objects->commit_count no longer returns unique values. A commit belong to super repo and another belonging to submodule might have the same index but different generation and graph positions. This could be fixed by defining commit index as maximum of commit index of all repositories + 1 but I have no idea how that would impact other code. Thoughts on this? Regards Abhishek