Commit b0b7042
committed
part: Optimize findIndex for node48
Use a 1-based indexing in node48.index so that 0 always means that
the key is not present.
Check for exact match first for node48 in findIndex, then check
if key is within bounds and only then binary search. Implement
binary search directly instead of using sort.Search to avoid
the function closure.
goos: darwin
goarch: arm64
pkg: github.com/cilium/statedb/part
cpu: Apple M1 Pro
│ a.txt │ b.txt │
│ sec/op │ sec/op vs base │
_Uint64Map_Sequential_Insert-8 430.5µ ± ∞ ¹ 476.4µ ± ∞ ¹ ~ (p=0.095 n=5)
_Uint64Map_Sequential_Txn_Insert-8 69.15µ ± ∞ ¹ 68.59µ ± ∞ ¹ ~ (p=0.151 n=5)
_Uint64Map_Random_Insert-8 519.9µ ± ∞ ¹ 541.2µ ± ∞ ¹ ~ (p=0.421 n=5)
_Uint64Map_Random_Txn_Insert-8 107.1µ ± ∞ ¹ 104.0µ ± ∞ ¹ -2.87% (p=0.008 n=5)
_Insert_RootOnlyWatch-8 72.25µ ± ∞ ¹ 69.49µ ± ∞ ¹ ~ (p=0.056 n=5)
_Insert-8 100.18µ ± ∞ ¹ 95.70µ ± ∞ ¹ -4.47% (p=0.016 n=5)
_GetInsert-8 79.07µ ± ∞ ¹ 78.45µ ± ∞ ¹ ~ (p=0.151 n=5)
_Hashmap_Insert-8 36.09µ ± ∞ ¹ 36.22µ ± ∞ ¹ ~ (p=0.841 n=5)
_Delete_Random-8 10.188m ± ∞ ¹ 8.640m ± ∞ ¹ -15.19% (p=0.008 n=5)
_find48-8 2.038n ± ∞ ¹ 2.065n ± ∞ ¹ ~ (p=0.095 n=5)
_findIndex48_hit-8 10.180n ± ∞ ¹ 2.047n ± ∞ ¹ -79.89% (p=0.008 n=5)
_findIndex48_miss-8 8.468n ± ∞ ¹ 2.260n ± ∞ ¹ -73.31% (p=0.008 n=5)
│ a.txt │ b.txt │
│ objects/sec │ objects/sec vs base │
_Insert_RootOnlyWatch-8 13.84M ± ∞ ¹ 14.39M ± ∞ ¹ ~ (p=0.056 n=5)
_Insert-8 9.982M ± ∞ ¹ 10.449M ± ∞ ¹ +4.68% (p=0.016 n=5)
_GetInsert-8 12.65M ± ∞ ¹ 12.75M ± ∞ ¹ ~ (p=0.151 n=5)
_Hashmap_Insert-8 27.71M ± ∞ ¹ 27.61M ± ∞ ¹ ~ (p=0.841 n=5)
_Delete_Random-8 9.816M ± ∞ ¹ 11.573M ± ∞ ¹ +17.91% (p=0.008 n=5)
Signed-off-by: Jussi Maki <jussi.maki@isovalent.com>1 parent e56c0c8 commit b0b7042
3 files changed
+50
-39
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
| |||
246 | 245 | | |
247 | 246 | | |
248 | 247 | | |
249 | | - | |
| 248 | + | |
250 | 249 | | |
251 | 250 | | |
252 | 251 | | |
| |||
374 | 373 | | |
375 | 374 | | |
376 | 375 | | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
385 | 391 | | |
386 | | - | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
387 | 404 | | |
388 | 405 | | |
389 | 406 | | |
| |||
418 | 435 | | |
419 | 436 | | |
420 | 437 | | |
421 | | - | |
| 438 | + | |
422 | 439 | | |
423 | 440 | | |
424 | | - | |
| 441 | + | |
425 | 442 | | |
426 | 443 | | |
427 | 444 | | |
| |||
452 | 469 | | |
453 | 470 | | |
454 | 471 | | |
455 | | - | |
| 472 | + | |
456 | 473 | | |
457 | 474 | | |
458 | 475 | | |
459 | | - | |
| 476 | + | |
460 | 477 | | |
461 | 478 | | |
462 | 479 | | |
| |||
489 | 506 | | |
490 | 507 | | |
491 | 508 | | |
492 | | - | |
| 509 | + | |
493 | 510 | | |
494 | | - | |
| 511 | + | |
495 | 512 | | |
496 | 513 | | |
497 | 514 | | |
| |||
547 | 564 | | |
548 | 565 | | |
549 | 566 | | |
550 | | - | |
551 | | - | |
| 567 | + | |
| 568 | + | |
552 | 569 | | |
553 | 570 | | |
554 | 571 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1667 | 1667 | | |
1668 | 1668 | | |
1669 | 1669 | | |
1670 | | - | |
| 1670 | + | |
1671 | 1671 | | |
1672 | 1672 | | |
1673 | 1673 | | |
1674 | | - | |
1675 | | - | |
1676 | | - | |
1677 | 1674 | | |
1678 | 1675 | | |
1679 | 1676 | | |
1680 | 1677 | | |
1681 | 1678 | | |
1682 | 1679 | | |
1683 | | - | |
| 1680 | + | |
1684 | 1681 | | |
1685 | 1682 | | |
1686 | 1683 | | |
| |||
1695 | 1692 | | |
1696 | 1693 | | |
1697 | 1694 | | |
1698 | | - | |
| 1695 | + | |
1699 | 1696 | | |
1700 | 1697 | | |
1701 | 1698 | | |
| |||
1705 | 1702 | | |
1706 | 1703 | | |
1707 | 1704 | | |
1708 | | - | |
| 1705 | + | |
1709 | 1706 | | |
1710 | 1707 | | |
1711 | 1708 | | |
| |||
1720 | 1717 | | |
1721 | 1718 | | |
1722 | 1719 | | |
1723 | | - | |
| 1720 | + | |
1724 | 1721 | | |
1725 | 1722 | | |
1726 | 1723 | | |
1727 | | - | |
1728 | | - | |
1729 | | - | |
1730 | 1724 | | |
1731 | 1725 | | |
1732 | 1726 | | |
1733 | 1727 | | |
1734 | 1728 | | |
1735 | 1729 | | |
1736 | | - | |
| 1730 | + | |
1737 | 1731 | | |
1738 | 1732 | | |
1739 | 1733 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
596 | 596 | | |
597 | 597 | | |
598 | 598 | | |
599 | | - | |
600 | | - | |
601 | | - | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
606 | 607 | | |
607 | | - | |
608 | 608 | | |
609 | 609 | | |
610 | 610 | | |
| |||
0 commit comments