You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to start a server (setup), then run some calls to it, benchmarking the calls. Because some of these calls can cause writes (think of it like key-value store), I want each call to have a unique value. The easiest thing to do is to just use the iteration count as the key.
I tried iter_batched, but that has no way to pass the current iteration count:
b.to_async(&rt).iter_batched(
|| {
// simple example of dataletdata=vec![0u8; size].into_boxed_slice();
data
},
|input|async {
letput_tx=srv.put_tx();
letkey=format!("key{}", count); // <--- THIS doesn't work; no way to get the current iteration count// do work with key to send to serverlet_=put_tx.send(PutMsg {
key,
value: input,
resp_tx,
});
letresult=resp_rx.recv().await;
black_box(result)
},
BatchSize::SmallInput,
);
Next effort was to use a counter in setup:
letmutiteration_count=0;
b.to_async(&rt).iter_batched(
|| {
iteration_count+=1;
// simple example of dataletdata=vec![0u8; size].into_boxed_slice();
(data, iteration_count)
},
|(input, count)|async {
letput_tx=srv.put_tx();
letkey=format!("key{}", count); // <--- THIS now has a value for `count`// do work with key to send to serverlet_=put_tx.send(PutMsg {
key,
value: input,
resp_tx,
});
letresult=resp_rx.recv().await;
black_box(result)
},
BatchSize::SmallInput,
);
This doesn't work, because I am passing a mut into an async fn.
Looks simple enough, but this also fails, because the async fn borrows iters, and the async may outlive the calling function.
But I cannot declare it move, because it doesn't like the move of srv, or data, or a whole bunch of things., like the srv, which cannot be moved. Actually, that is the whole reason for this approach, to have the srv set up before.
So, what is the correct approach to this? How do I call iter_custom on AsyncBencher and actually reference the iters inside the function?
The text was updated successfully, but these errors were encountered:
I am trying to start a server (setup), then run some calls to it, benchmarking the calls. Because some of these calls can cause writes (think of it like key-value store), I want each call to have a unique value. The easiest thing to do is to just use the iteration count as the key.
I tried
iter_batched
, but that has no way to pass the current iteration count:Next effort was to use a counter in setup:
This doesn't work, because I am passing a
mut
into an async fn.So I tried to switch to using
iter_custom
:Looks simple enough, but this also fails, because the async fn borrows
iters
, and the async may outlive the calling function.But I cannot declare it
move
, because it doesn't like the move ofsrv
, ordata
, or a whole bunch of things., like thesrv
, which cannot be moved. Actually, that is the whole reason for this approach, to have thesrv
set up before.So, what is the correct approach to this? How do I call
iter_custom
onAsyncBencher
and actually reference theiters
inside the function?The text was updated successfully, but these errors were encountered: