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

Drop mutext at txnTime #145

Merged
merged 1 commit into from
Apr 26, 2024
Merged

Drop mutext at txnTime #145

merged 1 commit into from
Apr 26, 2024

Conversation

erickpintor
Copy link
Contributor

There's currently a mix of mutex and atomic semantics in the txnTime struct. With atomic references/values, there's really no need to mutex. The difference, although still pretty fast, shows up as you increase the number of processes competing for the lock:

Before:

$ go test -run '^$' -bench BenchmarkTxnTime -cpu 1,2,4,6,8,10,12,14,16,18,20,22,24
goos: linux
goarch: amd64
pkg: github.com/fauna/fauna-go
cpu: AMD Ryzen 9 5900X 12-Core Processor
BenchmarkTxnTime       	21698958	       47.81 ns/op
BenchmarkTxnTime-2     	38165878	       71.46 ns/op
BenchmarkTxnTime-4     	20483498	       65.51 ns/op
BenchmarkTxnTime-6     	18176168	       96.62 ns/op
BenchmarkTxnTime-8     	 9268669	       138.1 ns/op
BenchmarkTxnTime-10    	 7864254	       159.0 ns/op
BenchmarkTxnTime-12    	 6894296	       184.0 ns/op
BenchmarkTxnTime-14    	 5897619	       171.3 ns/op
BenchmarkTxnTime-16    	 5877307	       211.4 ns/op
BenchmarkTxnTime-18    	 6124909	       213.2 ns/op
BenchmarkTxnTime-20    	 5618040	       207.3 ns/op
BenchmarkTxnTime-22    	 6004261	       171.7 ns/op
BenchmarkTxnTime-24    	 6618184	       203.7 ns/op
PASS
ok  	github.com/fauna/fauna-go	20.667s

After:

$ go test -run '^$' -bench BenchmarkTxnTime -cpu 1,2,4,6,8,10,12,14,16,18,20,22,24
goos: linux
goarch: amd64
pkg: github.com/fauna/fauna-go
cpu: AMD Ryzen 9 5900X 12-Core Processor
BenchmarkTxnTime       	 25714206	        39.49 ns/op
BenchmarkTxnTime-2     	 44444223	        26.82 ns/op
BenchmarkTxnTime-4     	 66274556	        15.58 ns/op
BenchmarkTxnTime-6     	100000000	        10.18 ns/op
BenchmarkTxnTime-8     	151929516	        7.935 ns/op
BenchmarkTxnTime-10    	173305910	        6.856 ns/op
BenchmarkTxnTime-12    	182882767	        6.513 ns/op
BenchmarkTxnTime-14    	196377723	        6.121 ns/op
BenchmarkTxnTime-16    	210278419	        5.707 ns/op
BenchmarkTxnTime-18    	218770639	        5.491 ns/op
BenchmarkTxnTime-20    	225907432	        5.338 ns/op
BenchmarkTxnTime-22    	233047292	        5.227 ns/op
BenchmarkTxnTime-24    	236090180	        5.138 ns/op
PASS
ok  	github.com/fauna/fauna-go	21.388s

@erickpintor erickpintor changed the title Drop mutext at txntime Drop mutext at txnTime Apr 26, 2024
@erickpintor erickpintor merged commit 02f4fa3 into main Apr 26, 2024
4 checks passed
@erickpintor erickpintor deleted the drop-mutex branch April 26, 2024 13:37
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.

3 participants