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

perf(ext/ffi): Avoid receiving on FFI async work channel when no UnsafeCallback exists #19454

Merged
merged 2 commits into from Jul 30, 2023

Conversation

aapoalas
Copy link
Collaborator

No performance measurements done yet but this makes the FFI event loop middleware avoid

  1. a mutable borrow of the OpState,
  2. allocating a (presumably empty) vector,
  3. trying to receive on the FfiState's async work channel,
    when no FFI workers (callbacks) exist.

When FFI workers do exist this causes an extra immutable borrow. This could maybe be avoided but it would return the vector allocation to FFI-less middleware work.

@aapoalas aapoalas requested review from mmastrac, littledivy and bartlomieju and removed request for mmastrac and littledivy June 10, 2023 05:15
@aapoalas aapoalas force-pushed the perf/http/ffi-event-loop-middleware branch from 357dd9a to a397a38 Compare June 11, 2023 06:31
Copy link
Member

@mmastrac mmastrac left a comment

Choose a reason for hiding this comment

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

I like where this PR is going... I suggest a new construction for the middleware callback to avoid extra borrows, but I think we also want to include a smallvec there to avoid hitting the heap any more than we have to.

@aapoalas aapoalas force-pushed the perf/http/ffi-event-loop-middleware branch from c9ea4bd to bd3e27d Compare June 20, 2023 18:29
Copy link
Member

@mmastrac mmastrac left a comment

Choose a reason for hiding this comment

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

LGTM

@aapoalas aapoalas changed the title perf(http): Avoid receiving on FFI async work channel when no UnsafeCallback exists perf(ext/ffi): Avoid receiving on FFI async work channel when no UnsafeCallback exists Jun 29, 2023
@aapoalas aapoalas merged commit e348c11 into denoland:main Jul 30, 2023
11 checks passed
@aapoalas aapoalas deleted the perf/http/ffi-event-loop-middleware branch July 30, 2023 13:43
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.

None yet

2 participants