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 find_entry #180

Merged
merged 10 commits into from
Feb 6, 2023
Merged

Benchmarks for find_entry #180

merged 10 commits into from
Feb 6, 2023

Conversation

arkpar
Copy link
Member

@arkpar arkpar commented Feb 6, 2023

$ cargo +nightly bench --features bench bench
    Finished bench [optimized + debuginfo] target(s) in 0.06s
     Running unittests src/lib.rs (target/release/deps/parity_db-21d11d42e7884130)

running 2 tests
test index::test::bench_find_entry     ... bench:          29 ns/iter (+/- 0)
test index::test::bench_find_entry_sse ... bench:          13 ns/iter (+/- 0)

Also added a small optimization for chunk_at

src/index.rs Outdated
key_prefix: u64,
sub_index: usize,
chunk: &[u8; CHUNK_LEN],
) -> (Entry, usize) {
assert!(chunk.len() >= CHUNK_ENTRIES * 8);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the assert still needed ?

src/index.rs Outdated
let i = index % 64;
let x = f(&table, keys[i], 0, &chunk).1;
assert_eq!(x, i);
index += 1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would make sense to me to have the 64 query under iter (so nb iter don't interfer (actually with this use case it probably does not really matter)).

Copy link
Member Author

Choose a reason for hiding this comment

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

Under real workload chunks are never full. I'd guess average occupancy is about 33%. With just a few entries base variant will probably be faster, while with 64 entries simd will probably be faster. This cycle averages it.

src/index.rs Outdated
IndexTable { id: TableId(18), map: RwLock::new(None), path: Default::default() };
let mut chunk = [0u8; 512];
let mut keys = [0u64; 64];
let mut rng = rand::thread_rng();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not too sure if we should bench on random content (could be just random from a fix seed).

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, even though It does not matter too much what the entry bits are, as long as they are different.

Copy link
Contributor

@Tpt Tpt left a comment

Choose a reason for hiding this comment

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

+1 to @cheme suggestions

@arkpar arkpar merged commit f58f212 into master Feb 6, 2023
@arkpar arkpar deleted the a-find-entry-bench branch February 6, 2023 20:53
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