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

script: Add watch command #60

Merged
merged 1 commit into from
Oct 21, 2024
Merged

script: Add watch command #60

merged 1 commit into from
Oct 21, 2024

Conversation

joamaki
Copy link
Contributor

@joamaki joamaki commented Oct 10, 2024

The 'watch' command allows watching a table for changes, similar to the cilium-dbg statedb <table> --watch flag. The "strike out" support is ported from cilium-dbg/cmd/statedb.go.

The plan is to eventually replace the "cilium-dbg statedb" with the script commands.

❯ go run .
> hive start
...
time=2024-10-11T12:25:45.489+02:00 level=INFO msg=Started duration=177.609µs
> db watch ex
Name    X
one     1
two     2
count   0
count   1
count   2
...
^C (interrupted)
> 

Base automatically changed from pr/joamaki/hivescript to main October 10, 2024 14:24
Copy link

github-actions bot commented Oct 10, 2024

$ make test
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 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	26.324s	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.008s	coverage: 46.7% of statements
ok  	github.com/cilium/statedb/part	2.604s	coverage: 82.9% of statements
ok  	github.com/cilium/statedb/reconciler	0.311s	coverage: 88.4% 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                    	  447801	      2627 ns/op	    380630 objects/sec	    2816 B/op	      32 allocs/op
BenchmarkDB_WriteTxn_10-4                   	 1230457	       976.3 ns/op	   1024320 objects/sec	     743 B/op	      10 allocs/op
BenchmarkDB_WriteTxn_100-4                  	 1450978	       777.9 ns/op	   1285511 objects/sec	     601 B/op	       7 allocs/op
BenchmarkDB_WriteTxn_1000-4                 	 1491226	       817.0 ns/op	   1224038 objects/sec	     550 B/op	       7 allocs/op
BenchmarkDB_WriteTxn_100_SecondaryIndex-4   	  510188	      2293 ns/op	    436146 objects/sec	    1503 B/op	      37 allocs/op
BenchmarkDB_Modify-4                        	    1300	    932590 ns/op	   1072283 objects/sec	  774010 B/op	    8462 allocs/op
BenchmarkDB_GetInsert-4                     	    1226	    998232 ns/op	   1001772 objects/sec	  758448 B/op	    8463 allocs/op
BenchmarkDB_RandomInsert-4                  	    2331	    500470 ns/op	   1998120 objects/sec	  402258 B/op	    7098 allocs/op
BenchmarkDB_RandomReplace-4                 	     318	   3737888 ns/op	    267531 objects/sec	 2357934 B/op	   48572 allocs/op
BenchmarkDB_SequentialInsert-4              	    1536	    802777 ns/op	   1245676 objects/sec	  552883 B/op	    7290 allocs/op
BenchmarkDB_Changes_Baseline-4              	    1262	    943833 ns/op	   1059510 objects/sec	  553184 B/op	   10252 allocs/op
BenchmarkDB_Changes-4                       	     694	   1707025 ns/op	    585815 objects/sec	  993498 B/op	   14494 allocs/op
BenchmarkDB_RandomLookup-4                  	   21283	     53490 ns/op	  18695228 objects/sec	     160 B/op	       1 allocs/op
BenchmarkDB_SequentialLookup-4              	   27447	     43676 ns/op	  22895678 objects/sec	       0 B/op	       0 allocs/op
BenchmarkDB_Prefix_SecondaryIndex-4         	    7531	    149066 ns/op	   6708464 objects/sec	   93893 B/op	    1044 allocs/op
BenchmarkDB_FullIteration_All-4             	     990	   1229925 ns/op	  81305873 objects/sec	     480 B/op	      12 allocs/op
BenchmarkDB_FullIteration_Get-4             	     220	   5449010 ns/op	  18351988 objects/sec	       0 B/op	       0 allocs/op
BenchmarkDB_PropagationDelay-4              	  507802	      2374 ns/op	        20.00 50th_µs	        25.00 90th_µs	        83.00 99th_µs	    1589 B/op	      24 allocs/op
PASS
ok  	github.com/cilium/statedb	27.772s
PASS
ok  	github.com/cilium/statedb/index	0.003s
PASS
ok  	github.com/cilium/statedb/internal	0.003s
goos: linux
goarch: amd64
pkg: github.com/cilium/statedb/part
cpu: AMD EPYC 7763 64-Core Processor                
Benchmark_Insert_RootOnlyWatch-4    	    8944	    131955 ns/op	   7578330 objects/sec	  104165 B/op	    2041 allocs/op
Benchmark_Insert-4                  	    6165	    181243 ns/op	   5517458 objects/sec	  219061 B/op	    3065 allocs/op
Benchmark_Modify-4                  	    7767	    140561 ns/op	   7114366 objects/sec	  212180 B/op	    1205 allocs/op
Benchmark_GetInsert-4               	    6831	    171721 ns/op	   5823405 objects/sec	  212454 B/op	    1204 allocs/op
Benchmark_Replace-4                 	27010606	        44.72 ns/op	  22360342 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Replace_RootOnlyWatch-4   	27019929	        44.81 ns/op	  22314391 objects/sec	       0 B/op	       0 allocs/op
Benchmark_txn_1-4                   	 3028470	       392.3 ns/op	   2548826 objects/sec	     448 B/op	       7 allocs/op
Benchmark_txn_10-4                  	 7507927	       158.2 ns/op	   6319864 objects/sec	     154 B/op	       2 allocs/op
Benchmark_txn_100-4                 	 8356810	       142.4 ns/op	   7024032 objects/sec	     224 B/op	       2 allocs/op
Benchmark_txn_1000-4                	 7449506	       161.2 ns/op	   6203308 objects/sec	     216 B/op	       2 allocs/op
Benchmark_txn_delete_1-4            	 3211776	       377.7 ns/op	   2647383 objects/sec	     856 B/op	       6 allocs/op
Benchmark_txn_delete_10-4           	 8422850	       141.5 ns/op	   7069384 objects/sec	     132 B/op	       1 allocs/op
Benchmark_txn_delete_100-4          	10429628	       113.6 ns/op	   8799292 objects/sec	      60 B/op	       1 allocs/op
Benchmark_txn_delete_1000-4         	11106276	       107.2 ns/op	   9332549 objects/sec	      26 B/op	       1 allocs/op
Benchmark_Get-4                     	   38956	     31527 ns/op	  31719293 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Iterate-4                 	  173866	      6840 ns/op	 146192759 objects/sec	      80 B/op	       3 allocs/op
Benchmark_Hashmap_Insert-4          	   15936	     75155 ns/op	  13305931 objects/sec	   86554 B/op	      64 allocs/op
Benchmark_Hashmap_Get_Uint64-4      	  153817	      7820 ns/op	 127880383 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Hashmap_Get_Bytes-4       	  149142	      8128 ns/op	 123027015 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Uint64Map_Random-4        	    1380	    854271 ns/op	   1170589 items/sec	 2700217 B/op	    9017 allocs/op
Benchmark_Uint64Map_Sequential-4    	    1508	    801810 ns/op	   1247180 items/sec	 2492407 B/op	    9749 allocs/op
PASS
ok  	github.com/cilium/statedb/part	28.252s
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.94 seconds (batch size 1000)
Throughput 340550.97 objects per second
Allocated 6011300 objects, 424755kB bytes, 526240kB bytes still in use

script.go Show resolved Hide resolved
The 'watch' command allows watching a table for changes, similar to the
"cilium-dbg statedb <table> --watch" flag. The "strike out" support is
ported from cilium-dbg/cmd/statedb.go.

The plan is to eventually replace the "cilium-dbg statedb" with the
script commands.

Signed-off-by: Jussi Maki <[email protected]>
@joamaki joamaki marked this pull request as ready for review October 11, 2024 10:38
@joamaki joamaki requested a review from a team as a code owner October 11, 2024 10:38
Copy link
Member

@pippolo84 pippolo84 left a comment

Choose a reason for hiding this comment

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

💯

script.go Show resolved Hide resolved
@joamaki joamaki merged commit 6035290 into main Oct 21, 2024
1 check passed
@joamaki joamaki deleted the pr/joamaki/watch-cmd branch October 21, 2024 12:02
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