Kristofer Karlsson 413d51724f prio-queue: use cascade-down for faster extract-min
Add sift_up_rebalance(), an alternative to sift_down_root() that
halves the number of comparisons per extract-min.

The standard extract places the last array element at the root and
sifts it down.  At each level this requires two comparisons (left
vs right child, then element vs winner) and a swap.

sift_up_rebalance() instead promotes the smaller child into the
root slot at each level — one comparison and one copy — until the
vacancy reaches a leaf.  The last array element is placed at the
vacancy and sifted up to restore heap order.  In practice the
sift-up rarely moves more than a level or two because the last
array element tends to be large.

Work per extract drops from 2d comparisons + d swaps to
d comparisons + d copies + a short sift-up.

prio_queue_get() now calls sift_up_rebalance() instead of placing
the last element at root and calling sift_down_root().

sift_down_root() and prio_queue_replace() are left unchanged.

Synthetic benchmark (10 rounds of 10M put+get cycles, CPU-pinned,
same compiler and Makefile flags):

Ascending keys (git's typical pattern — parents have lower
priority than children):

  queue width  baseline  patched  speedup
           10     4.39s    3.91s    1.12x
          100     9.10s    6.61s    1.38x
        1,000    11.84s    9.25s    1.28x
       10,000    17.50s   13.92s    1.26x
      100,000    23.97s   20.19s    1.19x

Descending keys (worst case — last element always sinks to leaf):

  queue width  baseline  patched  speedup
           10     4.94s    4.95s    1.00x
          100     9.75s    9.42s    1.03x
        1,000    15.01s   15.29s    0.98x
       10,000    24.79s   23.88s    1.04x
      100,000    29.69s   28.24s    1.05x

Random keys:

  queue width  baseline  patched  speedup
           10     5.05s    4.99s    1.01x
          100     9.90s    9.50s    1.04x
        1,000    15.35s   14.77s    1.04x
       10,000    25.35s   24.21s    1.05x
      100,000    65.71s   63.38s    1.04x

No regressions in any scenario.

End-to-end benchmark on the linux kernel repo (1.4M commits,
range v5.0..v6.0, 311K commits, 20 interleaved runs, 1 warmup):

  Command                      baseline  patched  speedup
  rev-list --count v5.0..v6.0    484ms     474ms    1.02x

The improvement scales with DAG width: wider DAGs produce larger
priority queues, amplifying the per-level savings.  In small or
narrow repositories the queues stay shallow and the sift-down
cost is already negligible.

Signed-off-by: Kristofer Karlsson <krka@spotify.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-06-01 19:11:29 +09:00
2026-03-27 11:00:01 -07:00
2026-02-03 09:41:52 -08:00
2026-04-01 10:28:19 -07:00
2026-03-20 09:31:04 +08:00
2026-03-23 09:20:29 -07:00
2026-02-07 17:41:03 -08:00
2026-02-09 12:09:09 -08:00
2026-02-23 13:23:41 -08:00
2026-02-23 13:23:41 -08:00
2026-03-24 12:31:32 -07:00
2026-03-23 09:20:29 -07:00
2026-04-08 10:19:17 -07:00
2026-03-23 08:33:10 -07:00
2026-03-23 08:33:10 -07:00
2026-04-19 19:01:39 -07:00
2026-03-24 12:26:58 -07:00
2026-03-10 14:23:24 -07:00
2026-02-17 13:30:41 -08:00
2026-02-24 11:16:34 -08:00
2026-03-31 20:43:14 -07:00
2026-03-31 20:43:14 -07:00
2026-02-23 13:21:18 -08:00
2026-04-08 10:19:17 -07:00
2026-04-08 10:19:17 -07:00
2026-03-26 09:38:06 -07:00
2026-03-26 09:38:06 -07:00
2026-02-08 15:03:06 -08:00
2026-03-09 14:36:55 -07:00
2026-03-31 20:43:14 -07:00
2026-04-08 10:19:17 -07:00
2026-03-23 21:27:17 -07:00
2026-02-05 15:42:01 -08:00
2026-03-31 20:43:14 -07:00
2026-04-08 10:19:18 -07:00
2026-03-25 12:58:05 -07:00
2026-03-26 09:38:06 -07:00
2026-04-03 13:01:09 -07:00
2026-04-03 13:01:09 -07:00
2026-03-31 20:43:14 -07:00
2026-04-01 10:28:19 -07:00
2026-02-08 15:16:49 -08:00
2026-02-08 15:16:49 -08:00
2026-03-31 20:43:14 -07:00

Build status

Git - fast, scalable, distributed revision control system

Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals.

Git is an Open Source project covered by the GNU General Public License version 2 (some parts of it are under different licenses, compatible with the GPLv2). It was originally written by Linus Torvalds with help of a group of hackers around the net.

Please read the file INSTALL for installation instructions.

Many Git online resources are accessible from https://git-scm.com/ including full documentation and Git related tools.

See Documentation/gittutorial.adoc to get started, then see Documentation/giteveryday.adoc for a useful minimum set of commands, and Documentation/git-<commandname>.adoc for documentation of each command. If git has been correctly installed, then the tutorial can also be read with man gittutorial or git help tutorial, and the documentation of each command with man git-<commandname> or git help <commandname>.

CVS users may also want to read Documentation/gitcvs-migration.adoc (man gitcvs-migration or git help cvs-migration if git is installed).

The user discussion and development of Git take place on the Git mailing list -- everyone is welcome to post bug reports, feature requests, comments and patches to git@vger.kernel.org (read Documentation/SubmittingPatches for instructions on patch submission and Documentation/CodingGuidelines).

Those wishing to help with error message, usage and informational message string translations (localization l10) should see po/README.md (a po file is a Portable Object file that holds the translations).

To subscribe to the list, send an email to git+subscribe@vger.kernel.org (see https://subspace.kernel.org/subscribing.html for details). The mailing list archives are available at https://lore.kernel.org/git/, https://marc.info/?l=git and other archival sites.

Issues which are security relevant should be disclosed privately to the Git Security mailing list git-security@googlegroups.com.

The maintainer frequently sends the "What's cooking" reports that list the current status of various development topics to the mailing list. The discussion following them give a good reference for project status, development direction and remaining tasks.

The name "git" was given by Linus Torvalds when he wrote the very first version. He described the tool as "the stupid content tracker" and the name as (depending on your mood):

  • random three-letter combination that is pronounceable, and not actually used by any common UNIX command. The fact that it is a mispronunciation of "get" may or may not be relevant.
  • stupid. contemptible and despicable. simple. Take your pick from the dictionary of slang.
  • "global information tracker": you're in a good mood, and it actually works for you. Angels sing, and a light suddenly fills the room.
  • "goddamn idiotic truckload of sh*t": when it breaks
Description
A fork of Git containing Windows-specific patches.
Readme 442 MiB
2025-08-19 03:50:05 -05:00
Languages
C 50.2%
Shell 39.2%
Perl 4.3%
Tcl 3%
Python 0.8%
Other 2.3%