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

benchmark: avoid TurboFan deopt in arrays bench #11894

Closed
wants to merge 1 commit into from

Conversation

targos
Copy link
Member

@targos targos commented Mar 17, 2017

Something unidentified at the moment is causing the arrays benchmarks to
deopt when run with the TurboFan compiler. Refactor the test to use an
inner function that can be correctly optimized by TurboFan and
Crankshaft.
I think this change also makes the benchmarks generally better. I will optimize the run function instead of the whole main that is run only once anyway.

Refs: #11851 (comment)

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

benchmark

Something unidentified at the moment is causing the arrays benchmarks to
deopt when run with the TurboFan compiler. Refactor the test to use an
inner function that can be correctly optimized by TurboFan and
Crankshaft.

Refs: nodejs#11851 (comment)
@targos targos added benchmark Issues and PRs related to the benchmark subsystem. v8 engine Issues and PRs related to the V8 dependency. labels Mar 17, 2017
@nodejs-github-bot nodejs-github-bot added the benchmark Issues and PRs related to the benchmark subsystem. label Mar 17, 2017
@targos
Copy link
Member Author

targos commented Mar 17, 2017

There are other benchmarks with the same issue. For example https://github.com/nodejs/node/blob/master/benchmark/assert/deepequal-prims-and-objs-big-array.js#L36. This one is optimized I think during the loop to initialize the arrays. Then it deopts when it reaches conf.method (or bench.start() if I move the lookup to the top).

@jasnell jasnell requested a review from mscdex March 22, 2017 06:21
@mscdex
Copy link
Contributor

mscdex commented Mar 22, 2017

If we backport these changes, we'd want to make sure that run() is inlined since older branches probably still might use Crankshaft for those functions?

@jasnell
Copy link
Member

jasnell commented Mar 27, 2017

Ping @mscdex ... is that an objection to landing this or does it LGTY?

@mscdex
Copy link
Contributor

mscdex commented Mar 27, 2017

I'm +0 really, the functions don't get compiled by TurboFan currently (tested with node v6.x, master with V8 5.6 and 5.7) unless forced via V8 command line options. I would guess that this is because the V8 team knows about such deopts and has not enabled TurboFan for those situations.

@targos
Copy link
Member Author

targos commented Mar 29, 2017

I'm not sure we necessarily want the run() function to be inlined. The goal of this change is to make the benchmark fair between TurboFan and Crankshaft. I tried to run it with both compilers and I think none inlined it (used --trace-inlining, is that correct?)

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

awesome work.
LGTM

@targos
Copy link
Member Author

targos commented Apr 4, 2017

A linter run is enough, right?
CI: https://ci.nodejs.org/job/node-test-linter/8005/

jasnell pushed a commit that referenced this pull request Apr 4, 2017
Something unidentified at the moment is causing the arrays benchmarks to
deopt when run with the TurboFan compiler. Refactor the test to use an
inner function that can be correctly optimized by TurboFan and
Crankshaft.

PR-URL: #11894
Ref: #11851 (comment)
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@jasnell
Copy link
Member

jasnell commented Apr 4, 2017

Landed in eefdf45

@jasnell jasnell closed this Apr 4, 2017
@targos targos deleted the benchmark-arrays-no-deopt branch April 4, 2017 19:36
@jasnell jasnell mentioned this pull request Apr 4, 2017
italoacasas pushed a commit to italoacasas/node that referenced this pull request Apr 10, 2017
Something unidentified at the moment is causing the arrays benchmarks to
deopt when run with the TurboFan compiler. Refactor the test to use an
inner function that can be correctly optimized by TurboFan and
Crankshaft.

PR-URL: nodejs#11894
Ref: nodejs#11851 (comment)
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@italoacasas italoacasas mentioned this pull request Apr 10, 2017
2 tasks
@MylesBorins
Copy link
Contributor

assuming we don't need to backport this to v6. thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
benchmark Issues and PRs related to the benchmark subsystem. v8 engine Issues and PRs related to the V8 dependency.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants