Skip to content

reconciler: Add WithName option#157

Merged
joamaki merged 1 commit intomainfrom
pr/joamaki/reconciler-name
Apr 15, 2026
Merged

reconciler: Add WithName option#157
joamaki merged 1 commit intomainfrom
pr/joamaki/reconciler-name

Conversation

@joamaki
Copy link
Copy Markdown
Contributor

@joamaki joamaki commented Apr 13, 2026

The reconciler metrics only had the Hive module ID to identify the reconciler instance.

Extend the [reconciler.Metrics] to pass an additional reconciler name to the metrics and add WithName() option to set the name to allow multiple reconcilers in a module with separate metrics.

The reconciler metrics only had the Hive module ID to identify
the reconciler instance.

Extend the [reconciler.Metrics] to pass an additional reconciler
name to the metrics and add WithName() option to set the name
to allow multiple reconcilers in a module with separate metrics.

Signed-off-by: Jussi Maki <jussi.maki@isovalent.com>
@joamaki joamaki requested a review from a team as a code owner April 13, 2026 08:53
@joamaki joamaki requested review from dylandreimerink and removed request for a team April 13, 2026 08:53
@github-actions
Copy link
Copy Markdown

$ make
go build ./...
go: downloading go.yaml.in/yaml/v3 v3.0.3
go: downloading github.com/cilium/hive v1.0.0
go: downloading golang.org/x/time v0.5.0
go: downloading github.com/spf13/cobra v1.8.0
go: downloading github.com/spf13/pflag v1.0.5
go: downloading github.com/cilium/stream v0.0.0-20240209152734-a0792b51812d
go: downloading github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de
go: downloading go.uber.org/dig v1.17.1
go: downloading golang.org/x/term v0.16.0
go: downloading github.com/spf13/viper v1.18.2
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 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
go: downloading golang.org/x/text v0.14.0
STATEDB_VALIDATE=1 go test ./... -cover -vet=all -test.count 1
go: downloading github.com/stretchr/testify v1.8.4
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	445.829s	coverage: 78.6% of statements
ok  	github.com/cilium/statedb/index	0.007s	coverage: 33.7% of statements
ok  	github.com/cilium/statedb/internal	0.021s	coverage: 42.9% of statements
ok  	github.com/cilium/statedb/lpm	4.399s	coverage: 77.6% of statements
ok  	github.com/cilium/statedb/part	72.374s	coverage: 87.7% of statements
ok  	github.com/cilium/statedb/reconciler	0.379s	coverage: 93.0% 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	39.790s
ok  	github.com/cilium/statedb/index	1.016s
ok  	github.com/cilium/statedb/internal	1.027s
ok  	github.com/cilium/statedb/lpm	2.928s
ok  	github.com/cilium/statedb/part	37.196s
ok  	github.com/cilium/statedb/reconciler	1.317s
?   	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                      	  623017	      1879 ns/op	    532104 objects/sec	    1000 B/op	      16 allocs/op
BenchmarkDB_WriteTxn_10-4                     	 1617985	       743.5 ns/op	   1345048 objects/sec	     520 B/op	       8 allocs/op
BenchmarkDB_WriteTxn_100-4                    	 1923512	       627.5 ns/op	   1593715 objects/sec	     536 B/op	       7 allocs/op
BenchmarkDB_WriteTxn_1000-4                   	 1661421	       727.9 ns/op	   1373762 objects/sec	     522 B/op	       7 allocs/op
BenchmarkDB_WriteTxn_100_SecondaryIndex-4     	  729782	      1464 ns/op	    683068 objects/sec	    1100 B/op	      20 allocs/op
BenchmarkDB_WriteTxn_CommitOnly_100Tables-4   	  885919	      1265 ns/op	    1112 B/op	       5 allocs/op
BenchmarkDB_WriteTxn_CommitOnly_1Table-4      	 1479583	       805.9 ns/op	     224 B/op	       5 allocs/op
BenchmarkDB_NewWriteTxn-4                     	 1696608	       714.8 ns/op	     200 B/op	       4 allocs/op
BenchmarkDB_WriteTxnCommit100-4               	  901042	      1236 ns/op	    1096 B/op	       5 allocs/op
BenchmarkDB_NewReadTxn-4                      	542841178	         2.188 ns/op	       0 B/op	       0 allocs/op
BenchmarkDB_Modify-4                          	    1438	    762647 ns/op	   1311222 objects/sec	  546080 B/op	    8094 allocs/op
BenchmarkDB_GetInsert-4                       	    1407	    851899 ns/op	   1173848 objects/sec	  530071 B/op	    8094 allocs/op
BenchmarkDB_RandomInsert-4                    	    1651	    736958 ns/op	   1356930 objects/sec	  522023 B/op	    7094 allocs/op
BenchmarkDB_RandomReplace-4                   	     418	   2889576 ns/op	    346072 objects/sec	 2073386 B/op	   29146 allocs/op
BenchmarkDB_SequentialInsert-4                	    1753	    712200 ns/op	   1404099 objects/sec	  522022 B/op	    7094 allocs/op
BenchmarkDB_SequentialInsert_Prefix-4         	     446	   2690878 ns/op	    371626 objects/sec	 3563371 B/op	   45542 allocs/op
BenchmarkDB_Changes_Baseline-4                	    1438	    840659 ns/op	   1189544 objects/sec	  582209 B/op	    9185 allocs/op
BenchmarkDB_Changes-4                         	     856	   1393227 ns/op	    717758 objects/sec	  783359 B/op	   12336 allocs/op
BenchmarkDB_RandomLookup-4                    	   21830	     54957 ns/op	  18196150 objects/sec	       0 B/op	       0 allocs/op
BenchmarkDB_SequentialLookup-4                	   26773	     44874 ns/op	  22284443 objects/sec	       0 B/op	       0 allocs/op
BenchmarkDB_Prefix_SecondaryIndex-4           	    7254	    173600 ns/op	   5760362 objects/sec	  124920 B/op	    1025 allocs/op
BenchmarkDB_FullIteration_All-4               	    1080	   1071363 ns/op	  93339070 objects/sec	     104 B/op	       4 allocs/op
BenchmarkDB_FullIteration_Prefix-4            	     913	   1183910 ns/op	  84465854 objects/sec	     136 B/op	       5 allocs/op
BenchmarkDB_FullIteration_Get-4               	     216	   5447903 ns/op	  18355688 objects/sec	       0 B/op	       0 allocs/op
BenchmarkDB_FullIteration_Get_Secondary-4     	      96	  10441283 ns/op	   9577367 objects/sec	       0 B/op	       0 allocs/op
BenchmarkDB_FullIteration_ReadTxnGet-4        	     218	   5453786 ns/op	  18335887 objects/sec	       0 B/op	       0 allocs/op
BenchmarkDB_PropagationDelay-4                	  660842	      1815 ns/op	        14.00 50th_µs	        18.00 90th_µs	        82.00 99th_µs	    1120 B/op	      19 allocs/op
BenchmarkDB_WriteTxn_100_LPMIndex-4           	  452379	      2495 ns/op	    400799 objects/sec	    1825 B/op	      37 allocs/op
BenchmarkDB_WriteTxn_1_LPMIndex-4             	  131594	     14960 ns/op	     66844 objects/sec	   15759 B/op	      81 allocs/op
BenchmarkDB_LPMIndex_Get-4                    	     405	   2902384 ns/op	   3445443 objects/sec	       0 B/op	       0 allocs/op
BenchmarkWatchSet_4-4                         	 2196957	       541.6 ns/op	     296 B/op	       4 allocs/op
BenchmarkWatchSet_16-4                        	  704156	      1633 ns/op	    1096 B/op	       5 allocs/op
BenchmarkWatchSet_128-4                       	   84808	     14246 ns/op	    8904 B/op	       5 allocs/op
BenchmarkWatchSet_1024-4                      	    8142	    138051 ns/op	   73744 B/op	       5 allocs/op
PASS
ok  	github.com/cilium/statedb	44.611s
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   	 6128624	       195.8 ns/op	       0 B/op	       0 allocs/op
PASS
ok  	github.com/cilium/statedb/internal	1.204s
goos: linux
goarch: amd64
pkg: github.com/cilium/statedb/lpm
cpu: AMD EPYC 7763 64-Core Processor                
Benchmark_txn_insert/batchSize=1-4         	    1758	    692165 ns/op	   1444742 objects/sec	  838406 B/op	   13975 allocs/op
Benchmark_txn_insert/batchSize=10-4        	    2835	    427006 ns/op	   2341886 objects/sec	  385193 B/op	    6668 allocs/op
Benchmark_txn_insert/batchSize=100-4       	    2971	    391370 ns/op	   2555129 objects/sec	  345613 B/op	    6027 allocs/op
Benchmark_txn_delete/batchSize=1-4         	    1472	    819584 ns/op	   1220131 objects/sec	 1286470 B/op	   13976 allocs/op
Benchmark_txn_delete/batchSize=10-4        	    2913	    420568 ns/op	   2377737 objects/sec	  372417 B/op	    5769 allocs/op
Benchmark_txn_delete/batchSize=100-4       	    3225	    362595 ns/op	   2757900 objects/sec	  286753 B/op	    5038 allocs/op
Benchmark_LPM_Lookup-4                     	    7723	    151432 ns/op	   6603634 objects/sec	       0 B/op	       0 allocs/op
Benchmark_LPM_All-4                        	  123990	      9155 ns/op	 109232725 objects/sec	      32 B/op	       1 allocs/op
Benchmark_LPM_Prefix-4                     	  133006	      9113 ns/op	 109737568 objects/sec	      32 B/op	       1 allocs/op
Benchmark_LPM_LowerBound-4                 	  246240	      4892 ns/op	 102200168 objects/sec	     288 B/op	       2 allocs/op
PASS
ok  	github.com/cilium/statedb/lpm	11.926s
goos: linux
goarch: amd64
pkg: github.com/cilium/statedb/part
cpu: AMD EPYC 7763 64-Core Processor                
Benchmark_Uint64Map_Random-4                  	    1362	    876390 ns/op	   1141045 items/sec	 2524699 B/op	    6048 allocs/op
Benchmark_Uint64Map_Sequential-4              	    1598	    686931 ns/op	   1455750 items/sec	 2216724 B/op	    5754 allocs/op
Benchmark_Uint64Map_Sequential_Insert-4       	    1890	    618320 ns/op	   1617286 items/sec	 2208724 B/op	    4753 allocs/op
Benchmark_Uint64Map_Sequential_Txn_Insert-4   	    9560	    113925 ns/op	   8777724 items/sec	   86352 B/op	    2028 allocs/op
Benchmark_Uint64Map_Random_Insert-4           	    1585	    733229 ns/op	   1363831 items/sec	 2517317 B/op	    5032 allocs/op
Benchmark_Uint64Map_Random_Txn_Insert-4       	    6115	    170897 ns/op	   5851477 items/sec	  119098 B/op	    2415 allocs/op
Benchmark_Insert_RootOnlyWatch-4              	   10000	    115533 ns/op	   8655555 objects/sec	   71504 B/op	    2033 allocs/op
Benchmark_Insert-4                            	    8070	    159404 ns/op	   6273384 objects/sec	  186937 B/op	    3060 allocs/op
Benchmark_Modify-4                            	   10000	    101604 ns/op	   9842140 objects/sec	   58224 B/op	    1007 allocs/op
Benchmark_GetInsert-4                         	    8108	    137485 ns/op	   7273530 objects/sec	   58224 B/op	    1007 allocs/op
Benchmark_Replace-4                           	31773044	        37.43 ns/op	  26715270 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Replace_RootOnlyWatch-4             	31839684	        37.48 ns/op	  26682739 objects/sec	       0 B/op	       0 allocs/op
Benchmark_txn_1-4                             	 5858436	       199.3 ns/op	   5017748 objects/sec	     168 B/op	       3 allocs/op
Benchmark_txn_10-4                            	 9979023	       121.8 ns/op	   8207363 objects/sec	      86 B/op	       2 allocs/op
Benchmark_txn_100-4                           	11554791	       105.0 ns/op	   9523656 objects/sec	      80 B/op	       2 allocs/op
Benchmark_txn_1000-4                          	 9860608	       119.6 ns/op	   8361953 objects/sec	      65 B/op	       2 allocs/op
Benchmark_txn_delete_1-4                      	 4700476	       257.1 ns/op	   3889870 objects/sec	     664 B/op	       4 allocs/op
Benchmark_txn_delete_10-4                     	10793678	       109.0 ns/op	   9172505 objects/sec	     106 B/op	       1 allocs/op
Benchmark_txn_delete_100-4                    	11620372	        98.52 ns/op	  10150754 objects/sec	      47 B/op	       1 allocs/op
Benchmark_txn_delete_1000-4                   	13809169	        83.27 ns/op	  12008586 objects/sec	      24 B/op	       1 allocs/op
Benchmark_Get-4                               	   44746	     26814 ns/op	  37293873 objects/sec	       0 B/op	       0 allocs/op
Benchmark_All-4                               	  120049	     10342 ns/op	  96689965 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Iterator_All-4                      	  134366	      9908 ns/op	 100930843 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Iterator_Next-4                     	  159777	      7557 ns/op	 132326093 objects/sec	     896 B/op	       1 allocs/op
Benchmark_Hashmap_Insert-4                    	   14448	     83337 ns/op	  11999470 objects/sec	   74264 B/op	      20 allocs/op
Benchmark_Hashmap_Get_Uint64-4                	  134734	      8861 ns/op	 112854165 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Hashmap_Get_Bytes-4                 	  106980	     10772 ns/op	  92834498 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Delete_Random-4                     	      84	  13937270 ns/op	   7175006 objects/sec	 2111843 B/op	  102364 allocs/op
Benchmark_find16-4                            	201173988	         5.944 ns/op	       0 B/op	       0 allocs/op
Benchmark_findIndex16-4                       	100000000	        13.03 ns/op	       0 B/op	       0 allocs/op
Benchmark_find48-4                            	384823143	         3.120 ns/op	       0 B/op	       0 allocs/op
Benchmark_findIndex48_hit-4                   	427415953	         2.806 ns/op	       0 B/op	       0 allocs/op
Benchmark_findIndex48_miss-4                  	382159604	         3.124 ns/op	       0 B/op	       0 allocs/op
Benchmark_find4-4                             	423550587	         2.828 ns/op	       0 B/op	       0 allocs/op
Benchmark_findIndex4-4                        	320200731	         3.744 ns/op	       0 B/op	       0 allocs/op
PASS
ok  	github.com/cilium/statedb/part	42.761s
PASS
ok  	github.com/cilium/statedb/reconciler	0.005s
?   	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 492510.30 objects per second
888MB total allocated, 6015181 in-use objects, 338MB bytes in use

@joamaki joamaki merged commit 2f79c85 into main Apr 15, 2026
1 check passed
@joamaki joamaki deleted the pr/joamaki/reconciler-name branch April 15, 2026 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants