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

Core integration attempt #5 #1938

Merged
merged 2 commits into from
Mar 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ ts_sources = [
"js/compiler.ts",
"js/console.ts",
"js/copy_file.ts",
"js/core.ts",
"js/custom_event.ts",
"js/deno.ts",
"js/dir.ts",
Expand Down
26 changes: 4 additions & 22 deletions core/http_bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,12 @@ const scratchBytes = new Uint8Array(
);
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;
if (sendWithShared) {
Deno._sharedQueue.push(scratchBytes);
libdeno.send(null, zeroCopy);
} else {
libdeno.send(scratchBytes, zeroCopy);
}
return DenoCore.dispatch(scratchBytes, zeroCopy);
}

/** Returns Promise<number> */
Expand All @@ -74,19 +65,10 @@ function recordFromBuf(buf) {
};
}

function recv() {
const buf = Deno._sharedQueue.shift();
if (!buf) {
return null;
}
return recordFromBuf(buf);
}

/** Returns i32 number */
function sendSync(opId, arg) {
send(0, opId, arg);
const record = recv();
assert(recv() == null);
const buf = send(0, opId, arg);
const record = recordFromBuf(buf);
return record.result;
}

Expand Down Expand Up @@ -141,7 +123,7 @@ async function serve(rid) {
}

async function main() {
Deno._setAsyncHandler(handleAsyncMsgFromRust);
DenoCore.setAsyncHandler(handleAsyncMsgFromRust);

libdeno.print("http_bench.js start\n");

Expand Down
4 changes: 1 addition & 3 deletions core/http_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,7 @@ fn main() {
let js_source = include_str!("http_bench.js");

let main_future = lazy(move || {
let isolate = deno_core::Isolate::new(HttpBench());

isolate.shared_init();
let mut isolate = deno_core::Isolate::new(HttpBench());

// TODO currently isolate.execute() must be run inside tokio, hence the
// lazy(). It would be nice to not have that contraint. Probably requires
Expand Down
Loading