]> git.ipfire.org Git - thirdparty/git.git/commit
revision: use priority queue for non-limited streaming walks
authorKristofer Karlsson <krka@spotify.com>
Wed, 27 May 2026 15:50:02 +0000 (15:50 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 27 May 2026 21:08:20 +0000 (06:08 +0900)
commitdd4bc01c0a8fc871a68a5027ed5ac953fa47fc6e
tree39ce1c5d0a2606c15bf21fcda26e773d1948ada5
parentd877b1af507a6aaf55e8643eb73277a30d3a800b
revision: use priority queue for non-limited streaming walks

The streaming (non-limited) walk in get_revision_1() inserts newly
discovered parent commits into a date-sorted queue via
commit_list_insert_by_date(), which scans the linked list to find the
insertion point -- O(w) per insert, where w is the width of the active
walk frontier.  Replace this with an O(log w) priority queue.

Add a commit_queue field to rev_info alongside the existing commits
linked list.  The two representations are mutually exclusive: setup
and external callers that need list access use the linked list, then
get_revision_1() lazily drains it into the priority queue on first
call.  Add a REV_WALK_NO_WALK enum value to distinguish the no_walk
case (which still uses the commit list) from the streaming case.

The conversion function rev_info_commit_list_to_queue() is public so
callers that know they will iterate can convert early.

Combined with the limit_list() priority queue change already in
master, this eliminates all O(w) sorted linked-list insertion from
the revision walk machinery.

Signed-off-by: Kristofer Karlsson <krka@spotify.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit.c
commit.h
revision.c
revision.h