Skip to content

Commit

Permalink
perf(core): don't access isolate slots for JsRuntimeState (denoland#1…
Browse files Browse the repository at this point in the history
…6376)

example writeFile benchmark:

```
# before
time 188 ms rate 53191
time 168 ms rate 59523
time 167 ms rate 59880
time 166 ms rate 60240
time 168 ms rate 59523
time 173 ms rate 57803
time 183 ms rate 54644

# after
time 157 ms rate 63694
time 152 ms rate 65789
time 151 ms rate 66225
time 151 ms rate 66225
time 152 ms rate 65789
```
  • Loading branch information
littledivy authored Oct 21, 2022
1 parent 0f27b84 commit d461a78
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 97 deletions.
3 changes: 3 additions & 0 deletions core/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::error::AnyError;
use crate::gotham_state::GothamState;
use crate::resources::ResourceTable;
use crate::runtime::GetErrorClassFn;
use crate::runtime::JsRuntimeState;
use crate::OpDecl;
use crate::OpsTracker;
use anyhow::Error;
Expand All @@ -19,6 +20,7 @@ use std::ops::Deref;
use std::ops::DerefMut;
use std::pin::Pin;
use std::rc::Rc;
use std::rc::Weak;
use std::task::Context;
use std::task::Poll;

Expand Down Expand Up @@ -152,6 +154,7 @@ pub struct OpCtx {
pub id: OpId,
pub state: Rc<RefCell<OpState>>,
pub decl: OpDecl,
pub runtime_state: Weak<RefCell<JsRuntimeState>>,
}

/// Maintains the resources and ops inside a JS runtime.
Expand Down
2 changes: 1 addition & 1 deletion core/ops_builtin_v8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ fn op_set_format_exception_callback<'a>(

#[op(v8)]
fn op_event_loop_has_more_work(scope: &mut v8::HandleScope) -> bool {
JsRuntime::event_loop_pending_state(scope).is_pending()
JsRuntime::event_loop_pending_state_from_isolate(scope).is_pending()
}

#[op(v8)]
Expand Down
Loading

0 comments on commit d461a78

Please sign in to comment.