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

Added rnd read capabilities to bbolt bench #711

Merged
merged 1 commit into from
Apr 11, 2024

Conversation

ambaxter
Copy link
Contributor

I was doing some testing and noticed that the benchmark functionality didn't have random access capabilities. This PR adds those options.

% ./bbolt bench -read-mode rnd                              
starting write benchmark.
Starting write iteration 0
Finished write iteration 0
starting read benchmark.
Completed 2195132 requests, 2195117/s 
# Write 1000(ops)       66.425456ms     (66.425µs/op)   (15054 op/sec)
# Read  2196000(ops)    1.000481397s    (455ns/op)      (2197802 op/sec)
./bbolt bench -read-mode rnd -write-mode rnd-nest         
starting write benchmark.
Starting write iteration 0
Finished write iteration 0
starting read benchmark.
Completed 1470719 requests, 1470489/s 
# Write 1000(ops)       67.886901ms     (67.886µs/op)   (14730 op/sec)
# Read  1471000(ops)    1.000507272s    (680ns/op)      (1470588 op/sec)

@ivanvc
Copy link
Member

ivanvc commented Apr 3, 2024

Hi, @ambaxter. Thanks for the pull request. Please ensure your commit is signed so the developer certificate of origin (DCO) check passes, i.e:

git rebase HEAD~1 --signoff
git push --force

@ahrtr, there will be conflicts with the migration to cobra-style of the bench command (#680). I removed read-mode as seq wasn't available when I rewrote the command. Do we want to wait until after 1.4 to add this PR? Then, it would be better to integrate it in #680. Otherwise, I can update my PR to add this functionality.

@ambaxter
Copy link
Contributor Author

ambaxter commented Apr 3, 2024

Hi, @ambaxter. Thanks for the pull request. Please ensure your commit is signed so the developer certificate of origin (DCO) check passes, i.e:

git rebase HEAD~1 --signoff
git push --force

Done

@ahrtr
Copy link
Member

ahrtr commented Apr 3, 2024

This looks like a useful enhancement. Since it doesn't break existing user experience, so it's accepted to add it in 1.4.0.

For rnd read, we should exclude the time of collecting & shuffle all the keys.

Obviously you did not sign the commit correctly. Please read https://github.com/etcd-io/bbolt/pull/711/checks?check_run_id=23409172937

@ivanvc
Copy link
Member

ivanvc commented Apr 3, 2024

This looks like a useful enhancement. Since it doesn't break existing user experience, so it's accepted to add it in 1.4.0.

Ok, I'll update my PR after this one gets merged.

@ambaxter ambaxter force-pushed the bench_random branch 2 times, most recently from db54f1d to 1c80f06 Compare April 3, 2024 20:48
@ambaxter
Copy link
Contributor Author

ambaxter commented Apr 3, 2024

Obviously you did not sign the commit correctly. Please read https://github.com/etcd-io/bbolt/pull/711/checks?check_run_id=23409172937

My apologies. I did reset my local git config and force pushed it with the commit ending in 'Signed-off-by: Adam Baxter adam.m.baxter@gmail.com'. The DCO action is still failing with the old commit message, however.

@ivanvc
Copy link
Member

ivanvc commented Apr 3, 2024

@ambaxter You need to fix (and reset) your author configuration. It doesn't match the DCO.

Author: abaxter <Adam Baxter>
Date:   Tue Mar 26 13:00:01 2024 +0000

    Added rnd read capabilities to bbolt bench
    
    Signed-off-by: Adam Baxter <adam.m.baxter@gmail.com>

Emphasis on Author.

@ambaxter
Copy link
Contributor Author

ambaxter commented Apr 4, 2024

@ambaxter You need to fix (and reset) your author configuration. It doesn't match the DCO.

Done. I'm sorry! This is probably the first big project I've committed to.

cmd/bbolt/main.go Outdated Show resolved Hide resolved
cmd/bbolt/main.go Outdated Show resolved Hide resolved
cmd/bbolt/main.go Show resolved Hide resolved
@ahrtr
Copy link
Member

ahrtr commented Apr 6, 2024

cc @fuweid @ivanvc @tjungblu PTAL, thx

cmd/bbolt/main.go Outdated Show resolved Hide resolved
@ahrtr
Copy link
Member

ahrtr commented Apr 8, 2024

Can you compare the benchmark result of rnd and seq reads?

Probably the collectKeys may have impact on the benchmark result of random read, because the OS may cache some data, accordingly the following random read actually just reads the data from cache instead of disk. One possible solution is to cache all the keys (and buckets for nested case) when writing instead of right before reading.

@ambaxter
Copy link
Contributor Author

ambaxter commented Apr 8, 2024

Can you compare the benchmark result of rnd and seq reads?

Probably the collectKeys may have impact on the benchmark result of random read, because the OS may cache some data, accordingly the following random read actually just reads the data from cache instead of disk. One possible solution is to cache all the keys (and buckets for nested case) when writing instead of right before reading.

I tested 100,000 and 1,000,000 with varying batch sizes. You're correct. Collecting the keys just before reading in general has a performance benefit.

100k_read_ops

1m_read_ops

@ambaxter
Copy link
Contributor Author

ambaxter commented Apr 8, 2024

The Robustness tests are currently failing with OOM.

@ambaxter
Copy link
Contributor Author

ambaxter commented Apr 8, 2024

Should be fixed now.

@ivanvc
Copy link
Member

ivanvc commented Apr 9, 2024

/ok-to-test

@ivanvc
Copy link
Member

ivanvc commented Apr 9, 2024

@ambaxter, can you please squash your commits? Thanks.

@ambaxter
Copy link
Contributor Author

ambaxter commented Apr 9, 2024

@ambaxter, can you please squash your commits? Thanks.

Done

@ivanvc
Copy link
Member

ivanvc commented Apr 9, 2024

@ahrtr PTAL

cmd/bbolt/main.go Outdated Show resolved Hide resolved
cmd/bbolt/main.go Outdated Show resolved Hide resolved
cmd/bbolt/main.go Outdated Show resolved Hide resolved
Signed-off-by: Adam Baxter <adam.m.baxter@gmail.com>
@ambaxter
Copy link
Contributor Author

I'm not sure why the ARM64 test failed

Copy link
Member

@ahrtr ahrtr left a comment

Choose a reason for hiding this comment

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

lgtm

Thanks.

@ahrtr
Copy link
Member

ahrtr commented Apr 10, 2024

Please also consider adding a test to cover the new rnd read, to avoid error something like #711 (comment). You can do it in a followup PR or as the second commit in this PR.

@ambaxter
Copy link
Contributor Author

Please also consider adding a test to cover the new rnd read, to avoid error something like #711 (comment). You can do it in a followup PR or as the second commit in this PR.

@ahrtr Sure. Like https://github.com/etcd-io/bbolt/blob/main/cmd/bbolt/main_test.go#L483 ?

@ahrtr
Copy link
Member

ahrtr commented Apr 11, 2024

@ahrtr Sure. Like https://github.com/etcd-io/bbolt/blob/main/cmd/bbolt/main_test.go#L483 ?

Yes, you can add a couple of more items into the list.

}{
"no-args": {},
"100k count": {[]string{"-count", "100000"}},
}

@ahrtr
Copy link
Member

ahrtr commented Apr 11, 2024

@fuweid do you have bandwidth to take a look at this PR, so that we can merge it? thx

Copy link
Member

@fuweid fuweid left a comment

Choose a reason for hiding this comment

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

LGTM

@ahrtr ahrtr merged commit ee11a09 into etcd-io:main Apr 11, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

5 participants