perf(forwarder): compile multiline regex patterns once at module level#1078
Merged
Conversation
DD_MULTILINE_LOG_REGEX_PATTERN was compiled into 2 regex objects on every S3EventHandler instantiation. For SQS batches with ~10 records, that is 20 redundant re.compile calls per invocation. Move the two compilations to module-level constants and assign the pre-compiled references in __init__. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
CI's black version requires 1 blank line (not 2) between the import block and module-level variable assignments. Two blank lines are reserved for class and function definitions. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
ViBiOh
approved these changes
Mar 17, 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.
Summary
DD_MULTILINE_LOG_REGEX_PATTERNwas compiled into 2 regex objects on everyS3EventHandlerinstantiationre.compilecalls per invocation_MULTILINE_REGEX_START_PATTERN,_MULTILINE_REGEX_PATTERN) and assign the pre-compiled references in__init__Test plan
test_s3_handler.pytests pass (tests set instance attributes directly, so they are unaffected)🤖 Generated with Claude Code