GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — util: delay creation of debug context by ofrobots · Pull Request #2248 · nodejs/node

Conversation

@ofrobots

@ofrobots ofrobots commented Jul 25, 2015

Copy link
Copy Markdown
Contributor

Now that it is really simple to take profiles with node (thanks to #2090), I was looking a profile I got from a trivial JSON.stringify benchmark.

I was really surprised by the number of ticks I got in RunInDebugContext. The full profile is here but here's an excerpt:

38    0.7%    0.7%  node::ContextifyContext::RunInDebugContext(v8::FunctionCallbackInfo<v8::Value> const&)

I looked into this. It seems that #1471 introduced a change which now creates a Debug context by default in the util module. This is needed to be able to inspect promises. I think this is fine, but we should not be doing the really expensive operation of creating a Debug context on default startup of node. This patch fixes that.

Based on my measurements, this saves ~24ms in node startup time measured as follows:

#!/usr/bin/bash
# Note: this requires GNU date
start=$(date +%s%N)
for c in {0..60}
do
  iojs -e " "
done
new=$(date +%s%N)
elapsed=$(((new - start)/60))
echo $elapsed

This reduces startup time from ~90ms → ~66ms on my machine. I think it is important that node startup is as fast as possible. I don't like deferred initialization as I am proposing, but I think it is a much lesser evil than spending 24ms on each node startup.

R=@bnoordhuis, @monsanto

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ofrobots
util: delay creation of debug context
1f0a679
We need the debug context to be able to inspect promises. However, this is
very expensive and should not be done on default startup.
@mscdex mscdex added util Issues and PRs related to the built-in util module. vm Issues and PRs related to the vm subsystem. labels Jul 25, 2015
@mscdex

mscdex commented Jul 25, 2015

Copy link
Copy Markdown
Contributor

LGTM

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@targos

targos commented Jul 25, 2015

Copy link
Copy Markdown
Member

LGTM, the difference is huge !

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnoordhuis

bnoordhuis commented Jul 25, 2015

Copy link
Copy Markdown
Member

LGTM. Obvious in hindsight.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fishrock123

Fishrock123 commented Jul 25, 2015

Copy link
Copy Markdown
Contributor

So does this mean that the first time you console.log a promise it'l take like 24ms?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@monsanto

monsanto commented Jul 25, 2015

Copy link
Copy Markdown
Contributor

LGTM

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@brendanashworth brendanashworth mentioned this pull request Jul 26, 2015
Process startup time on ARM #2138
Closed
@rvagg

rvagg commented Jul 27, 2015

Copy link
Copy Markdown
Member

https://jenkins-iojs.nodesource.com/job/iojs+any-pr+multi/194/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ofrobots

ofrobots commented Jul 27, 2015

Copy link
Copy Markdown
Contributor Author

@Fishrock123 Yes, it is going to be expensive for the first promise that is inspected.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig

cjihrig commented Jul 27, 2015

Copy link
Copy Markdown
Contributor

Definitely worth the tradeoff IMO. LGTM.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ofrobots

ofrobots commented Jul 27, 2015

Copy link
Copy Markdown
Contributor Author

The CI looks decent to me, ignoring the flaky failures. I will land this later today.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ofrobots added a commit that referenced this pull request Jul 28, 2015
@ofrobots
util: delay creation of debug context
ab47965
We need the debug context to be able to inspect promises. However, this is
very expensive and should not be done on default startup.

PR-URL: #2248
Reviewed-By: Brian White <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Christopher Monsanto <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
@ofrobots

ofrobots commented Jul 28, 2015

Copy link
Copy Markdown
Contributor Author

Landed in ab47965.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ofrobots ofrobots closed this Jul 28, 2015
@cjihrig cjihrig mentioned this pull request Jul 28, 2015
Release Proposal: v2.5.0 #2239
Merged
@ofrobots
ofrobots deleted the delay-debug-context branch August 3, 2015 23:08
@snyk-bot snyk-bot mentioned this pull request Aug 11, 2020
[Snyk] Upgrade prismjs from 1.18.0 to 1.20.0 radiumrasheed/node#5
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

util Issues and PRs related to the built-in util module. vm Issues and PRs related to the vm subsystem.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

8 participants

@ofrobots @mscdex @targos @bnoordhuis @Fishrock123 @monsanto @rvagg @cjihrig
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.