Commit 08bb69d
describe: use prio_queue_replace()
Optimize the sequence get+put to peek+replace to avoid one unnecessary
heap rebalance.
Do that by tracking partial get operations in a prio_queue wrapper,
struct lazy_queue, and using wrapper functions that turn get into peek
and put into replace as needed. This is simpler than tracking the
state explicitly in the calling code.
We get a nice speedup on top of the previous patch's conversion to
prio_queue:
Benchmark 1: ./git_2.50.1 describe $(git rev-list v2.41.0..v2.47.0)
Time (mean ± σ): 1.559 s ± 0.002 s [User: 1.493 s, System: 0.051 s]
Range (min … max): 1.556 s … 1.563 s 10 runs
Benchmark 2: ./git_describe_pq describe $(git rev-list v2.41.0..v2.47.0)
Time (mean ± σ): 1.204 s ± 0.001 s [User: 1.138 s, System: 0.051 s]
Range (min … max): 1.202 s … 1.205 s 10 runs
Benchmark 3: ./git describe $(git rev-list v2.41.0..v2.47.0)
Time (mean ± σ): 850.9 ms ± 1.6 ms [User: 786.6 ms, System: 49.8 ms]
Range (min … max): 849.1 ms … 854.1 ms 10 runs
Summary
./git describe $(git rev-list v2.41.0..v2.47.0) ran
1.41 ± 0.00 times faster than ./git_describe_pq describe $(git rev-list v2.41.0..v2.47.0)
1.83 ± 0.00 times faster than ./git_2.50.1 describe $(git rev-list v2.41.0..v2.47.0)
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>1 parent 66e2adb commit 08bb69d
1 file changed
+52
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
253 | | - | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
254 | 290 | | |
255 | | - | |
256 | | - | |
| 291 | + | |
| 292 | + | |
257 | 293 | | |
258 | 294 | | |
259 | 295 | | |
260 | 296 | | |
261 | 297 | | |
262 | 298 | | |
263 | | - | |
| 299 | + | |
264 | 300 | | |
265 | 301 | | |
266 | 302 | | |
267 | | - | |
268 | | - | |
| 303 | + | |
| 304 | + | |
269 | 305 | | |
270 | 306 | | |
271 | 307 | | |
| |||
277 | 313 | | |
278 | 314 | | |
279 | 315 | | |
280 | | - | |
| 316 | + | |
281 | 317 | | |
282 | 318 | | |
283 | 319 | | |
| |||
319 | 355 | | |
320 | 356 | | |
321 | 357 | | |
322 | | - | |
| 358 | + | |
323 | 359 | | |
324 | 360 | | |
325 | 361 | | |
| |||
363 | 399 | | |
364 | 400 | | |
365 | 401 | | |
366 | | - | |
367 | | - | |
368 | | - | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
369 | 405 | | |
370 | 406 | | |
371 | 407 | | |
| |||
399 | 435 | | |
400 | 436 | | |
401 | 437 | | |
402 | | - | |
| 438 | + | |
403 | 439 | | |
404 | 440 | | |
405 | 441 | | |
| |||
422 | 458 | | |
423 | 459 | | |
424 | 460 | | |
425 | | - | |
| 461 | + | |
426 | 462 | | |
427 | 463 | | |
428 | 464 | | |
| |||
437 | 473 | | |
438 | 474 | | |
439 | 475 | | |
440 | | - | |
| 476 | + | |
441 | 477 | | |
442 | 478 | | |
443 | 479 | | |
| |||
453 | 489 | | |
454 | 490 | | |
455 | 491 | | |
456 | | - | |
| 492 | + | |
457 | 493 | | |
458 | 494 | | |
459 | 495 | | |
460 | | - | |
| 496 | + | |
461 | 497 | | |
462 | 498 | | |
463 | 499 | | |
| |||
0 commit comments