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

Remove Document-Policy header requirement #80

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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

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.

1 participant