Skip to content

script: fix db/cmp update header indentation#160

Merged
joamaki merged 1 commit into
mainfrom
pr/tklauser/update-no-header-indent
Jun 9, 2026
Merged

script: fix db/cmp update header indentation#160
joamaki merged 1 commit into
mainfrom
pr/tklauser/update-no-header-indent

Conversation

@tklauser

@tklauser tklauser commented Jun 5, 2026

Copy link
Copy Markdown
Member

db/cmp prefixes context lines in its diff output with two spaces. When support for -scripttest.update was added to db/cmp in commit e2a88e6931c ("script: support -scripttest.update in db/cmp"), it accidentally reused that diff-prefixed header for the replacement content when writing the new golden file. This was causing updated table files to gain two leading spaces before the first header column.

Fix this by keeping the diff prefix only in the diff output and write the replacement header without indentation.

Fixes: 1e2a88e ("script: support -scripttest.update in db/cmp")
Reported-by: @joamaki

db/cmp prefixes context lines in its diff output with two spaces. When
support for -scripttest.update was added to db/cmp in commit e2a88e6931c
("script: support -scripttest.update in db/cmp"), it accidentally reused
that diff-prefixed header for the replacement content when writing the
new golden file. This was causing updated table files to gain two
leading spaces before the first header column.

Fix this by keeping the diff prefix only in the diff output and write
the replacement header without indentation.

Fixes: 1e2a88e ("script: support -scripttest.update in db/cmp")
Reported-by: Jussi Maki <jussi.maki@isovalent.com>
Signed-off-by: Tobias Klauser <tobias@cilium.io>
@tklauser tklauser requested a review from a team as a code owner June 5, 2026 12:43
@tklauser tklauser requested review from derailed and removed request for a team June 5, 2026 12:43
@tklauser tklauser changed the title script: fix db/cmp update header indentation script: fix db/cmp update header indentation Jun 5, 2026
@tklauser tklauser requested review from joamaki and removed request for derailed June 5, 2026 12:45
@github-actions

