-
Notifications
You must be signed in to change notification settings - Fork 341
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
[email protected]: big benchmark regression on block_on #770
Comments
bench code: https://github.com/casbin/casbin-rs/blob/master/benches/benchmark.rs, this bench code isn't that correct because I'm creating runtime in every bench However, casbin-rs's previous version uses the same bench code so basically I think the bench can be compared to previous version which uses [email protected] |
@dignifiedquire Any idea on this? Thanks in advance. |
@GopherJ it may also be useful to open an issue on |
@yoshuawuyts From stjepang :
then it becomes hard to benchmark async code. |
I am working on this, the issue will be fixed with smol 0.2 when it gets released. The solution is to create a thread-local executor lazily on demand. If there is no |
@stjepang does that mean smol 0.2 i would like to use smol, but i'm currently struggling cause my simplest case is a |
@algesten In that case, I wonder why not just use Version 0.2 will break smol into 3 subcrates: blocking (already done), async I/O + timers, and executor. There will be more knobs for async I/O and executors, which will allow us to implement |
@stjepang ah you're right! thanks! I'm just getting acquainted with smol's API. |
Is this still an issue? I believe it has been resolved but can we check? |
HI, @stjepang , I confirm it's nearly fixed: #![feature(test)]
extern crate test;
use test::Bencher;
fn raw_enforce(r: [&str; 3]) -> bool {
let policies = [["alice", "data1", "read"], ["bob", "data2", "write"]];
for policy in &policies {
if policy == &r {
return true;
}
}
return false;
}
async fn async_enforce(r: [&str; 3]) -> bool {
raw_enforce(r)
}
#[bench]
fn b_benchmark_raw(b: &mut Bencher) {
b.iter(|| {
raw_enforce(["alice", "data1", "read"]);
});
}
#[bench]
fn b_benchmark_async(b: &mut Bencher) {
b.iter(|| {
async_std::task::block_on(async_enforce(["alice", "data1", "read"]));
});
} [email protected][email protected] |
In this PR casbin/casbin-rs#136, I upgraded
async-std
to1.6-beta.1
because I'm interested in itswasm
support, thanks for @dignifiedquire who made the fix in branchfix/file-block
#768However, after upgrading, I found that there is a big bench regression, you should be able to see it from here:
https://travis-ci.org/github/casbin/casbin-rs/jobs/685015785#L813
The text was updated successfully, but these errors were encountered: