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

Should clone benchmark use use test::blackbox? #690

Closed
wyfo opened this issue Apr 10, 2024 · 1 comment · Fixed by #691
Closed

Should clone benchmark use use test::blackbox? #690

wyfo opened this issue Apr 10, 2024 · 1 comment · Fixed by #691

Comments

@wyfo
Copy link
Contributor

wyfo commented Apr 10, 2024

I've recently run the bytes.rs benchmarks, and was quite surprised that clone_shared was identical to clone_arc_vec. That should not be the case with the indirection caused by the vtable.
Actually, the compiler seems to be smart enough to inline the vtable, hence this result (I haven't checked on godbolt because the library feature is broken).

However, if we replace &bytes.clone() by test::black_box(test::black_box(&bytes).clone()), a (small) difference appears, and I think it should be more representative of arbitrary code in which bytes can be used. Is it a good idea to update the benchmarks?

@Darksonn
Copy link
Contributor

That sounds like a reasonable suggestion.

wyfo added a commit to wyfo/bytes that referenced this issue Apr 10, 2024
Closes tokio-rs#690
Without it, it seemed to me that compiler was able to inline the vtable,
resulting in similar results for `clone_shared` and `clone_arg_vec`.
wyfo added a commit to wyfo/bytes that referenced this issue Apr 10, 2024
Closes tokio-rs#690
Without it, it seems to me that compiler is able to inline the vtable,
resulting in similar results for `clone_shared` and `clone_arg_vec`.
Darksonn pushed a commit that referenced this issue Apr 11, 2024
#691)

Closes #690
Without it, it seems to me that compiler is able to inline the vtable,
resulting in similar results for `clone_shared` and `clone_arg_vec`.
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 a pull request may close this issue.

2 participants