github-actions Bot commented Jun 5, 2026

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 github.com/spf13/viper v1.18.2
go: downloading go.uber.org/dig v1.17.1
go: downloading golang.org/x/term v0.16.0
go: downloading golang.org/x/sys v0.17.0
go: downloading golang.org/x/tools v0.17.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 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/spf13/cast v1.6.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	416.429s	coverage: 78.5% of statements
ok  	github.com/cilium/statedb/index	0.006s	coverage: 33.7% of statements
ok  	github.com/cilium/statedb/internal	0.025s	coverage: 42.9% of statements
ok  	github.com/cilium/statedb/lpm	4.526s	coverage: 77.6% of statements
ok  	github.com/cilium/statedb/part	64.649s	coverage: 87.7% of statements
ok  	github.com/cilium/statedb/reconciler	0.270s	coverage: 92.5% 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.163s
ok  	github.com/cilium/statedb/index	1.013s
ok  	github.com/cilium/statedb/internal	1.035s
ok  	github.com/cilium/statedb/lpm	2.946s
ok  	github.com/cilium/statedb/part	35.950s
ok  	github.com/cilium/statedb/reconciler	1.340s
?   	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                      	  706788	      1703 ns/op	    587338 objects/sec	    1000 B/op	      16 allocs/op
BenchmarkDB_WriteTxn_10-4                     	 1530458	       723.7 ns/op	   1381832 objects/sec	     520 B/op	       8 allocs/op
BenchmarkDB_WriteTxn_100-4                    	 1913548	       625.0 ns/op	   1599949 objects/sec	     536 B/op	       7 allocs/op
BenchmarkDB_WriteTxn_1000-4                   	 1681213	       717.5 ns/op	   1393807 objects/sec	     522 B/op	       7 allocs/op
BenchmarkDB_WriteTxn_100_SecondaryIndex-4     	  766369	      1400 ns/op	    714329 objects/sec	    1100 B/op	      20 allocs/op
BenchmarkDB_WriteTxn_CommitOnly_100Tables-4   	  983126	      1218 ns/op	    1112 B/op	       5 allocs/op
BenchmarkDB_WriteTxn_CommitOnly_1Table-4      	 1582344	       757.2 ns/op	     224 B/op	       5 allocs/op
BenchmarkDB_NewWriteTxn-4                     	 1731496	       692.1 ns/op	     200 B/op	       4 allocs/op
BenchmarkDB_WriteTxnCommit100-4               	  902029	      1208 ns/op	    1096 B/op	       5 allocs/op
BenchmarkDB_NewReadTxn-4                      	641466961	         1.869 ns/op	       0 B/op	       0 allocs/op
BenchmarkDB_Modify-4                          	    1504	    788618 ns/op	   1268042 objects/sec	  546082 B/op	    8094 allocs/op
BenchmarkDB_GetInsert-4                       	    1426	    840470 ns/op	   1189811 objects/sec	  530072 B/op	    8094 allocs/op
BenchmarkDB_RandomInsert-4                    	    1660	    731086 ns/op	   1367827 objects/sec	  522022 B/op	    7094 allocs/op
BenchmarkDB_RandomReplace-4                   	     428	   2764121 ns/op	    361779 objects/sec	 2073403 B/op	   29146 allocs/op
BenchmarkDB_SequentialInsert-4                	    1657	    718536 ns/op	   1391718 objects/sec	  522020 B/op	    7094 allocs/op
BenchmarkDB_SequentialInsert_Prefix-4         	     432	   2610978 ns/op	    382998 objects/sec	 3563580 B/op	   45542 allocs/op
BenchmarkDB_Changes_Baseline-4                	    1417	    841026 ns/op	   1189024 objects/sec	  582204 B/op	    9185 allocs/op
BenchmarkDB_Changes-4                         	     859	   1387716 ns/op	    720609 objects/sec	  783852 B/op	   12336 allocs/op
BenchmarkDB_RandomLookup-4                    	   22267	     53876 ns/op	  18561081 objects/sec	       0 B/op	       0 allocs/op
BenchmarkDB_SequentialLookup-4                	   26866	     44617 ns/op	  22412767 objects/sec	       0 B/op	       0 allocs/op
BenchmarkDB_Prefix_SecondaryIndex-4           	    7107	    163996 ns/op	   6097716 objects/sec	  124920 B/op	    1025 allocs/op
BenchmarkDB_FullIteration_All-4               	    1096	   1075604 ns/op	  92970986 objects/sec	     104 B/op	       4 allocs/op
BenchmarkDB_FullIteration_Prefix-4            	    1033	   1142833 ns/op	  87501857 objects/sec	     136 B/op	       5 allocs/op
BenchmarkDB_FullIteration_Get-4               	     219	   5409421 ns/op	  18486268 objects/sec	       0 B/op	       0 allocs/op
BenchmarkDB_FullIteration_Get_Secondary-4     	     100	  10047367 ns/op	   9952856 objects/sec	       0 B/op	       0 allocs/op
BenchmarkDB_FullIteration_ReadTxnGet-4        	     222	   5389321 ns/op	  18555214 objects/sec	       0 B/op	       0 allocs/op
BenchmarkDB_PropagationDelay-4                	  657187	      1717 ns/op	        15.00 50th_µs	        17.00 90th_µs	        71.00 99th_µs	    1120 B/op	      19 allocs/op
BenchmarkDB_WriteTxn_100_LPMIndex-4           	  501278	      2368 ns/op	    422339 objects/sec	    1825 B/op	      37 allocs/op
BenchmarkDB_WriteTxn_1_LPMIndex-4             	  140269	     14065 ns/op	     71101 objects/sec	   15869 B/op	      82 allocs/op
BenchmarkDB_LPMIndex_Get-4                    	     399	   2954523 ns/op	   3384642 objects/sec	       0 B/op	       0 allocs/op
BenchmarkWatchSet_4-4                         	 2291064	       514.7 ns/op	     296 B/op	       4 allocs/op
BenchmarkWatchSet_16-4                        	  771098	      1553 ns/op	    1096 B/op	       5 allocs/op
BenchmarkWatchSet_128-4                       	   88844	     13384 ns/op	    8904 B/op	       5 allocs/op
BenchmarkWatchSet_1024-4                      	    8948	    133466 ns/op	   73743 B/op	       5 allocs/op
PASS
ok  	github.com/cilium/statedb	43.790s
PASS
ok  	github.com/cilium/statedb/index	0.003s
goos: linux
goarch: amd64
pkg: github.com/cilium/statedb/internal
cpu: AMD EPYC 7763 64-Core Processor                
Benchmark_SortableMutex-4   	 6136125	       195.3 ns/op	       0 B/op	       0 allocs/op
PASS
ok  	github.com/cilium/statedb/internal	1.203s
goos: linux
goarch: amd64
pkg: github.com/cilium/statedb/lpm
cpu: AMD EPYC 7763 64-Core Processor                
Benchmark_txn_insert/batchSize=1-4         	    1872	    644031 ns/op	   1552721 objects/sec	  838413 B/op	   13975 allocs/op
Benchmark_txn_insert/batchSize=10-4        	    3064	    394857 ns/op	   2532565 objects/sec	  385195 B/op	    6668 allocs/op
Benchmark_txn_insert/batchSize=100-4       	    3286	    371817 ns/op	   2689492 objects/sec	  345613 B/op	    6027 allocs/op
Benchmark_txn_delete/batchSize=1-4         	    1556	    771505 ns/op	   1296168 objects/sec	 1286471 B/op	   13976 allocs/op
Benchmark_txn_delete/batchSize=10-4        	    3127	    383782 ns/op	   2605648 objects/sec	  372417 B/op	    5769 allocs/op
Benchmark_txn_delete/batchSize=100-4       	    3490	    359470 ns/op	   2781873 objects/sec	  286753 B/op	    5038 allocs/op
Benchmark_LPM_Lookup-4                     	    7804	    151973 ns/op	   6580101 objects/sec	       0 B/op	       0 allocs/op
Benchmark_LPM_All-4                        	  135339	      8982 ns/op	 111329333 objects/sec	      32 B/op	       1 allocs/op
Benchmark_LPM_Prefix-4                     	  132480	      9196 ns/op	 108744709 objects/sec	      32 B/op	       1 allocs/op
Benchmark_LPM_LowerBound-4                 	  242998	      4891 ns/op	 102236340 objects/sec	     288 B/op	       2 allocs/op
PASS
ok  	github.com/cilium/statedb/lpm	12.113s
goos: linux
goarch: amd64
pkg: github.com/cilium/statedb/part
cpu: AMD EPYC 7763 64-Core Processor                
Benchmark_Uint64Map_Random-4                  	    1633	    738762 ns/op	   1353616 items/sec	 2526324 B/op	    6033 allocs/op
Benchmark_Uint64Map_Sequential-4              	    1908	    632776 ns/op	   1580339 items/sec	 2216724 B/op	    5754 allocs/op
Benchmark_Uint64Map_Sequential_Insert-4       	    2110	    570727 ns/op	   1752151 items/sec	 2208722 B/op	    4753 allocs/op
Benchmark_Uint64Map_Sequential_Txn_Insert-4   	   10000	    102754 ns/op	   9731980 items/sec	   86352 B/op	    2028 allocs/op
Benchmark_Uint64Map_Random_Insert-4           	    1539	    744834 ns/op	   1342580 items/sec	 2519026 B/op	    5031 allocs/op
Benchmark_Uint64Map_Random_Txn_Insert-4       	    7210	    164202 ns/op	   6090073 items/sec	  119832 B/op	    2422 allocs/op
Benchmark_Insert_RootOnlyWatch-4              	   10000	    110012 ns/op	   9089900 objects/sec	   71504 B/op	    2033 allocs/op
Benchmark_Insert-4                            	    7896	    155308 ns/op	   6438831 objects/sec	  186937 B/op	    3060 allocs/op
Benchmark_Modify-4                            	   12346	     97099 ns/op	  10298775 objects/sec	   58224 B/op	    1007 allocs/op
Benchmark_GetInsert-4                         	    9344	    127255 ns/op	   7858248 objects/sec	   58224 B/op	    1007 allocs/op
Benchmark_Replace-4                           	31987419	        37.04 ns/op	  26996197 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Replace_RootOnlyWatch-4             	31841428	        37.59 ns/op	  26603413 objects/sec	       0 B/op	       0 allocs/op
Benchmark_txn_1-4                             	 6214820	       191.3 ns/op	   5227448 objects/sec	     168 B/op	       3 allocs/op
Benchmark_txn_10-4                            	10061350	       118.3 ns/op	   8455879 objects/sec	      86 B/op	       2 allocs/op
Benchmark_txn_100-4                           	11777522	       100.6 ns/op	   9938339 objects/sec	      80 B/op	       2 allocs/op
Benchmark_txn_1000-4                          	10297518	       116.0 ns/op	   8620606 objects/sec	      65 B/op	       2 allocs/op
Benchmark_txn_delete_1-4                      	 4878836	       245.5 ns/op	   4073474 objects/sec	     664 B/op	       4 allocs/op
Benchmark_txn_delete_10-4                     	11229292	       105.8 ns/op	   9453082 objects/sec	     106 B/op	       1 allocs/op
Benchmark_txn_delete_100-4                    	12626132	        95.34 ns/op	  10489318 objects/sec	      47 B/op	       1 allocs/op
Benchmark_txn_delete_1000-4                   	14966305	        79.34 ns/op	  12604673 objects/sec	      24 B/op	       1 allocs/op
Benchmark_Get-4                               	   44575	     26827 ns/op	  37275339 objects/sec	       0 B/op	       0 allocs/op
Benchmark_All-4                               	  123110	     10563 ns/op	  94673255 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Iterator_All-4                      	  129666	     10044 ns/op	  99557050 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Iterator_Next-4                     	  160058	      7444 ns/op	 134345193 objects/sec	     896 B/op	       1 allocs/op
Benchmark_Hashmap_Insert-4                    	   14802	     80894 ns/op	  12361891 objects/sec	   74264 B/op	      20 allocs/op
Benchmark_Hashmap_Get_Uint64-4                	  137670	      8720 ns/op	 114682207 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Hashmap_Get_Bytes-4                 	  109365	     10966 ns/op	  91192791 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Delete_Random-4                     	      87	  13957453 ns/op	   7164631 objects/sec	 2111869 B/op	  102363 allocs/op
Benchmark_find16-4                            	201254131	         5.947 ns/op	       0 B/op	       0 allocs/op
Benchmark_findIndex16-4                       	100000000	        12.39 ns/op	       0 B/op	       0 allocs/op
Benchmark_find48-4                            	383876658	         3.123 ns/op	       0 B/op	       0 allocs/op
Benchmark_findIndex48_hit-4                   	427013680	         2.809 ns/op	       0 B/op	       0 allocs/op
Benchmark_findIndex48_miss-4                  	384526515	         3.120 ns/op	       0 B/op	       0 allocs/op
Benchmark_find4-4                             	424454511	         2.827 ns/op	       0 B/op	       0 allocs/op
Benchmark_findIndex4-4                        	321084320	         3.740 ns/op	       0 B/op	       0 allocs/op
PASS
ok  	github.com/cilium/statedb/part	43.183s
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 1.99 seconds (batch size 1000)
Throughput 502763.79 objects per second
888MB total allocated, 6015191 in-use objects, 338MB bytes in use

@joamaki joamaki merged commit 98455aa into main Jun 9, 2026
1 check passed
@joamaki joamaki deleted the pr/tklauser/update-no-header-indent branch June 9, 2026 06:52
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