Anyone on here familiar with speculative optimizations in #V8 / #Chrome? I'm trying to test how two JS patterns compare and following this (excellent) breakdown:
https://ponyfoo.com/articles/an-introduction-to-speculative-optimization-in-v8
I have a local build of #d8, but unfortunately I'm not able to reproduce their output, even for the trivial `add` examples. `%DebugPrint` doesn't seem to be tracking the feedback vector as I only see:
> - feedback vector: No feedback vector, but we have a closure feedback cell array
0x197300001fd5: [ClosureFeedbackCellArray] in ReadOnlySpace
`--trace-deopt` also doesn't print anything when following the exact example in the blog post.
Do I need to build d8 with special flags or something? Is there something else I need to do?
@develwithoutacause For me it works just fine. When I run it with
$ d8 test.js --allow-natives-syntax --trace-deopt
I get both the %DebugPrint output with a feedback vector and the deopt trace.
The loop is needed as afaik feedback vectors are only allocated after a few executions.
@mliedtke Interesting, the blog post doesn't include a loop in those examples. I didn't try that in my initial attempt. I can give that another try with a loop and see if it shows up.
@develwithoutacause I just checked the flags and if you call d8 with --no-lazy-feedback-allocation it is enough to call the add function twice before %OptimizeOnNextCall to reach the same situation that it optimizes for an addition of two smis and then deopts when being called with two doubles.
Lazy feedback allocation apparently landed in 2019, so it makes sense that it isn't part of the blog post.
@mliedtke Ah interesting, that makes sense. Thank you so much for looking into this! I don't think I would have figured that out on my own.