FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fs: two minor optimizations by BridgeAR · Pull Request #14055 · nodejs/node · GitHub

/ node Public

fs: two minor optimizations - #14055

Merged
refack merged 1 commit into
nodejs:masterfrom
BridgeAR:micro-optimize-fs
Jul 9, 2017
Merged

fs: two minor optimizations#14055
refack merged 1 commit into
nodejs:masterfrom
BridgeAR:micro-optimize-fs

Conversation

BridgeAR commented Jul 3, 2017

Copy link
Copy Markdown
Member
  1. If the function in tryStatSync threw, it would never reach that code path to return any value.
  2. Only use try catch if necessary. lchmodSync does not need the second try catch in most cases.
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
Affected core subsystem(s)

fs

nodejs-github-bot added the fs Issues and PRs related to the fs subsystem / file system. label Jul 3, 2017
Comment thread lib/fs.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Now that TF+I are in, can we start inlining all of these try* functions?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

At least in a recently run benchmark (v8 5.8) it still seemed like it's a tiny bit better to keep them around. I suggest to wait until 6.0 has landed and if it's good to inline them, I'd make a single PR for all of them.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Ack, since it's an patch level enhancement that should land in v8.x, although it will probably be relevant for 1 minor node8 release.

Comment thread lib/fs.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I guess it was written like this for performance. If not, isn't cleaner to use catch and get rid of the threw variable?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I am about to open a separate PR that deals with lots of those :D

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Get ready to run benchmarks then :) as I remember that some of these changes (finally -> catch) were rejected in the past. I think it was on timers.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Out of my perspective the main issue is that the error has to be thrown again.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Hm, when running the benchmark it does not seem to be a significant change, so it would be more churn than anything else.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@BridgeAR please note that the performance profile of try/catch/finally changed quite a bit since the code was added most likely :)

BridgeAR Jul 8, 2017
edited
Loading

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Of course but I ran the benchmarks with changing these to try catch and it did not show changed numbers. Therefore I think it's mainly churn to change it.

Comment thread lib/fs.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Ack, since it's an patch level enhancement that should land in v8.x, although it will probably be relevant for 1 minor node8 release.

refack commented Jul 8, 2017

Copy link
Copy Markdown
Contributor

refack self-assigned this Jul 8, 2017
Comment thread lib/fs.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

does a trinary with assign to const perform better?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

There is not really a measurable difference.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

🤷‍♂️ never mind then

* tryStatSync should not return any value
  If the function threw, it would never reach that code path.

* only use try catch if necessary
  lchmodSync does not need the second try catch in most cases.

PR-URL: nodejs#14055
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
refack force-pushed the micro-optimize-fs branch from ac7bd7c to 1806952 Compare July 9, 2017 17:42
refack merged commit 1806952 into nodejs:master Jul 9, 2017

refack commented Jul 9, 2017

Copy link
Copy Markdown
Contributor

addaleax pushed a commit that referenced this pull request Jul 11, 2017
* tryStatSync should not return any value
  If the function threw, it would never reach that code path.

* only use try catch if necessary
  lchmodSync does not need the second try catch in most cases.

PR-URL: #14055
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
addaleax mentioned this pull request Jul 11, 2017
addaleax pushed a commit that referenced this pull request Jul 18, 2017
* tryStatSync should not return any value
  If the function threw, it would never reach that code path.

* only use try catch if necessary
  lchmodSync does not need the second try catch in most cases.

PR-URL: #14055
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Fishrock123 pushed a commit that referenced this pull request Jul 19, 2017
* tryStatSync should not return any value
  If the function threw, it would never reach that code path.

* only use try catch if necessary
  lchmodSync does not need the second try catch in most cases.

PR-URL: #14055
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>

Copy link
Copy Markdown
Contributor

Should this be backported to v6.x-staging? If yes please follow the guide and raise a backport PR, if no let me know or add the dont-land-on label.

Copy link
Copy Markdown
Contributor

ping re: v6.x

Copy link
Copy Markdown
Member Author

I will open a PR to backport this soon.

Copy link
Copy Markdown
Contributor

ping @BridgeAR

Copy link
Copy Markdown
Member Author

When looking at it again there is little benefit for backporting, so I just changed the label accordingly.

refack removed their assignment Oct 12, 2018
BridgeAR deleted the micro-optimize-fs branch April 1, 2019 23:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fs Issues and PRs related to the fs subsystem / file system.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants


Back | FazBrowse Home | New Git URL