PHPC-2337: Fix performance regression due to trace logging #1504
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.
PHPC-2337
Fixes #1501.
This adds a call to
mongoc_log_trace_disable()
in the extension'sMINIT
function. Since we always compile with trace-level logging (which is emitted when themongodb.debug
setting is enabled), libmongoc starts out with trace logging enabled. While we disable trace logging inphongo_log_sync_handlers()
, this function is not called ifmongodb.debug
is not set, thus leaving trace logging enabled and causing significant overhead due to message preparation.Now, trace logging starts out as disabled and will be enabled when
phongo_log_sync_handlers()
is called, either due to adding a log subscriber to a manager or due to the INI setting being enabled and us storing a file handle the debug log gets written to.I've confirmed that the performance increases again - a bulk write that took 1.9 seconds without the change now completes in 0.02 seconds. However, due to the difficulty of measuring the performance in CI systems, I did not add the test. We will manually verify the improvements by observing the results of the performance test suite contained in PHPLIB.