-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Remove control slice from ops #6048
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very interesting! We need to be extremely careful with this patch - since it effects everything - do you have any ideas about the perf impact?
I think the benchmarks should go together with frequency analysis; I'll probably do that later today or tomorrow. |
Benchmarks
zero_copy length counts for different programsFetch remote images and store them to diskInitial fetch
Check for new images to fetch (none added)
Single fetch and display processed data
Oak's getting started returning
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I think we should rename ZeroCopyBuf
to JSBuf
or something because it is a bit misleading now (doesn't have to be done in this patch).
Also we should probably document that ops shouldn't clone and store zero_copy[0]
because it might be overwritten immediately.
@ry PTAL
|
master:
this branch try 1
this branch try 2
|
Also pretty wonky. Node and Hyper differ a lot between the runs :/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SyrupThinker We have concerns about the correctness of this patch in the way the control buffer gets rewritten on the shared buffer. I'm making this patch as "Request changes" so it doesn't accidentally get merged.
I suspect we can come up with a test case that introduces errors: modify the control buf during an async op, while there are other async ops happening.
From Discord chat:
|
@SyrupThinker Can you please merge with master? Note there's been a recent patch that introduced the |
What's the status on this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marking as "request changes" because in the current state this PR introduces panics when Deno.core.dispatch()
is called without at least two arguments
v1.1.3
$ deno
Deno 1.1.3
exit using ctrl+d or close()
> const a = Deno.core.dispatch(10)
undefined
> new TextDecoder().decode(a)
{"err":{"message":"EOF while parsing a value at line 1 column 0","kind":17},"promiseId":null}
this PR
target/debug/deno
Deno 1.1.2
exit using ctrl+d or close()
> const a = Deno.core.dispatch(10)
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', cli/state.rs:107:32
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5
[1] 21816 abort target/debug/deno
@SyrupThinker I think there should be some validation added in core/bindings.rs::send
that there's at least one zero copy buffer passed or some JS error returned informing that too few arguments were passed.
That seems like an arbitrary restriction to me. If my op just changes the system state and doesn't take parameters why should I be forced to pass an argument anyway? |
@SyrupThinker I apologize for the delay in landing this patch. It's a very central change so we have to be careful. I will land this today. I want to see its effects on the benchmarks. Potentially it will be reverted if we see some negative side effects. Potentially we'll just land some fixes for the issue Bartek brought up. Bartek, it's a good point but let's just land this anyway. Just waiting for the last few commits I landed to go green. Then I will merge this. |
Thats what the last commit did ;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - thank you for all the hard work @SyrupThinker
Observation
The control slice is special cased in the dispatch interface despite it being treated similar to zero copy buffers internally.
Does the interface benefit from this distinction, or should it be removed for simplicity?
Points that need to be addressed in the implementation of this PR
DenoCore
interface now has two identical functionsdispatch
andsend
One could be removed.
Is the distinction of control and data bytes still appropriate for theMetrics
? The PR currently merges them. This changes the stable public interface, so it might be undesired.How manyZeroCopyBuf
s should be stack allocated?I'm currently planning on measuring the frequency of buffer counts for different workloads to determine this.