Skip to content

Commit 6c2bc97

Browse files
committed
docs: Add alloca explanation
1 parent 6180449 commit 6c2bc97

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/routine.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,12 @@ where
252252
for (i, iters) in iters.iter().enumerate() {
253253
#[cfg(any(target_family = "unix", target_family = "windows"))]
254254
{
255+
// Intentionally vary the stack allocation size to reduce measurement bias from
256+
// memory alignment and cache effects.
257+
// The shift can go up to a full page size suitable for the system.
255258
alloca::with_alloca(
256-
i % page_size::get(), /* how much bytes we want to allocate */
257-
|_shifting_stack_space: &mut [core::mem::MaybeUninit<u8>] /* dynamically stack allocated slice itself */| {
259+
i % page_size::get(), /* how many bytes we want to allocate */
260+
|_shifting_stack_space: &mut [core::mem::MaybeUninit<u8>] /* stack allocated slice itself */| {
258261
b.iters = *iters;
259262
(*f)(&mut b, black_box(parameter));
260263
b.assert_iterated();

0 commit comments

Comments
 (0)