Hi Rafael, It's not easy to analyze optimizations with turbolizer, it's intended more as a compiler developer tool than an end-user tool. Even if you did, you might be disappointed if the current benchmark is fine and nothing is eliminated right now, but a future iteration of Turbofan/shaft ends up eliminating that loop because of some new analysis. In particular, if we were to detect that structuredClone has no side-effects, we could theoretically collapse your loop to just execute the last iteration.
You're probably better off using some intrinsics (--allow-natives-syntax) to ensure that the object escapes, and make sure that it escapes on each iteration (and then maybe compare that against a loop that does nothing). For example, you could write function DoNotOptimize(x) {} // Prevent DoNotOptimize from optimizing or being inlined. %NeverOptimize(DoNotOptimize); ... for (let i = 0; i < n; ++i) > DoNotOptimize(structuredClone(blob)); > This would be similar to DoNotOptimize in the google C++ benchmarking library <https://github.com/google/benchmark/blob/main/docs/user_guide.md#:~:text=DoNotOptimize(%3Cexpr%3E)%20forces%20the%20result%20of%20%3Cexpr%3E%20to%20be%20stored%20in%20either%20memory%20or%20a%20register.> . - Leszek On Tue, Sep 3, 2024 at 11:24 PM Rafael Gonzaga <w...@rafaelgss.dev> wrote: > Hi folks! > > I'm member of Node.js team and I'm conducting a research on our benchmark > suite (https://github.com/nodejs/node/tree/main/benchmark). > > In our benchmarks, we attempt to avoid the measured block from being > eliminated by V8 dead-code elimination by making use of a state and > checking the state after the benchmark run. Example: > https://github.com/nodejs/node/blob/main/benchmark/blob/clone.js#L24 > > However, this is an assumption, we do not check if the measured block is > being eliminated so, the benchmark result will be noop or we are measuring > it correctly. I tried to run the benchmark with --trace-turbo and analyzing > it with tools/turbolizer, but I couldn't find a way to identify which > blocks were removed. > > Is there a way to do that? I understand that usually micro-benchmarks are > far from reliable, but at the moment I don't see how we could make it more > sophisticated and specific. > > Thanks in advance > > -- > -- > v8-dev mailing list > v8-dev@googlegroups.com > http://groups.google.com/group/v8-dev > --- > You received this message because you are subscribed to the Google Groups > "v8-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to v8-dev+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/v8-dev/4e060cb2-477c-4037-876a-bd2f5aab245fn%40googlegroups.com > <https://groups.google.com/d/msgid/v8-dev/4e060cb2-477c-4037-876a-bd2f5aab245fn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- -- v8-dev mailing list v8-dev@googlegroups.com http://groups.google.com/group/v8-dev --- You received this message because you are subscribed to the Google Groups "v8-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/CAGRskv-A1NHQb91c2SmsL7R74W3Bo4KFYOW%2BpHtwKqnx6kXCNA%40mail.gmail.com.