Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JSON formatting in db show command #62

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

joamaki
Copy link
Contributor

@joamaki joamaki commented Oct 29, 2024

The "db show -format=json" was missing newline at the end. While at it, switch to MarshalIndent for nicer output and extend the tests.

Hive dependency is bumped to add the -scripttest.update support.

@joamaki joamaki requested a review from a team as a code owner October 29, 2024 14:14
@joamaki joamaki requested review from bimmlerd and removed request for a team October 29, 2024 14:14
Copy link

github-actions bot commented Oct 29, 2024

$ make test
go: downloading golang.org/x/sys v0.17.0
go: downloading golang.org/x/tools v0.17.0
go: downloading golang.org/x/exp v0.0.0-20240119083558-1b970713d09a
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 golang.org/x/text v0.14.0
	github.com/cilium/statedb/reconciler/benchmark		coverage: 0.0% of statements
	github.com/cilium/statedb/reconciler/example		coverage: 0.0% of statements
ok  	github.com/cilium/statedb	31.407s	coverage: 82.6% of statements
ok  	github.com/cilium/statedb/index	0.005s	coverage: 28.7% of statements
ok  	github.com/cilium/statedb/internal	0.014s	coverage: 46.7% of statements
ok  	github.com/cilium/statedb/part	2.734s	coverage: 82.9% of statements
ok  	github.com/cilium/statedb/reconciler	0.287s	coverage: 89.6% of statements
-----
$ make bench
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                    	  437586	      2674 ns/op	    374006 objects/sec	    2816 B/op	      32 allocs/op
BenchmarkDB_WriteTxn_10-4                   	 1207032	       992.2 ns/op	   1007832 objects/sec	     743 B/op	      10 allocs/op
BenchmarkDB_WriteTxn_100-4                  	 1519858	       809.5 ns/op	   1235342 objects/sec	     598 B/op	       7 allocs/op
BenchmarkDB_WriteTxn_1000-4                 	 1480930	       818.9 ns/op	   1221128 objects/sec	     548 B/op	       7 allocs/op
BenchmarkDB_WriteTxn_100_SecondaryIndex-4   	  484756	      2336 ns/op	    428055 objects/sec	    1507 B/op	      37 allocs/op
BenchmarkDB_Modify-4                        	    1316	   1011451 ns/op	    988680 objects/sec	  771003 B/op	    8458 allocs/op
BenchmarkDB_GetInsert-4                     	    1162	   1037933 ns/op	    963455 objects/sec	  761623 B/op	    8465 allocs/op
BenchmarkDB_RandomInsert-4                  	    2342	    507642 ns/op	   1969893 objects/sec	  402185 B/op	    7097 allocs/op
BenchmarkDB_RandomReplace-4                 	     306	   3911967 ns/op	    255626 objects/sec	 2359432 B/op	   48573 allocs/op
BenchmarkDB_SequentialInsert-4              	    1464	    817270 ns/op	   1223586 objects/sec	  550487 B/op	    7285 allocs/op
BenchmarkDB_Changes_Baseline-4              	    1240	    962049 ns/op	   1039450 objects/sec	  553138 B/op	   10252 allocs/op
BenchmarkDB_Changes-4                       	     679	   1748236 ns/op	    572005 objects/sec	  993328 B/op	   14494 allocs/op
BenchmarkDB_RandomLookup-4                  	   21955	     53299 ns/op	  18762043 objects/sec	     160 B/op	       1 allocs/op
BenchmarkDB_SequentialLookup-4              	   27374	     43520 ns/op	  22977940 objects/sec	       0 B/op	       0 allocs/op
BenchmarkDB_Prefix_SecondaryIndex-4         	    7522	    150172 ns/op	   6659056 objects/sec	   93893 B/op	    1044 allocs/op
BenchmarkDB_FullIteration_All-4             	     692	   1805080 ns/op	  55399315 objects/sec	     480 B/op	      12 allocs/op
BenchmarkDB_FullIteration_Get-4             	     213	   5644769 ns/op	  17715549 objects/sec	       0 B/op	       0 allocs/op
BenchmarkDB_PropagationDelay-4              	  486787	      2359 ns/op	        20.00 50th_µs	        24.00 90th_µs	       100.0 99th_µs	    1591 B/op	      24 allocs/op
PASS
ok  	github.com/cilium/statedb	28.012s
PASS
ok  	github.com/cilium/statedb/index	0.004s
PASS
ok  	github.com/cilium/statedb/internal	0.004s
goos: linux
goarch: amd64
pkg: github.com/cilium/statedb/part
cpu: AMD EPYC 7763 64-Core Processor                
Benchmark_Insert_RootOnlyWatch-4    	    7792	    135159 ns/op	   7398673 objects/sec	  104163 B/op	    2041 allocs/op
Benchmark_Insert-4                  	    5940	    190139 ns/op	   5259305 objects/sec	  219061 B/op	    3064 allocs/op
Benchmark_Modify-4                  	    8263	    144587 ns/op	   6916273 objects/sec	  212696 B/op	    1205 allocs/op
Benchmark_GetInsert-4               	    6729	    180053 ns/op	   5553933 objects/sec	  212757 B/op	    1204 allocs/op
Benchmark_Replace-4                 	27048020	        45.10 ns/op	  22174582 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Replace_RootOnlyWatch-4   	27275462	        44.74 ns/op	  22351984 objects/sec	       0 B/op	       0 allocs/op
Benchmark_txn_1-4                   	 2993409	       400.1 ns/op	   2499484 objects/sec	     448 B/op	       7 allocs/op
Benchmark_txn_10-4                  	 7376277	       159.8 ns/op	   6258338 objects/sec	     154 B/op	       2 allocs/op
Benchmark_txn_100-4                 	 8292368	       145.5 ns/op	   6873063 objects/sec	     224 B/op	       2 allocs/op
Benchmark_txn_1000-4                	 7189796	       167.3 ns/op	   5977265 objects/sec	     216 B/op	       2 allocs/op
Benchmark_txn_delete_1-4            	 3141169	       378.1 ns/op	   2645100 objects/sec	     856 B/op	       6 allocs/op
Benchmark_txn_delete_10-4           	 8251650	       143.9 ns/op	   6950046 objects/sec	     132 B/op	       1 allocs/op
Benchmark_txn_delete_100-4          	10115833	       116.8 ns/op	   8564990 objects/sec	      60 B/op	       1 allocs/op
Benchmark_txn_delete_1000-4         	10878652	       109.7 ns/op	   9114306 objects/sec	      26 B/op	       1 allocs/op
Benchmark_Get-4                     	   38312	     31668 ns/op	  31577559 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Iterate-4                 	  174175	      7063 ns/op	 141583882 objects/sec	      80 B/op	       3 allocs/op
Benchmark_Hashmap_Insert-4          	   15520	     77995 ns/op	  12821314 objects/sec	   86556 B/op	      64 allocs/op
Benchmark_Hashmap_Get_Uint64-4      	  153164	      7731 ns/op	 129343018 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Hashmap_Get_Bytes-4       	  147312	      8114 ns/op	 123250467 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Uint64Map_Random-4        	    1332	    871819 ns/op	   1147029 items/sec	 2700320 B/op	    9025 allocs/op
Benchmark_Uint64Map_Sequential-4    	    1474	    804338 ns/op	   1243259 items/sec	 2492407 B/op	    9749 allocs/op
PASS
ok  	github.com/cilium/statedb/part	28.319s
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 3.00 seconds (batch size 1000)
Throughput 333450.99 objects per second
Allocated 6011296 objects, 424758kB bytes, 513264kB bytes still in use

The "db show -format=json" was missing newline at the end. While
at it, switch to MarshalIndent for nicer output and extend the tests.

Hive dependency is bumped to add the -scripttest.update support.

Signed-off-by: Jussi Maki <[email protected]>
@joamaki joamaki force-pushed the pr/joamaki/fix-json-cmd-output branch from d11247a to 5e0f668 Compare October 29, 2024 14:26
Copy link
Member

@bimmlerd bimmlerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, love the tests

@joamaki joamaki merged commit e0d473d into main Oct 29, 2024
1 check passed
@joamaki joamaki deleted the pr/joamaki/fix-json-cmd-output branch October 29, 2024 15:38
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