Repository navigation
perf: stop the profiler at init for visitors who cannot see its output - #148
Merged
Merged
Conversation
The query argument started the profiler for every visitor. Switch it off at init, once the current user is known, when the output would be discarded.
Contributor
|
Included in Blockstudio 7.7.6, now officially released. This PR is merged into main as part of the reviewed release, with full CI and distribution checks passing for the release commit. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
?blockstudio-perf(or thedev/perfsetting) turns on the profiler for every visitor, and output is only gated later incan_finalize()(includes/classes/perf.php). Anonymous visitors on a public site still pay for every timer and track call on the page, and the data is then thrown away.Perf::init()runs while plugins load, before pluggable functions exist, so the user cannot be checked there.The fix keeps the early start, so the total timing is unchanged. It adds
Perf::maybe_deactivate()oninitat the earliest priority, where WordPress has just set the current user and before Blockstudio's build and render phases run. If the request may not receive the output under the existingcan_finalize()rules, the profiler switches off and drops what it has. Editors and anonymous local probes behave exactly as before.Measured on a page with nine blocks: an anonymous remote request with the query argument went from 40 recorded track calls in 14 groups to none. Editor output, including the total, is unchanged. This is mostly hygiene, the saved work per request is small.
Test:
PerfTest::test_query_probe_stops_at_init_for_visitors_who_cannot_receive_output(anonymous remote, anonymous local, editor remote).