Skip to content

Conversation

@BridgeAR
Copy link
Member

  1. commit: util: improve inspect's customInspect performance
This improves the performance to copy user options that are then passed through to the custom inspect function. The performance improvement depends on the complexity of the custom inspect function. For very basic cases this is 100% faster than before. 
  1. commit: util: add more predefined color codes to inspect.colors
This adds most commonly used ANSI color codes to `util.inspect.colors`. 

@nodejs/util PTAL

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

This improves the performance to copy user options that are then passed through to the custom inspect function. The performance improvement depends on the complexity of the custom inspect function. For very basic cases this is 100% faster than before.
This adds most commonly used ANSI color codes to `util.inspect.colors`.
@nodejs-github-botnodejs-github-bot added the util Issues and PRs related to the built-in util module. label Nov 26, 2019
@nodejs-github-bot

This comment has been minimized.

@TrottTrott added the semver-minor PRs that contain new features and should be released in the next minor version. label Nov 26, 2019
@Trott
Copy link
Member

I'd consider adding more colors that we support to be semver-minor. Once we add it, we'll risk breaking people's stuff if we ever take it away.

Not strongly opposed (at least at this moment), but wondering if we might want to leave robust color support to userland modules and just support the relatively small number of colors we already support. Is there a justification for these colors in particular over the colors that we already have?

@BridgeAR
Copy link
MemberAuthor

BridgeAR commented Nov 26, 2019

@Trott I actually already have follow-up pull requests that add further "robust" color support to Node.js.

This is just a first step in that direction. I recently had another PR open (#29676) where I needed a color code that we did not yet have in our predefined ones. We also need more APIs to properly handle colors internally. Otherwise it's not possible to add colors in Node.js core and that is something I try to slowly move forward.

@nodejs-github-bot

This comment has been minimized.

@BridgeARBridgeAR added the performance Issues and PRs related to the performance of Node.js. label Nov 26, 2019
@nodejs-github-bot
Copy link
Collaborator

});
}

defineColorAlias('gray','grey');
Copy link
Member

Choose a reason for hiding this comment

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

grey/gray seem motivated, but why are the rest of these here?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Mainly due to different descriptions depending on where these ANSI codes are described. I have no strong opinion on either of these names. I thought it does not hurt to allow different aliases so people could use what ever they feel most comfortable with. The camel case and all lower cased versions are just there to prevent typos.

@nodejs-github-bot
Copy link
Collaborator

@BridgeAR
Copy link
MemberAuthor

@nodejs/util this could use another review :)

@BridgeAR
Copy link
MemberAuthor

@nodejs/util @nodejs/repl @devsnek@Trott I would like to land this soon. I have multiple PRs that need more color support.

I'll land this if there's no objection in the next 24 hours.

Copy link
Contributor

@antsmartianantsmartian left a comment

Choose a reason for hiding this comment

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

LGTM

@nodejs-github-bot

This comment has been minimized.

@BridgeARBridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Dec 6, 2019
@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Dec 6, 2019

BridgeAR added a commit that referenced this pull request Dec 6, 2019
This improves the performance to copy user options that are then passed through to the custom inspect function. The performance improvement depends on the complexity of the custom inspect function. For very basic cases this is 100% faster than before. PR-URL: #30659 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Anto Aravinth <[email protected]>
BridgeAR added a commit that referenced this pull request Dec 6, 2019
This adds most commonly used ANSI color codes to `util.inspect.colors`. PR-URL: #30659 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Anto Aravinth <[email protected]>
@BridgeAR
Copy link
MemberAuthor

Landed in 2a0ec9c, 832290a 🎉

@BridgeARBridgeAR closed this Dec 6, 2019
targos pushed a commit that referenced this pull request Dec 9, 2019
This improves the performance to copy user options that are then passed through to the custom inspect function. The performance improvement depends on the complexity of the custom inspect function. For very basic cases this is 100% faster than before. PR-URL: #30659 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Anto Aravinth <[email protected]>
targos pushed a commit that referenced this pull request Dec 9, 2019
This adds most commonly used ANSI color codes to `util.inspect.colors`. PR-URL: #30659 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Anto Aravinth <[email protected]>
@MylesBorinsMylesBorins mentioned this pull request Dec 13, 2019
targos pushed a commit that referenced this pull request Jan 14, 2020
This improves the performance to copy user options that are then passed through to the custom inspect function. The performance improvement depends on the complexity of the custom inspect function. For very basic cases this is 100% faster than before. PR-URL: #30659 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Anto Aravinth <[email protected]>
targos pushed a commit that referenced this pull request Jan 14, 2020
This adds most commonly used ANSI color codes to `util.inspect.colors`. PR-URL: #30659 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Anto Aravinth <[email protected]>
@targostargos mentioned this pull request Jan 15, 2020
@BridgeARBridgeAR deleted the improve-user-options-perf branch January 20, 2020 12:07
BethGriggs pushed a commit that referenced this pull request Feb 6, 2020
This improves the performance to copy user options that are then passed through to the custom inspect function. The performance improvement depends on the complexity of the custom inspect function. For very basic cases this is 100% faster than before. PR-URL: #30659 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Anto Aravinth <[email protected]>
BethGriggs pushed a commit that referenced this pull request Feb 6, 2020
This adds most commonly used ANSI color codes to `util.inspect.colors`. PR-URL: #30659 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Anto Aravinth <[email protected]>
@MylesBorinsMylesBorins mentioned this pull request Feb 8, 2020
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.performanceIssues and PRs related to the performance of Node.js.semver-minorPRs that contain new features and should be released in the next minor version.utilIssues and PRs related to the built-in util module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@BridgeAR@nodejs-github-bot@Trott@jasnell@antsmartian@targos@devsnek