Skip to content
Permalink
Browse files

fix a few perf bugs

  • Loading branch information...
ry committed Mar 15, 2019
1 parent dd43ad9 commit 6fc76887742e1f740fbee0b96d039e046ead360c
Showing with 13 additions and 5 deletions.
  1. +13 −5 core/http_bench.js
@@ -35,16 +35,25 @@ const scratch32 = new Int32Array(4);
const scratchBytes = new Uint8Array(
scratch32.buffer,
scratch32.byteOffset,
scratch32.byteLength + scratch32.byteOffset
scratch32.byteOffset + scratch32.byteLength
);
assert(scratchBytes.byteLength === 4 * 4);

// Toggle what method we send with. false = legacy.
// AFAICT This has no effect on performance.
const sendWithShared = true;

function send(promiseId, opId, arg, zeroCopy = null) {
scratch32[0] = promiseId;
scratch32[1] = opId;
scratch32[2] = arg;
scratch32[3] = -1;
Deno._sharedQueue.push(scratchBytes);
libdeno.send(null, zeroCopy);
if (sendWithShared) {
Deno._sharedQueue.push(scratchBytes);
libdeno.send(null, zeroCopy);
} else {
libdeno.send(scratchBytes, zeroCopy);
}
}

/** Returns Promise<number> */
@@ -53,7 +62,6 @@ function sendAsync(opId, arg, zeroCopyData) {
const p = createResolvable();
promiseMap.set(promiseId, p);
send(promiseId, opId, arg, zeroCopyData);
libdeno.send(null, zeroCopyData);
return p;
}

@@ -65,7 +73,7 @@ function recv() {
const buf32 = new Int32Array(
buf.buffer,
buf.byteOffset,
buf.byteOffset + buf.byteOffset + buf.byteLength
buf.byteOffset + buf.byteLength
);
return {
promiseId: buf32[0],

0 comments on commit 6fc7688

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.