perf(logs): remove LogEvent ingest wrapper allocations - #3766
Closed
djwhitt wants to merge 2 commits into
Closed
Conversation
This was referenced Aug 3, 2026
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.
Note
Removed from the stack: the isolated benchmark showed only a noisy 2.4% geometric-mean throughput change with approximately neutral memory, which did not justify carrying this additional mapper/validator refactor. The remaining stack continues with #3765 → #3767 → #3768 → #3769.
Summary
{body, timestamp_inferred}directly from the ingest mapper instead of allocating an intermediate envelope map.timestamp_inferredkey from the database mapper result.This is part 2 of 5 in the stack replacing #3760.
Rationale
The ingest mapper previously returned a three-key envelope containing
body,id, andtimestamp_inferred.LogEvent.make/2immediately destructured that envelope, even though the ID was already present in the mapped body. Returning{body, timestamp_inferred}removes that short-lived map from every ingest operation.The database reconstruction path still returns the map required by its Ecto changeset, but both paths now share mapper-field insertion and message normalization. Its unused top-level
timestamp_inferredkey is omitted. Validation also calls the sole active validator directly instead of traversing a one-element module list and creating reducer control tuples. The valid-event function contract and validation error shape remain unchanged.Incremental benchmark
This comparison isolates this PR from its stack parent, #3765:
f60b8258(perf/logevent-clean-payload-reuse)9422950b(perf/logevent-ingest-wrappers)Across all 12 scenarios, geometric-mean throughput improved 2.4%. Individual throughput results ranged from 3.0% lower to 14.5% higher; median latency was unchanged to 5.5% lower. Per-operation memory was approximately neutral (-2.4% to +2.6%) and reductions were unchanged to 1.3% lower. These incremental effects are modest and some throughput results are within run-to-run noise; the main value is removing unnecessary hot-path data structures while simplifying the mapper and validator flow.
These measurements isolate
LogEvent.make/2; they do not represent end-to-end ingestion throughput.Stack
Validation
../bin/test test/logflare/log_event_test.exs test/logflare/validator/bq_schema_change_validator_test.exsMIX_ENV=test ../bin/x mix format --check-formattedMIX_ENV=test ../bin/x mix compile --warnings-as-errorsMIX_ENV=test ../bin/x mix lint.all