Skip to content
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

feat(ops): implement fast lazy async ops #16579

Merged
merged 51 commits into from
Nov 11, 2022

Conversation

littledivy
Copy link
Member

@littledivy littledivy commented Nov 9, 2022

Depends on #16514

#[op(fast)]
async fn op_read(
  state: Rc<RefCell<OpState>>,
  rid: ResourceId,
  buf: &mut [u8],
) -> Result<u32, Error> {
  // ...
}

The future is scheduled via a fast API call and polled by the event loop after being woken up by its waker.

Copy link
Member Author

@littledivy littledivy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe attribute name "fast" is misleading for async ops that can benefit from first-poll-resolution instead of a full event-loop tick. A very useless example is op_void_async

@littledivy littledivy marked this pull request as ready for review November 10, 2022 12:50
core/resources.rs Outdated Show resolved Hide resolved
runtime/ops/io.rs Outdated Show resolved Hide resolved
@lucacasonato
Copy link
Member

I do not think the core/resources.rs related changes are correct at all.

@littledivy
Copy link
Member Author

@lucacasonato Reverted those changes. Instead of marking the generalized op_read, I think we should selectively mark specialized ops (eg op_http_read) after profiling.

@lucacasonato
Copy link
Member

I think we should selectively mark specialized ops (eg op_http_read) after profiling.

Maybe - but we need to take care that the Resource::read ops stay correct so that fast streams continue to work.

@littledivy littledivy merged commit 5b9620d into denoland:main Nov 11, 2022
bartlomieju pushed a commit to bartlomieju/deno that referenced this pull request Nov 12, 2022
Implements fast scheduling of deferred op futures. 

```rs
#[op(fast)]
async fn op_read(
  state: Rc<RefCell<OpState>>,
  rid: ResourceId,
  buf: &mut [u8],
) -> Result<u32, Error> {
  // ...
}
```

The future is scheduled via a fast API call and polled by the event loop
after being woken up by its waker.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants