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

Implement GetAppend #68

Merged
merged 1 commit into from
Aug 3, 2024
Merged

Conversation

mcrakhman
Copy link
Contributor

@mcrakhman mcrakhman commented Aug 2, 2024

Hi Artem,

I wanted to add GetAppend to the library, so we can enhance performance of our sync layer, because it required a lot of reading from DB for large documents. GetAppend appends the value data to the buffer.

In my implementation I decided to copy the code of the function, because If I would reuse the same code with some modifications this would make the original Get function slower which is bad for performance critical library like yours (the reason is that append works slower than copy).

These are the benchmarks on latest MacOs on M3 MacBook Air and my friend's linux laptop for GetAppend:

goos: linux
goarch: amd64
pkg: github.com/akrylysov/pogreb
cpu: AMD Ryzen 7 PRO 5850U with Radeon Graphics     
BenchmarkGet-16          	 2248670	       545.0 ns/op	    1024 B/op	       1 allocs/op
BenchmarkGetAppend-16    	 4433508	       272.4 ns/op	       0 B/op	       0 allocs/op
PASS
BenchmarkGet-16          	 2240300	       548.3 ns/op	    1024 B/op	       1 allocs/op
BenchmarkGetAppend-16    	 4162995	       291.6 ns/op	       0 B/op	       0 allocs/op
PASS
BenchmarkGet-16          	  293073	      3791 ns/op	    2688 B/op	       3 allocs/op
BenchmarkGetAppend-16    	  323263	      3447 ns/op	    1664 B/op	       2 allocs/op
PASS
ok  	github.com/akrylysov/pogreb	11.354s

goos: darwin
goarch: arm64
pkg: github.com/akrylysov/pogreb
BenchmarkGet-8           7294815               169.3 ns/op          1024 B/op          1 allocs/op
BenchmarkGetAppend-8    11547056               104.4 ns/op             0 B/op          0 allocs/op
PASS
BenchmarkGet-8           6131505               273.5 ns/op          1024 B/op          1 allocs/op
BenchmarkGetAppend-8    11637585               118.7 ns/op             0 B/op          0 allocs/op
PASS
BenchmarkGet-8           1000000              1131 ns/op            2688 B/op          3 allocs/op
BenchmarkGetAppend-8     1000000              1011 ns/op            1664 B/op          2 allocs/op
PASS
ok      github.com/akrylysov/pogreb     14.534s

@akrylysov akrylysov merged commit 076d5fe into akrylysov:main Aug 3, 2024
1 of 7 checks passed
@akrylysov
Copy link
Owner

Great addition, thank you!

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