Commit 277e597
committed
Extend Vec term storage to 20k with eager/lazy bucket ids
Raise MAX_NUM_TERMS_FOR_VEC to 20_000 so the dense Vec term storage
(direct-indexed, no hashing/paging) is used for low/moderate cardinality
both with and without sub-aggregations, not just the <100 low-card case.
Split the old single threshold into MAX_NUM_TERMS_FOR_LOWCARD_SUBAGG (100,
still gates the Vec + LowCard-buffer pairing) and MAX_NUM_TERMS_FOR_VEC.
VecTermBuckets is now generic over a compile-time `const LAZY: bool`:
- eager (default): assigns all ids up front in `new`, branchless term_entry
- lazy: assigns on first occurrence, keeping the sub-agg bucket range down
to the terms that actually occur (no blowup for sparse ordinal spaces)
A new BucketIdSlot::ASSIGNS_ID const plus the LAZY const fully gate the
first-seen branch out at monomorphization, so the only branchy path is the
deliberately-lazy <BucketId, true> instantiation. The with-sub-agg Vec path
picks eager below MAX_NUM_TERMS_FOR_EAGER_BUCKET_IDS (4096) and lazy above,
avoiding the ~6-11% hot-loop regression eager fixes while keeping large
sparse cases compact.
Biggest impact on terms_zipf_1000_only with -40%
```
full
terms_7 Memory: 46.5 KB Avg: 2.3566ms (+4.29%) Median: 2.3566ms (+4.29%) [2.3566ms .. 2.3566ms]
terms_all_unique Memory: 11.5 MB Avg: 4.8532ms (-5.74%) Median: 4.8532ms (-5.74%) [4.8532ms .. 4.8532ms]
terms_all_unique_order_by_key Memory: 11.5 MB Avg: 4.8448ms (-0.53%) Median: 4.8448ms (-0.53%) [4.8448ms .. 4.8448ms]
terms_150_000 Memory: 2.7 MB Avg: 5.5295ms (+0.64%) Median: 5.5295ms (+0.64%) [5.5295ms .. 5.5295ms]
terms_many_top_1000 Memory: 5.3 MB Avg: 8.4738ms (+0.58%) Median: 8.4738ms (+0.58%) [8.4738ms .. 8.4738ms]
terms_many_order_by_term Memory: 2.7 MB (-0.01%) Avg: 4.5959ms (-0.15%) Median: 4.5959ms (-0.15%) [4.5959ms .. 4.5959ms]
terms_many_with_top_hits Memory: 48.9 MB (-0.00%) Avg: 85.8206ms (-5.46%) Median: 85.8206ms (-5.46%) [85.8206ms .. 85.8206ms]
terms_all_unique_with_avg_sub_agg Memory: 54.7 MB (-0.00%) Avg: 17.8747ms (+8.16%) Median: 17.8747ms (+8.16%) [17.8747ms .. 17.8747ms]
terms_many_with_avg_sub_agg Memory: 13.5 MB (-0.00%) Avg: 14.7797ms (+2.54%) Median: 14.7797ms (+2.54%) [14.7797ms .. 14.7797ms]
terms_status_with_avg_sub_agg Memory: 92.1 KB (-0.35%) Avg: 5.1467ms (+0.72%) Median: 5.1467ms (+0.72%) [5.1467ms .. 5.1467ms]
terms_status_with_terms_zipf_1000_sub_agg Memory: 213.2 KB Avg: 3.9576ms (-2.73%) Median: 3.9576ms (-2.73%) [3.9576ms .. 3.9576ms]
terms_zipf_1000_with_terms_status_sub_agg Memory: 726.5 KB (+0.28%) Avg: 12.1432ms (+3.30%) Median: 12.1432ms (+3.30%) [12.1432ms .. 12.1432ms]
terms_status_with_histogram Memory: 139.0 KB Avg: 2.4717ms (+2.45%) Median: 2.4717ms (+2.45%) [2.4717ms .. 2.4717ms]
terms_status_with_date_histogram Memory: 145.9 KB Avg: 2.3644ms (-0.44%) Median: 2.3644ms (-0.44%) [2.3644ms .. 2.3644ms]
terms_status_with_date_histogram_hard_bounds Memory: 145.4 KB Avg: 2.5705ms (+4.70%) Median: 2.5705ms (+4.70%) [2.5705ms .. 2.5705ms]
terms_status_with_date_histogram_and_sibling_terms Memory: 143.3 KB Avg: 3.8946ms (+1.61%) Median: 3.8946ms (+1.61%) [3.8946ms .. 3.8946ms]
terms_zipf_1000_only Memory: 75.8 KB (-0.02%) Avg: 1.2684ms (-41.50%) Median: 1.2684ms (-41.50%) [1.2684ms .. 1.2684ms]
terms_zipf_1000_with_histogram Memory: 1.2 MB (+0.17%) Avg: 20.9323ms (+4.08%) Median: 20.9323ms (+4.08%) [20.9323ms .. 20.9323ms]
terms_zipf_1000_with_avg_sub_agg Memory: 486.7 KB (+2.95%) Avg: 8.5297ms (-1.66%) Median: 8.5297ms (-1.66%) [8.5297ms .. 8.5297ms]
terms_many_json_mixed_type_with_avg_sub_agg Memory: 17.9 MB Avg: 27.0210ms (+1.81%) Median: 27.0210ms (+1.81%) [27.0210ms .. 27.0210ms]
terms_status_with_cardinality_agg Memory: 93.9 KB Avg: 3.2022ms (-0.64%) Median: 3.2022ms (-0.64%) [3.2022ms .. 3.2022ms]
terms_100_buckets_with_cardinality_agg Memory: 9.8 MB (+0.31%) Avg: 49.3188ms (-1.70%) Median: 49.3188ms (-1.70%) [49.3188ms .. 49.3188ms]
terms_many_with_single_term_order_by_card Memory: 48.9 MB Avg: 77.2127ms (-5.02%) Median: 77.2127ms (-5.02%) [77.2127ms .. 77.2127ms]
terms_many_with_single_term_2_order_by_card Memory: 40.6 MB (-0.02%) Avg: 45.8004ms (-17.57%) Median: 45.8004ms (-17.57%) [45.8004ms .. 45.8004ms]
```1 parent fc84c0f commit 277e597
3 files changed
Lines changed: 197 additions & 50 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
259 | 263 | | |
260 | 264 | | |
261 | 265 | | |
| |||
265 | 269 | | |
266 | 270 | | |
267 | 271 | | |
| 272 | + | |
268 | 273 | | |
269 | 274 | | |
270 | 275 | | |
| |||
275 | 280 | | |
276 | 281 | | |
277 | 282 | | |
| 283 | + | |
278 | 284 | | |
279 | 285 | | |
280 | 286 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
335 | 335 | | |
336 | 336 | | |
337 | 337 | | |
338 | | - | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
339 | 343 | | |
340 | | - | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
341 | 357 | | |
342 | 358 | | |
343 | 359 | | |
344 | 360 | | |
345 | 361 | | |
346 | 362 | | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
347 | 379 | | |
348 | 380 | | |
349 | 381 | | |
| |||
413 | 445 | | |
414 | 446 | | |
415 | 447 | | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
416 | 468 | | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
| 469 | + | |
| 470 | + | |
421 | 471 | | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
447 | 476 | | |
448 | | - | |
| 477 | + | |
| 478 | + | |
449 | 479 | | |
450 | 480 | | |
451 | 481 | | |
| |||
454 | 484 | | |
455 | 485 | | |
456 | 486 | | |
457 | | - | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
458 | 490 | | |
459 | 491 | | |
460 | 492 | | |
| |||
463 | 495 | | |
464 | 496 | | |
465 | 497 | | |
466 | | - | |
467 | | - | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
468 | 514 | | |
469 | 515 | | |
470 | 516 | | |
| |||
473 | 519 | | |
474 | 520 | | |
475 | 521 | | |
476 | | - | |
| 522 | + | |
477 | 523 | | |
478 | 524 | | |
479 | 525 | | |
| |||
482 | 528 | | |
483 | 529 | | |
484 | 530 | | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
485 | 549 | | |
486 | 550 | | |
487 | 551 | | |
| |||
731 | 795 | | |
732 | 796 | | |
733 | 797 | | |
734 | | - | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
735 | 801 | | |
736 | | - | |
| 802 | + | |
737 | 803 | | |
738 | 804 | | |
739 | 805 | | |
740 | | - | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
741 | 809 | | |
742 | 810 | | |
743 | 811 | | |
| |||
753 | 821 | | |
754 | 822 | | |
755 | 823 | | |
756 | | - | |
| 824 | + | |
757 | 825 | | |
758 | 826 | | |
759 | 827 | | |
| |||
762 | 830 | | |
763 | 831 | | |
764 | 832 | | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
765 | 840 | | |
766 | 841 | | |
767 | 842 | | |
| |||
776 | 851 | | |
777 | 852 | | |
778 | 853 | | |
779 | | - | |
780 | | - | |
781 | | - | |
782 | | - | |
783 | | - | |
784 | | - | |
785 | | - | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
786 | 865 | | |
787 | 866 | | |
788 | 867 | | |
| |||
2566 | 2645 | | |
2567 | 2646 | | |
2568 | 2647 | | |
| 2648 | + | |
| 2649 | + | |
| 2650 | + | |
| 2651 | + | |
| 2652 | + | |
| 2653 | + | |
| 2654 | + | |
| 2655 | + | |
| 2656 | + | |
| 2657 | + | |
| 2658 | + | |
| 2659 | + | |
| 2660 | + | |
| 2661 | + | |
| 2662 | + | |
| 2663 | + | |
| 2664 | + | |
| 2665 | + | |
| 2666 | + | |
| 2667 | + | |
| 2668 | + | |
| 2669 | + | |
| 2670 | + | |
| 2671 | + | |
| 2672 | + | |
| 2673 | + | |
| 2674 | + | |
| 2675 | + | |
| 2676 | + | |
| 2677 | + | |
| 2678 | + | |
| 2679 | + | |
| 2680 | + | |
| 2681 | + | |
| 2682 | + | |
| 2683 | + | |
| 2684 | + | |
| 2685 | + | |
| 2686 | + | |
| 2687 | + | |
| 2688 | + | |
| 2689 | + | |
| 2690 | + | |
| 2691 | + | |
| 2692 | + | |
| 2693 | + | |
| 2694 | + | |
| 2695 | + | |
| 2696 | + | |
| 2697 | + | |
| 2698 | + | |
| 2699 | + | |
| 2700 | + | |
| 2701 | + | |
| 2702 | + | |
| 2703 | + | |
| 2704 | + | |
| 2705 | + | |
| 2706 | + | |
| 2707 | + | |
| 2708 | + | |
| 2709 | + | |
| 2710 | + | |
2569 | 2711 | | |
2570 | 2712 | | |
2571 | 2713 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
389 | 389 | | |
390 | 390 | | |
391 | 391 | | |
392 | | - | |
393 | | - | |
394 | | - | |
| 392 | + | |
| 393 | + | |
395 | 394 | | |
396 | 395 | | |
397 | 396 | | |
| |||
0 commit comments