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(runtime): optimize Deno.file open & stream #15496

Merged
merged 4 commits into from Aug 19, 2022

Conversation

littledivy
Copy link
Member

@littledivy littledivy commented Aug 19, 2022

Opening and closing files is 2.5x faster

# Deno new
open_file_sync     7.55 µs/iter     (7.51 µs … 7.72 µs)   7.56 µs   7.72 µs   7.72 µs
# Deno `main`
open_file_sync    18.31 µs/iter   (17.79 µs … 39.75 µs)  18.25 µs  19.62 µs  20.62 µs

ext/flash send_file benchmark now gives 7GB/s transfer rate. 1.3x faster than main:

Transfer/sec:      5.79GB # main
Transfer/sec:      7.56GB # new

@@ -658,7 +658,9 @@
* @returns {ReadableStream<Uint8Array>}
*/
function readableStreamForRid(rid, unrefCallback) {
const stream = new ReadableStream({
Copy link
Member Author

Choose a reason for hiding this comment

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

something to note: ReadableStream initialization triggers a pretty serious deopt in V8. From a flamegraph of the send file server on main:

image

@aapoalas
Copy link
Collaborator

Opening and closing files is 2.5x faster

# Deno `main`
open_file_sync     7.55 µs/iter     (7.51 µs … 7.72 µs)   7.56 µs   7.72 µs   7.72 µs
# Deno new
open_file_sync    18.31 µs/iter   (17.79 µs … 39.75 µs)  18.25 µs  19.62 µs  20.62 µs

Am I reading this wrong somehow? I read this as the new open_file_sync taking 18 microseconds and the old one taking only 7.5 microseconds, ie. old one being faster.

@littledivy
Copy link
Member Author

Am I reading this wrong somehow? I read this as the new open_file_sync taking 18 microseconds and the old one taking only 7.5 microseconds, ie. old one being faster.

Oopsie, wrong labels.

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

@littledivy littledivy merged commit 9e576df into denoland:main Aug 19, 2022
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