perf(loggly): hoist per-request closure out of log phase#13648
Open
shreemaan-abhishek wants to merge 1 commit into
Open
perf(loggly): hoist per-request closure out of log phase#13648shreemaan-abhishek wants to merge 1 commit into
shreemaan-abhishek wants to merge 1 commit into
Conversation
The log phase reassigned the handle_http_payload closure on every request just to capture conf, allocating a new function object per request and adding GC pressure. Thread conf into handle_log directly and build the batch-processor handler once per config version instead of per request. This also removes a latent bug where the shared module-level closure could resolve the wrong conf when multiple routes use different loggly configs.
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.
Description
The
logglylogger reassigned thehandle_http_payloadclosure on every request inside_M.log(), solely to captureconf. Each request therefore allocated a fresh function object, adding avoidable GC pressure in the log phase. Benchmarking loggers showedlogglycarrying a disproportionately high per-request overhead compared to peers in the same class, and this per-request allocation was the cause (P50 is unaffected since the actual send happens in the async batch-processor timer).This PR hoists the handler to module scope:
confis threaded intohandle_log(entries, conf)directly, and the small binding closure is created once per batch processor (i.e. once per config version) rather than once per request. The separatehandle_http_payloadindirection is removed.As a side effect this also removes a latent correctness bug: the shared module-level
handle_http_payloadwas overwritten by whichever request ran_M.log()last, so with two routes using different loggly configs the async handler could send a batch with the wrongconf. Bindingconfper processor fixes that.Behavior is otherwise unchanged; existing
t/plugin/loggly.tcases (including TEST 15, the http bulk path that assertsconf.tags) continue to cover both the syslog and http paths.Which issue(s) this PR fixes:
Fixes #
Checklist