Skip to content

Conversation

@nornagon
Copy link

@nornagon nornagon commented Jan 9, 2024

Discussions with @acomminos lead me to believe that the Document-Policy header requirement is superfluous and we can instead launch the profiler lazily when the first new Profiler is created.

Currently, the requirement to enable js-profiling with the Document-Policy header forces authors to decide whether JS profiling will be available on the server side at page load time, which has several downsides:

  1. The server may not have information about whether profiling will be needed in the client at page load time. The header could be attached unconditionally, but this forces the browser to do extra work to collect profiling information even though it won't be used.
  2. Pages served from file:// or through some CDNs cannot have this header attached, making it impossible to use the self-profiling API on these pages.

The header was initially introduced because of a mistaken belief that launching the profiler before pageload would result in a faster profiler startup time because the JS heap would be empty to begin with, and profiling metadata collection could be amortized as functions were parsed and added to the heap. This is true for some initial page loads, but if Chromium has a code cache for a page (i.e. if it's not a first-load), that cache will be loaded into the heap before the profiler begins, which is just as much work as if the profiler were started later, so this benefit is questionable. The cost of this initial load was missed at design time because it happens very early in page load (before any JS runs!) and so was difficult to measure.


Preview | Diff

@thomasbertet
Copy link
Contributor

Hi @nornagon! What would be the status of this update ? Can we still expect to remove this header in a ~near future ?

Is there anything blocking us from removing the header requirement ?

(Curious because it indeed creates a bit of friction for wide adoption and it seems there is no good reason to keep it around)

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants