← Back to Pull requests

WatchSet.Wait now waits even with single channel #177

Merged
joamaki merged 2 files (63 lines) on Aug 19, 2026 12:25 UTC
View on GitHub
joamaki joamaki commented on Aug 19, 2026 11:57 UTC
Author

The original semantics of returning immediately when the channel in a single channel set closes is at odds with how this is being used.

We want the settle time to be a form of rate-limiting to avoid computing too often and this should also apply to the single channel case.

Change the WatchSet.Wait to also wait with a single channel set.

Reported-by: Marco Iorio <marco.iorio@isovalent.com>

Diff: 63 lines (+53 / -10) across 2 files Reviewer: bimmlerd Review duration: 27m
All Vouch review confidence checks passed
Residual risk 0.02 = Change Risk (0.29) × (1 − Review Confidence (0.92)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.29 · 63 lines diff across 2 files
0.29
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.96 · 1 substantive comment(s)
0.96
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
91%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.249
Real PR Conversation Timeline
3 items
github-actions[bot] github-actions[bot] commented on Aug 19, 2026 12:09 UTC
Bot

$ make
go build ./...
go: downloading go.yaml.in/yaml/v3 v3.0.4
go: downloading github.com/cilium/hive v1.0.4
go: downloading golang.org/x/time v0.15.0
go: downloading github.com/spf13/cobra v1.10.2
go: downloading github.com/spf13/pflag v1.0.10
go: downloading github.com/cilium/stream v0.0.1
go: downloading github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de
go: downloading go.uber.org/dig v1.17.1
go: downloading github.com/spf13/viper v1.18.2
go: downloading golang.org/x/term v0.16.0
go: downloading github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
go: downloading github.com/mitchellh/mapstructure v1.5.0
go: downloading golang.org/x/sys v0.17.0
go: downloading golang.org/x/tools v0.17.0
go: downloading github.com/spf13/cast v1.6.0
go: downloading github.com/fsnotify/fsnotify v1.7.0
go: downloading github.com/sagikazarmark/slog-shim v0.1.0
go: downloading github.com/spf13/afero v1.11.0
go: downloading golang.org/x/text v0.14.0
go: downloading github.com/subosito/gotenv v1.6.0
go: downloading github.com/hashicorp/hcl v1.0.0
go: downloading gopkg.in/ini.v1 v1.67.0
go: downloading github.com/magiconair/properties v1.8.7
go: downloading github.com/pelletier/go-toml/v2 v2.1.0
go: downloading gopkg.in/yaml.v3 v3.0.1
STATEDB_VALIDATE=1 go test ./... -cover -vet=all -test.count 1
go: downloading github.com/stretchr/testify v1.11.1
go: downloading go.uber.org/goleak v1.3.0
go: downloading golang.org/x/exp v0.0.0-20240119083558-1b970713d09a
go: downloading github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2
ok  	github.com/cilium/statedb	424.357s	coverage: 79.1% of statements
ok  	github.com/cilium/statedb/index	0.006s	coverage: 33.7% of statements
ok  	github.com/cilium/statedb/internal	0.033s	coverage: 42.9% of statements
ok  	github.com/cilium/statedb/lpm	4.755s	coverage: 77.9% of statements
ok  	github.com/cilium/statedb/part	64.228s	coverage: 87.3% of statements
ok  	github.com/cilium/statedb/reconciler	0.277s	coverage: 93.1% of statements
	github.com/cilium/statedb/reconciler/benchmark		coverage: 0.0% of statements
	github.com/cilium/statedb/reconciler/example		coverage: 0.0% of statements
go test -race ./... -test.count 1
ok  	github.com/cilium/statedb	40.987s
ok  	github.com/cilium/statedb/index	1.016s
ok  	github.com/cilium/statedb/internal	1.026s
ok  	github.com/cilium/statedb/lpm	2.586s
ok  	github.com/cilium/statedb/part	37.467s
ok  	github.com/cilium/statedb/reconciler	1.391s
?   	github.com/cilium/statedb/reconciler/benchmark	[no test files]
?   	github.com/cilium/statedb/reconciler/example	[no test files]
go test ./... -bench . -benchmem -test.run xxx
goos: linux
goarch: amd64
pkg: github.com/cilium/statedb
cpu: AMD EPYC 7763 64-Core Processor                
BenchmarkDB_WriteTxn_1-4                      	  658267	      1804 ns/op	    554195 objects/sec	    1016 B/op	      17 allocs/op
BenchmarkDB_WriteTxn_10-4                     	 1668303	       720.1 ns/op	   1388674 objects/sec	     521 B/op	       8 allocs/op
BenchmarkDB_WriteTxn_100-4                    	 1960711	       606.7 ns/op	   1648184 objects/sec	     536 B/op	       7 allocs/op
BenchmarkDB_WriteTxn_1000-4                   	 1670614	       697.5 ns/op	   1433607 objects/sec	     522 B/op	       7 allocs/op
BenchmarkDB_WriteTxn_100_SecondaryIndex-4     	  759038	      1404 ns/op	    712284 objects/sec	    1100 B/op	      20 allocs/op
BenchmarkDB_WriteTxn_CommitOnly_100Tables-4   	  896484	      1292 ns/op	    1128 B/op	       6 allocs/op
BenchmarkDB_WriteTxn_CommitOnly_1Table-4      	 1385040	       891.6 ns/op	     240 B/op	       6 allocs/op
BenchmarkDB_NewWriteTxn-4                     	 1537770	       777.1 ns/op	     216 B/op	       5 allocs/op
BenchmarkDB_WriteTxnCommit100-4               	  898668	      1308 ns/op	    1112 B/op	       6 allocs/op
BenchmarkDB_NewReadTxn-4                      	638698740	         1.872 ns/op	       0 B/op	       0 allocs/op
BenchmarkDB_Modify-4                          	    1562	    762824 ns/op	   1310918 objects/sec	  546098 B/op	    8095 allocs/op
BenchmarkDB_GetInsert-4                       	    1434	    828659 ns/op	   1206769 objects/sec	  530087 B/op	    8095 allocs/op
BenchmarkDB_RandomInsert-4                    	    1708	    712675 ns/op	   1403163 objects/sec	  522039 B/op	    7095 allocs/op
BenchmarkDB_RandomReplace-4                   	     420	   2792804 ns/op	    358063 objects/sec	 2073413 B/op	   29147 allocs/op
BenchmarkDB_SequentialInsert-4                	    1700	    695331 ns/op	   1438164 objects/sec	  522036 B/op	    7095 allocs/op
BenchmarkDB_SequentialInsert_Prefix-4         	     477	   2515243 ns/op	    397576 objects/sec	 3562735 B/op	   45542 allocs/op
BenchmarkDB_Changes_Baseline-4                	    1471	    807051 ns/op	   1239078 objects/sec	  582239 B/op	    9187 allocs/op
BenchmarkDB_Changes-4                         	     902	   1331547 ns/op	    751006 objects/sec	  783763 B/op	   12338 allocs/op
BenchmarkDB_RandomLookup-4                    	   22083	     54161 ns/op	  18463542 objects/sec	       0 B/op	       0 allocs/op
BenchmarkDB_SequentialLookup-4                	   26546	     45166 ns/op	  22140595 objects/sec	       0 B/op	       0 allocs/op
BenchmarkDB_Prefix_SecondaryIndex-4           	    6714	    167263 ns/op	   5978606 objects/sec	  124920 B/op	    1025 allocs/op
BenchmarkDB_FullIteration_All-4               	     843	   1345786 ns/op	  74306038 objects/sec	     104 B/op	       4 allocs/op
BenchmarkDB_FullIteration_Prefix-4            	    1022	   1176306 ns/op	  85011903 objects/sec	     136 B/op	       5 allocs/op
BenchmarkDB_FullIteration_Get-4               	     213	   5557857 ns/op	  17992546 objects/sec	       0 B/op	       0 allocs/op
BenchmarkDB_FullIteration_Get_Secondary-4     	      97	  10653689 ns/op	   9386420 objects/sec	       0 B/op	       0 allocs/op
BenchmarkDB_FullIteration_ReadTxnGet-4        	     208	   5707841 ns/op	  17519761 objects/sec	       0 B/op	       0 allocs/op
BenchmarkDB_PropagationDelay-4                	  603482	      1794 ns/op	        14.00 50th_µs	        20.00 90th_µs	        67.00 99th_µs	    1124 B/op	      20 allocs/op
BenchmarkDB_WriteTxn_100_LPMIndex-4           	  465026	      2463 ns/op	    406075 objects/sec	    1825 B/op	      37 allocs/op
BenchmarkDB_WriteTxn_1_LPMIndex-4             	  131700	     14759 ns/op	     67758 objects/sec	   15776 B/op	      82 allocs/op
BenchmarkDB_LPMIndex_Get-4                    	     403	   2936934 ns/op	   3404911 objects/sec	       0 B/op	       0 allocs/op
BenchmarkWatchSet_4-4                         	 2225232	       534.0 ns/op	     296 B/op	       4 allocs/op
BenchmarkWatchSet_16-4                        	  736851	      1603 ns/op	    1096 B/op	       5 allocs/op
BenchmarkWatchSet_128-4                       	   86486	     13822 ns/op	    8904 B/op	       5 allocs/op
BenchmarkWatchSet_1024-4                      	    7940	    136930 ns/op	   73744 B/op	       5 allocs/op
PASS
ok  	github.com/cilium/statedb	43.513s
PASS
ok  	github.com/cilium/statedb/index	0.004s
goos: linux
goarch: amd64
pkg: github.com/cilium/statedb/internal
cpu: AMD EPYC 7763 64-Core Processor                
Benchmark_SortableMutex-4   	 5714917	       209.6 ns/op	       0 B/op	       0 allocs/op
PASS
ok  	github.com/cilium/statedb/internal	1.201s
goos: linux
goarch: amd64
pkg: github.com/cilium/statedb/lpm
cpu: AMD EPYC 7763 64-Core Processor                
Benchmark_txn_insert/batchSize=1-4         	    1846	    647421 ns/op	   1544591 objects/sec	  838408 B/op	   13975 allocs/op
Benchmark_txn_insert/batchSize=10-4        	    2996	    398187 ns/op	   2511380 objects/sec	  385194 B/op	    6668 allocs/op
Benchmark_txn_insert/batchSize=100-4       	    3231	    374607 ns/op	   2669466 objects/sec	  345613 B/op	    6027 allocs/op
Benchmark_txn_delete/batchSize=1-4         	    1550	    777595 ns/op	   1286017 objects/sec	 1286471 B/op	   13976 allocs/op
Benchmark_txn_delete/batchSize=10-4        	    3120	    401467 ns/op	   2490866 objects/sec	  372418 B/op	    5769 allocs/op
Benchmark_txn_delete/batchSize=100-4       	    3387	    346483 ns/op	   2886143 objects/sec	  286753 B/op	    5038 allocs/op
Benchmark_LPM_Lookup-4                     	    7848	    152113 ns/op	   6574079 objects/sec	       0 B/op	       0 allocs/op
Benchmark_LPM_All-4                        	  129414	      9342 ns/op	 107047454 objects/sec	      32 B/op	       1 allocs/op
Benchmark_LPM_Prefix-4                     	  129621	      9255 ns/op	 108052949 objects/sec	      32 B/op	       1 allocs/op
Benchmark_LPM_LowerBound-4                 	  243088	      4863 ns/op	 102822687 objects/sec	     288 B/op	       2 allocs/op
PASS
ok  	github.com/cilium/statedb/lpm	12.028s
goos: linux
goarch: amd64
pkg: github.com/cilium/statedb/part
cpu: AMD EPYC 7763 64-Core Processor                
Benchmark_Uint64Map_Random-4                  	    1443	    788031 ns/op	   1268986 items/sec	 2525178 B/op	    6040 allocs/op
Benchmark_Uint64Map_Sequential-4              	    1826	    650382 ns/op	   1537557 items/sec	 2216724 B/op	    5754 allocs/op
Benchmark_Uint64Map_Sequential_Insert-4       	    2026	    594325 ns/op	   1682581 items/sec	 2208720 B/op	    4753 allocs/op
Benchmark_Uint64Map_Sequential_Txn_Insert-4   	   10000	    109426 ns/op	   9138587 items/sec	   86352 B/op	    2028 allocs/op
Benchmark_Uint64Map_Random_Insert-4           	    1659	    720067 ns/op	   1388760 items/sec	 2520050 B/op	    5037 allocs/op
Benchmark_Uint64Map_Random_Txn_Insert-4       	    7196	    166337 ns/op	   6011897 items/sec	  120447 B/op	    2420 allocs/op
Benchmark_Insert_RootOnlyWatch-4              	   10000	    107250 ns/op	   9323980 objects/sec	   71504 B/op	    2033 allocs/op
Benchmark_Insert-4                            	    7701	    157051 ns/op	   6367365 objects/sec	  186937 B/op	    3060 allocs/op
Benchmark_Modify-4                            	   12768	     93975 ns/op	  10641143 objects/sec	   58224 B/op	    1007 allocs/op
Benchmark_GetInsert-4                         	    9624	    120643 ns/op	   8288907 objects/sec	   58224 B/op	    1007 allocs/op
Benchmark_Replace-4                           	32039857	        37.45 ns/op	  26703140 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Replace_RootOnlyWatch-4             	31661680	        37.62 ns/op	  26579796 objects/sec	       0 B/op	       0 allocs/op
Benchmark_txn_1-4                             	 6111808	       194.3 ns/op	   5145500 objects/sec	     168 B/op	       3 allocs/op
Benchmark_txn_10-4                            	10406232	       114.5 ns/op	   8732063 objects/sec	      86 B/op	       2 allocs/op
Benchmark_txn_100-4                           	12186735	        97.54 ns/op	  10252485 objects/sec	      80 B/op	       2 allocs/op
Benchmark_txn_1000-4                          	10951828	       108.4 ns/op	   9226345 objects/sec	      65 B/op	       2 allocs/op
Benchmark_txn_delete_1-4                      	 4831338	       249.3 ns/op	   4011555 objects/sec	     664 B/op	       4 allocs/op
Benchmark_txn_delete_10-4                     	11338212	       104.7 ns/op	   9552138 objects/sec	     106 B/op	       1 allocs/op
Benchmark_txn_delete_100-4                    	12410568	        95.54 ns/op	  10466314 objects/sec	      47 B/op	       1 allocs/op
Benchmark_txn_delete_1000-4                   	14845298	        80.13 ns/op	  12479086 objects/sec	      24 B/op	       1 allocs/op
Benchmark_Get-4                               	   44710	     26837 ns/op	  37262137 objects/sec	       0 B/op	       0 allocs/op
Benchmark_All-4                               	  130905	     10242 ns/op	  97634943 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Iterator_All-4                      	  152688	      9869 ns/op	 101325961 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Iterator_Next-4                     	  159456	      7487 ns/op	 133560726 objects/sec	     896 B/op	       1 allocs/op
Benchmark_Hashmap_Insert-4                    	   14961	     80262 ns/op	  12459243 objects/sec	   74264 B/op	      20 allocs/op
Benchmark_Hashmap_Get_Uint64-4                	  138058	      8670 ns/op	 115342339 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Hashmap_Get_Bytes-4                 	  111331	     10779 ns/op	  92775729 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Delete_Random-4                     	      72	  14055761 ns/op	   7114521 objects/sec	 2111844 B/op	  102364 allocs/op
Benchmark_find16-4                            	202272343	         5.930 ns/op	       0 B/op	       0 allocs/op
Benchmark_findIndex16-4                       	100000000	        12.48 ns/op	       0 B/op	       0 allocs/op
Benchmark_find48-4                            	383017891	         3.126 ns/op	       0 B/op	       0 allocs/op
Benchmark_findIndex48_hit-4                   	427227298	         2.808 ns/op	       0 B/op	       0 allocs/op
Benchmark_findIndex48_miss-4                  	384473485	         3.122 ns/op	       0 B/op	       0 allocs/op
Benchmark_find4-4                             	422904298	         2.835 ns/op	       0 B/op	       0 allocs/op
Benchmark_findIndex4-4                        	320903048	         3.742 ns/op	       0 B/op	       0 allocs/op
PASS
ok  	github.com/cilium/statedb/part	43.200s
PASS
ok  	github.com/cilium/statedb/reconciler	0.004s
?   	github.com/cilium/statedb/reconciler/benchmark	[no test files]
?   	github.com/cilium/statedb/reconciler/example	[no test files]
go run ./reconciler/benchmark -quiet
1000000 objects reconciled in 2.03 seconds (batch size 1000)
Throughput 492170.49 objects per second
888MB total allocated, 6015192 in-use objects, 338MB bytes in use

<!-- thollander/actions-comment-pull-request "results" -->

bimmlerd bimmlerd approved these changes on Aug 19, 2026 12:22 UTC
Approved Reviewer

Right, so this means you can rely on it always taking settleTime and hence use it for rate limiting. Makes sense to me.

Reviewers
Assignees
joamaki joamaki
Labels
risk: low confidence: 91.9% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 29.3% (LOW) · Higher = larger blast radius
29.3%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 91.9% · Lower = rushed or shallow review
91.9%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 2.4% · Safe to merge
2.4%
Repository