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

Benchmarks for ordered ints #3

Closed
wants to merge 5 commits into from
Closed

Benchmarks for ordered ints #3

wants to merge 5 commits into from

Conversation

recoilme
Copy link

@recoilme recoilme commented Jun 3, 2022

Hello

When i pass keys without zero terminated byte, i get this results

go test -bench=Ints
goos: darwin
goarch: amd64
pkg: github.com/arriqaaq/art
cpu: Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
BenchmarkIntsArtTreeInsert-8    15019468                92.99 ns/op           25 B/op          1 allocs/op
BenchmarkIntsArtTreeSearch-8    17869408                68.18 ns/op           15 B/op          0 allocs/op
PASS

But if i add zero byte i get much better results

BenchmarkIntsArtTreeInsert-8    20680020                60.41 ns/op           10 B/op          0 allocs/op
BenchmarkIntsArtTreeSearch-8    30512358                33.79 ns/op            0 B/op          0 allocs/op

May you please to explain your motivation for using zero terminated strings in this library? It's for simplifing redis protocol parsing in flashdb or for comatiblity with С?

I add benchmarks in PR, please take a look. More benchmarks here: https://github.com/recoilme/bench_sortedsets

@recoilme recoilme mentioned this pull request Jun 6, 2022
@arriqaaq
Copy link
Owner

arriqaaq commented Jun 8, 2022

Thank you for your PR @recoilme, please give me sometime to respond back. I appreciate your time in going through the code.

@recoilme recoilme mentioned this pull request Jun 11, 2022
Closed
@recoilme
Copy link
Author

Speed up after removing terminate:

(base) v-kulibaba:art v.kulibaba$ go test -bench=Ints
goos: darwin
goarch: amd64
pkg: github.com/arriqaaq/art
cpu: Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
BenchmarkIntsArtTreeInsert-8    26208822                46.43 ns/op            8 B/op          0 allocs/op
BenchmarkIntsArtTreeSearch-8    45115551                32.56 ns/op            0 B/op          0 allocs/op
PASS

@arriqaaq
Copy link
Owner

arriqaaq commented Jun 17, 2022

This looks good, I'll have a look over the weekend, can we check the memory footprint?

@recoilme
Copy link
Author

recoilme commented Jul 2, 2022

Your current terminate implementation doesn't check last byte on 0, but any and insert at end, its buggy

func terminate(key []byte) []byte {
	index := bytes.Index(key, []byte{0})
	if index < 0 {
		key = append(key, byte(0))
	}
	return key
}

This PR fix it, too.

FYI: I decide rewrite ART from scratch, with optimized memory usage. I will publish it soon

This pull request was closed.
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