From: Junio C Hamano Date: Thu, 05 Nov 2026 22:49:38 GMT Subject: Re: [PATCH v2 12/12] remote: use strmap for apply_push_cas() Message-ID: In-Reply-To: <20261014031347.50433-13-jon@jonsimons.org> Jon Simons writes: > Optimize apply_push_cas() by replacing a linear traversal of all > advertised remote refs with strmap lookups. > > Before this change, applying N explicit --force-with-lease entries > to M remote advertised refs entails O(N * M) calls to refname_match() > in apply_one_cas(). > > After this change, we build a strmap of remote refs O(M), and use it > for O(N * rules) lookups of the lease entry refnames. OK. We may be checking multiple target refs, and we may be checking with multiple cas rules, but the order of check does not matter, so we do not have to be linearly scanning the remote_refs list at all. > The refnames are resolved by issuing one strmap lookup for each > candidate rules pattern generated with expand_ref_prefix(), as > with earlier strmap conversions. That trick is clever and apparently very effective ... > p5516 timings show the speedup: > > Test HEAD~1 HEAD > -------------------------------------------------------------------- > 5516.16: empty:lease:1 0.13(0.07+0.10) 0.14(0.08+0.11) +7.7% > 5516.19: empty:lease:10 0.16(0.10+0.10) 0.14(0.08+0.11) -12.5% > 5516.22: empty:lease:100 0.45(0.39+0.10) 0.16(0.09+0.11) -64.4% > 5516.25: mirror:lease:1 0.16(0.09+0.11) 0.17(0.10+0.12) +6.3% > 5516.28: mirror:lease:10 0.19(0.12+0.10) 0.17(0.10+0.11) -10.5% > 5516.31: mirror:lease:100 0.49(0.42+0.12) 0.19(0.11+0.12) -61.2% ... which is very nice. Thanks.