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: lazy atexit setup #21053

Merged
merged 3 commits into from
Nov 4, 2023
Merged

perf: lazy atexit setup #21053

merged 3 commits into from
Nov 4, 2023

Conversation

littledivy
Copy link
Member

libc::atexit incurrs 2% dyld cost at startup on macOS. This PR moves the setup to when the tty mode is changed using op_stdin_set_raw.

@mmastrac
Copy link
Contributor

mmastrac commented Nov 2, 2023

/bench startup_nop_empty

@denobot
Copy link
Collaborator

denobot commented Nov 2, 2023

startup_nop_empty

time user system relative
node 22 ms 17 ms 6 ms +690.4%
bun 2 ms 0 ms 1 ms best
deno 16 ms 11 ms 5 ms +472.0%
deno-baseline 16 ms 10 ms 6 ms +470.8%

start: Thu, 02 Nov 2023 16:10:17 GMT

id: 89801a37-f1d1-49c4-a033-75cd95194b0a

server: 877332cb-1a3c-499d-a92c-39e827edb3c9

runtime/ops/tty.rs Outdated Show resolved Hide resolved
extern "C" fn reset_stdio() {
// SAFETY: Reset the stdio state.
unsafe { tcsetattr(libc::STDIN_FILENO, 0, &ORIG_TERMIOS.unwrap()) };
static ORIG_TERMIOS: OnceCell<Option<termios>> = OnceCell::new();
Copy link
Contributor

Choose a reason for hiding this comment

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

💯 perfect

@littledivy littledivy enabled auto-merge (squash) November 3, 2023 18:02
@littledivy littledivy disabled auto-merge November 4, 2023 04:29
@littledivy littledivy requested a review from mmastrac November 4, 2023 04:29
Copy link
Contributor

@mmastrac mmastrac 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 0b75a71 into denoland:main Nov 4, 2023
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.

3 participants