@@ -547,23 +547,102 @@ func (c *createWrapper) Create(ctx context.Context, key string, obj, out runtime
547
547
})
548
548
}
549
549
550
- func BenchmarkStoreListCreate (b * testing.B ) {
550
+ func BenchmarkStoreCreateList (b * testing.B ) {
551
551
klog .SetLogger (logr .Discard ())
552
- b .Run ("RV=NotOlderThan" , func (b * testing.B ) {
553
- ctx , cacher , _ , terminate := testSetupWithEtcdServer (b )
554
- b .Cleanup (terminate )
555
- storagetesting .RunBenchmarkStoreListCreate (ctx , b , cacher , metav1 .ResourceVersionMatchNotOlderThan )
556
- })
557
- b .Run ("RV=ExactMatch" , func (b * testing.B ) {
558
- ctx , cacher , _ , terminate := testSetupWithEtcdServer (b )
559
- b .Cleanup (terminate )
560
- storagetesting .RunBenchmarkStoreListCreate (ctx , b , cacher , metav1 .ResourceVersionMatchExact )
561
- })
552
+ storeOptions := []struct {
553
+ name string
554
+ btreeEnabled bool
555
+ }{
556
+ {
557
+ name : "Btree" ,
558
+ btreeEnabled : true ,
559
+ },
560
+ {
561
+ name : "Map" ,
562
+ btreeEnabled : false ,
563
+ },
564
+ }
565
+ for _ , store := range storeOptions {
566
+ b .Run (fmt .Sprintf ("Store=%s" , store .name ), func (b * testing.B ) {
567
+ featuregatetesting .SetFeatureGateDuringTest (b , utilfeature .DefaultFeatureGate , features .BtreeWatchCache , store .btreeEnabled )
568
+ for _ , rvm := range []metav1.ResourceVersionMatch {metav1 .ResourceVersionMatchNotOlderThan , metav1 .ResourceVersionMatchExact } {
569
+ b .Run (fmt .Sprintf ("RV=%s" , rvm ), func (b * testing.B ) {
570
+ for _ , useIndex := range []bool {true , false } {
571
+ b .Run (fmt .Sprintf ("Indexed=%v" , useIndex ), func (b * testing.B ) {
572
+ opts := []setupOption {}
573
+ if useIndex {
574
+ opts = append (opts , withSpecNodeNameIndexerFuncs )
575
+ }
576
+ ctx , cacher , _ , terminate := testSetupWithEtcdServer (b , opts ... )
577
+ b .Cleanup (terminate )
578
+ storagetesting .RunBenchmarkStoreListCreate (ctx , b , cacher , rvm )
579
+ })
580
+ }
581
+ })
582
+ }
583
+ })
584
+ }
562
585
}
563
586
564
587
func BenchmarkStoreList (b * testing.B ) {
565
588
klog .SetLogger (logr .Discard ())
566
- ctx , cacher , _ , terminate := testSetupWithEtcdServer (b , withSpecNodeNameIndexerFuncs )
567
- b .Cleanup (terminate )
568
- storagetesting .RunBenchmarkStoreList (ctx , b , cacher )
589
+ // Based on https://github.com/kubernetes/community/blob/master/sig-scalability/configs-and-limits/thresholds.md
590
+ dimensions := []struct {
591
+ namespaceCount int
592
+ podPerNamespaceCount int
593
+ nodeCount int
594
+ }{
595
+ {
596
+ namespaceCount : 10_000 ,
597
+ podPerNamespaceCount : 15 ,
598
+ nodeCount : 5_000 ,
599
+ },
600
+ {
601
+ namespaceCount : 50 ,
602
+ podPerNamespaceCount : 3_000 ,
603
+ nodeCount : 5_000 ,
604
+ },
605
+ {
606
+ namespaceCount : 100 ,
607
+ podPerNamespaceCount : 1_100 ,
608
+ nodeCount : 1000 ,
609
+ },
610
+ }
611
+ for _ , dims := range dimensions {
612
+ b .Run (fmt .Sprintf ("Namespaces=%d/Pods=%d/Nodes=%d" , dims .namespaceCount , dims .namespaceCount * dims .podPerNamespaceCount , dims .nodeCount ), func (b * testing.B ) {
613
+ data := storagetesting .PrepareBenchchmarkData (dims .namespaceCount , dims .podPerNamespaceCount , dims .nodeCount )
614
+ storeOptions := []struct {
615
+ name string
616
+ btreeEnabled bool
617
+ }{
618
+ {
619
+ name : "Btree" ,
620
+ btreeEnabled : true ,
621
+ },
622
+ {
623
+ name : "Map" ,
624
+ btreeEnabled : false ,
625
+ },
626
+ }
627
+ for _ , store := range storeOptions {
628
+ b .Run (fmt .Sprintf ("Store=%s" , store .name ), func (b * testing.B ) {
629
+ featuregatetesting .SetFeatureGateDuringTest (b , utilfeature .DefaultFeatureGate , features .BtreeWatchCache , store .btreeEnabled )
630
+ ctx , cacher , _ , terminate := testSetupWithEtcdServer (b , withSpecNodeNameIndexerFuncs )
631
+ b .Cleanup (terminate )
632
+ var out example.Pod
633
+ for _ , pod := range data .Pods {
634
+ err := cacher .Create (ctx , computePodKey (pod ), pod , & out , 0 )
635
+ if err != nil {
636
+ b .Fatal (err )
637
+ }
638
+ }
639
+ for _ , useIndex := range []bool {true , false } {
640
+ b .Run (fmt .Sprintf ("Indexed=%v" , useIndex ), func (b * testing.B ) {
641
+ storagetesting .RunBenchmarkStoreList (ctx , b , cacher , data , useIndex )
642
+ })
643
+ }
644
+ })
645
+ }
646
+ })
647
+ }
569
648
}
0 commit comments