Kristián Filo
Kristián Filo

Reputation: 865

Chrome JS Profiler and "Not Optimized: Inlining Bailed Out" warnings

I have tried to run my app with the Chrome JS Profiler recording the CPU usage, and I've got a few warnings, ther were some "ForInStatement is not fast case", which I have fixed, but I am getting the "Inlining Bailed Out" warnings, for example in this code:

function display_loader(){
  for(i in obstacles){
    display(obstacles[i])
  }
}

This function basically creates an obstacles (display(obstacles[i]) draws a specific image of an obstacle - two separate functions for loading and for the code because of the "ForInStatement" warnings mentioned above).

The message "Inlining Bailed Out" appears randomly, especially when I play more than a minute, and it appears in either move_loader, display_loader or collision_loader functions. Sometimes does, sometimes doesn't.

Can you give me any word-explanation of ´what this message really means? I've read a lot of threads over the web and I understand the "ForInStatement" logic, but I have no clue about the Inlining Bailed Out.

Also, can you give me a hint of how I fix it?

Thank you!

Upvotes: 3

Views: 503

Answers (1)

Derlin
Derlin

Reputation: 9881

Normally, bailout means that the function could not be optimized. This can come from unsupported JS features like try/catch blocks, for of, etc. or because the optimization process hit certain limitations.

As the docs sums up:

Not all functions can be optimized. Some features prevent the optimizing compiler from running on a given function (a “bail-out”)

This article series gives some good explanations. Basically, the Inlining is crucial for good performance. But functions are not systematically inlined, since it has a cost. Normally, only functions called many times are picked up for inlining.

So in your case, I guess there is something in your display function that prevents optimization. The message does not pop up directly because the function is not always/directly picked for optimization:

One consequence of this optimization approach is that short-running programs [...] don't exit their warm-up phase and don't get optimized. In general it is not necessary to waste energy to optimize something that is only run for a very short time.

Furthermore, note that V8 uses a non-deterministic sampling profiler to detect hot functions. Performance can therefore vary wildly depending on which function is active during the profiling ticks.

Further reading here. Hope this helps.

Upvotes: 1

Related Questions