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

refactor(minimal ops) refactor minimal ops & rename to buffer ops #9719

Merged
merged 8 commits into from
Mar 18, 2021
Merged

refactor(minimal ops) refactor minimal ops & rename to buffer ops #9719

merged 8 commits into from
Mar 18, 2021

Conversation

inteon
Copy link
Contributor

@inteon inteon commented Mar 7, 2021

Extracted minimal ops rewrite from #9457.

Is first step in effort to merge json and buffer ops.

R: ValueOrVector,
{
rt.register_op(name, metrics_op(name, buffer_op_sync(op_fn)));
}
Copy link
Member

Choose a reason for hiding this comment

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

I like how this is mirrors the structure of the JSON ops register function - so I think easier to understand.

runtime/ops/ops_buffer.rs Outdated Show resolved Hide resolved
runtime/ops/ops_buffer.rs Outdated Show resolved Hide resolved
@inteon
Copy link
Contributor Author

inteon commented Mar 11, 2021

@ry I made the required changes and added some tests.
I use the little-endian rust functions to convert u64 to u8.
Is there a preference for little/ big endianness in Deno?

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

A few more nitpicks from me, but after that I think we're ready to land this PR, great work @inteon

core/core.js Show resolved Hide resolved
function opAsync(opName, opRequestBuilder, opResultParser) {
// Make sure requests of this type are handled by the asyncHandler
// The asyncHandler's role is to call the "promiseTable[requestId]" function
core.setAsyncHandlerByName(opName, (bufUi8, _) => {
Copy link
Member

Choose a reason for hiding this comment

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

Not entirely sure, but I have a feeling that using arrow function here might be less performant than having a named function definition before opAsync

Copy link
Contributor Author

Choose a reason for hiding this comment

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

opResultParser is passed into this arrow function, so that makes it hard to extract this arrow function from this opAsync function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

a solution could be to call this function on an object that stores this opResultParser function, but I found this quickly makes the code a lot less readable. please let me know if you think this is useful (I could create such a solution and share it with you for review)

Copy link
Member

Choose a reason for hiding this comment

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

@inteon is it required to pass that opResultParser? I think you could just directly call it in such function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I see, let's land it as is then.

runtime/js/10_dispatch_buffer.js Show resolved Hide resolved
function opAsync(opName, opRequestBuilder, opResultParser) {
// Make sure requests of this type are handled by the asyncHandler
// The asyncHandler's role is to call the "promiseTable[requestId]" function
core.setAsyncHandlerByName(opName, (bufUi8, _) => {
Copy link
Member

Choose a reason for hiding this comment

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

Also wondering if this should be called only once, otherwise a new callback is set with each call to the op

Copy link
Contributor Author

@inteon inteon Mar 16, 2021

Choose a reason for hiding this comment

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

I also think this should be called once. The current jsonOp implementation also does this wrongly (so it is somewhat unrelated to this PR):

deno/core/core.js

Lines 214 to 217 in bd961c3

async function jsonOpAsync(opName, args = null, ...zeroCopy) {
setAsyncHandler(opsCache[opName], jsonOpAsyncHandler);

I do fix this for both bufferOps and jsonOps in #9457.

runtime/js/10_dispatch_buffer.js Outdated Show resolved Hide resolved
runtime/js/10_dispatch_buffer.js Outdated Show resolved Hide resolved
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @inteon

@bartlomieju bartlomieju merged commit 20627c9 into denoland:main Mar 18, 2021
@inteon inteon deleted the move_minimal_ops_to_core_step1 branch March 4, 2022 10:45
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

3 participants