Uh oh!
There was an error while loading. Please reload this page.
util: improve util.format performance - #5360
Conversation
evanlucas
commented
Feb 22, 2016
There was a problem hiding this comment.
Use var here until v8 can optimize let better.
447e7f1 to
88039b9CompareThere was a problem hiding this comment.
Sorry, you'll also need to move the var i declaration out and above and change var i = 1; a few lines below to i = 1 to avoid a linter error.
There was a problem hiding this comment.
yep, just noticed that locally. Thanks
88039b9 to
429ad25Comparemscdex
commented
Feb 22, 2016
For bonus points, you can change for(varx=args[i];i<len;x=args[++i]){to while(i<len){constx=args[i++];to avoid an eager deopt due to potential out of bounds access on |
7a00928 to
91fc8b4Compareevanlucas
commented
Feb 22, 2016
Ah, totally missed the case where |
There was a problem hiding this comment.
String(f) here can probably just be replaced with just f since it should already be a string at that point.
evanlucas
commented
Feb 22, 2016
ooo good catch |
91fc8b4 to
6fd10feComparemscdex
commented
Feb 22, 2016
mscdex
commented
Feb 22, 2016
Just for fun I replaced the regexp + replace function with a simple loop and improved performance an additional 60-200% in the benchmarks included (and no change in the |
evanlucas
commented
Feb 22, 2016
wow, nice |
jasnell
commented
Mar 2, 2016
Marking this LTS watch but I'd rather this sit for a bit before getting pulled back. |
jasnell
commented
Mar 2, 2016
LGTM |
evanlucas
commented
Mar 4, 2016
Running CI again: https://ci.nodejs.org/job/node-test-pull-request/1851/ |
PR-URL: nodejs#5360 Reviewed-By: James M Snell <jasnell@gmail.com>
By manually copying arguments and breaking the try/catch out, we are able to improve the performance of util.format by 20-100% (depending on the types). PR-URL: nodejs#5360 Reviewed-By: James M Snell <jasnell@gmail.com>
Replacing the regexp and replace function with a loop improves performance by ~60-200%. PR-URL: nodejs#5360 Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins
commented
May 17, 2016
@jasnell would you want to include this in a future lts? |
jasnell
commented
May 17, 2016
I believe so yes. |
MylesBorins
commented
Jul 1, 2016
@jasnell / @nodejs/lts how much longer to we want this to live before backporting? |
jasnell
commented
Jul 1, 2016
I haven't heard of any regressions. We may be good on this one
|
By manually copying arguments and breaking the try/catch out, we are able to improve the performance of util.format by 20-100% (depending on the types). PR-URL: #5360 Reviewed-By: James M Snell <jasnell@gmail.com>
Replacing the regexp and replace function with a loop improves performance by ~60-200%. PR-URL: #5360 Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins
commented
Jul 11, 2016
I've gone ahead and added this to v4.x-staging and will include it in the v4.5.0 rc. @evanlucas please let me know if there are any accompanying patch's we need to make this work |
MylesBorins
commented
Jul 11, 2016
@evanlucas as a heads up you need to provide the commit before your initial commit when doing the 735e0df...c490b8b does not include 735e0df |
By manually copying arguments and breaking the try/catch out, we are able to improve the performance of util.format by 20-100% (depending on the types). PR-URL: #5360 Reviewed-By: James M Snell <jasnell@gmail.com>
Replacing the regexp and replace function with a loop improves performance by ~60-200%. PR-URL: #5360 Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: #5360 Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: #5360 Reviewed-By: James M Snell <jasnell@gmail.com>
evanlucas
commented
Jul 12, 2016
@thealphanerd there shouldn't be anything else need to land these. Thanks for the heads up on the range syntax as well :] |
By manually copying arguments and breaking the try/catch out, we are able to improve the performance of util.format by 20-100% (depending on the types). PR-URL: #5360 Reviewed-By: James M Snell <jasnell@gmail.com>
Replacing the regexp and replace function with a loop improves performance by ~60-200%. PR-URL: #5360 Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: #5360 Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: #5360 Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: #5360 Reviewed-By: James M Snell <jasnell@gmail.com>
By manually copying arguments and breaking the try/catch out, we are able to improve the performance of util.format by 20-100% (depending on the types).
Also includes a util.format benchmark.
The numbers:
EDIT: I updated the numbers after rebasing on master and with @mscdex's changes included as well.