Uh oh!
There was an error while loading. Please reload this page.
Conversation
This naming makes more sense, esspecially if we add more benchmark files. Signed-off-by: Joe Richey <joerichey@google.com>
This PR came about because I discovered the amazing After installing the tool, we can run buffer::p384::bench_getrandom::inner:pushrbxsubrsp,64 ; Zero the bufferxorpsxmm0,xmm0movaps xmmword ptr [rsp+48],xmm0movaps xmmword ptr [rsp+32],xmm0movaps xmmword ptr [rsp+16],xmm0 ; Call the funtionlearbx,[rsp+16]movesi,48movrdi,rbxcall qword ptr [rip+ getrandom::imp::getrandom_inner@GOTPCREL] ; Check for errortesteax,eaxjne .LBB17_1 ; test::black_box(slice);mov qword ptr [rsp],rbxmov qword ptr [rsp+8],48movrax,rspaddrsp,64poprbxretWe can see the effect of using buffer::p384::bench_getrandom_uninit::inner:pushrbxsubrsp,64learbx,[rsp+16]movesi,48movrdi,rbxcall qword ptr [rip+ getrandom::imp::getrandom_inner@GOTPCREL]testeax,eaxjne .LBB18_1mov qword ptr [rsp],rbxmov qword ptr [rsp+8],48movrax,rspaddrsp,64poprbxretAs the benchmarks are compiled as separate crates, we can see the effect of inlining. Removing the buffer::p384::bench_getrandom_uninit::inner:pushrbxsubrsp,80learbx,[rsp+16]learsi,[rsp+32]movedx,48movrdi,rbxcall qword ptr [rip+ getrandom::getrandom_uninit@GOTPCREL]movrax, qword ptr [rsp+16]testrax,raxje .LBB18_1movrcx, qword ptr [rsp+24]mov qword ptr [rsp+16],raxmov qword ptr [rsp+24],rcxaddrsp,80poprbxretWe can also see that passing the entire array to buffer::p384::bench_getrandom_uninit::inner:subrsp,104leardi,[rsp+56]movesi,48call qword ptr [rip+ getrandom::imp::getrandom_inner@GOTPCREL]testeax,eaxjne .LBB18_1 ; 48 byte copymovupsxmm0, xmmword ptr [rsp+56]movupsxmm1, xmmword ptr [rsp+72]movupsxmm2, xmmword ptr [rsp+88]movaps xmmword ptr [rsp+32],xmm2movaps xmmword ptr [rsp+16],xmm1movaps xmmword ptr [rsp],xmm0movrax,rspaddrsp,104ret@briansmith this relates to #291 (comment) about how the type you pass to |
This change: - Move the benchmarks from mod.rs to buffer.rs - Move the inner loop we benchmark into an `#[inline(never)]` function - Includes instructions for getting the ASM for a specific benchmark This should hopefully reduce the variance of these benchmarks and make it easier to figure out if we are emitting the assembly or IR we expect for a particular implementation. Signed-off-by: Joe Richey <joerichey@google.com>
briansmith
commented
Oct 21, 2022
No major objections from me.
I think most users don't really want a |
* Rename benches/mod.rs to benches/buffer.rs This naming makes more sense, especially if we add more benchmark files. Signed-off-by: Joe Richey <joerichey@google.com> * Rework benchmarks to make it easier to get assembly. This change: - Move the benchmarks from mod.rs to buffer.rs - Move the inner loop we benchmark into an `#[inline(never)]` function - Includes instructions for getting the ASM for a specific benchmark This should hopefully reduce the variance of these benchmarks and make it easier to figure out if we are emitting the assembly or IR we expect for a particular implementation. Signed-off-by: Joe Richey <joerichey@google.com> Signed-off-by: Joe Richey <joerichey@google.com>
This change:
&[u8]totest::black_boxfor both benchmarks#[inline(never)]functionThis should hopefully reduce the variance of these benchmarks and make it easier to figure out if we are emitting the assembly or IR we expect for a particular implementation.
Signed-off-by: Joe Richey joerichey@google.com