-
Notifications
You must be signed in to change notification settings - Fork 4.6k
⚡️ Speed up method AirbyteLogFormatter.format
by 13% in PR #44444 (artem1205/airbyte-cdk-protocol-dataclasses-serpyco-rs
)
#44942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
…dk-protocol-dataclasses # Conflicts: # airbyte-cdk/python/poetry.lock
Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
[skip ci] Signed-off-by: Artem Inzhyyants <[email protected]>
[skip ci] Signed-off-by: Artem Inzhyyants <[email protected]>
[skip ci] Signed-off-by: Artem Inzhyyants <[email protected]>
[skip ci] Signed-off-by: Artem Inzhyyants <[email protected]>
[skip ci] Signed-off-by: Artem Inzhyyants <[email protected]>
[skip ci] Signed-off-by: Artem Inzhyyants <[email protected]>
…205/airbyte-cdk-protocol-dataclasses-serpyco-rs # Conflicts: # airbyte-cdk/python/airbyte_cdk/sources/connector_state_manager.py # airbyte-cdk/python/unit_tests/sources/file_based/stream/concurrent/test_file_based_concurrent_cursor.py # airbyte-cdk/python/unit_tests/sources/test_abstract_source.py # airbyte-cdk/python/unit_tests/sources/test_connector_state_manager.py
[skip ci] Signed-off-by: Artem Inzhyyants <[email protected]>
[skip ci] Signed-off-by: Artem Inzhyyants <[email protected]>
[skip ci] Signed-off-by: Artem Inzhyyants <[email protected]>
[skip ci] Signed-off-by: Artem Inzhyyants <[email protected]>
[skip ci] Signed-off-by: Artem Inzhyyants <[email protected]>
[skip ci] Signed-off-by: Artem Inzhyyants <[email protected]>
[skip ci] Signed-off-by: Artem Inzhyyants <[email protected]>
[skip ci] Signed-off-by: Artem Inzhyyants <[email protected]>
[skip ci] Signed-off-by: Artem Inzhyyants <[email protected]>
[skip ci] Signed-off-by: Artem Inzhyyants <[email protected]>
[skip ci] Signed-off-by: Artem Inzhyyants <[email protected]>
[skip ci] Signed-off-by: Artem Inzhyyants <[email protected]>
[skip ci] Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
…dk-protocol-dataclasses-serpyco-rs # Conflicts: # airbyte-cdk/python/poetry.lock # airbyte-cdk/python/unit_tests/sources/streams/http/error_handlers/test_json_error_message_parser.py
Signed-off-by: Artem Inzhyyants <[email protected]>
Signed-off-by: Artem Inzhyyants <[email protected]>
…`artem1205/airbyte-cdk-protocol-dataclasses-serpyco-rs`) To optimize the given Python program, we'll focus on reducing redundancy, unnecessary object creations, and repetitive computations. 1. **Avoid Redundant Imports:** Ensure to import only necessary modules and classes. 2. **Optimize `filter_secrets`:** Use `str.replace` in a more efficient loop. 3. **Optimize `AirbyteLogFormatter.format`:** Avoid redundant computations and direct return strings where possible. Below is the optimized code. ### Changes and Optimizations. 1. **Consolidated Imports:** Removed redundant and unused imports, keeping the necessary ones. 2. **Enhanced `extract_extra_args_from_record`:** Initialized `default_attrs` once in the constructor to avoid recalculating it for each log record. 3. **Direct Use `base_filter_secrets`:** Refactored to directly use the `base_filter_secrets` function. 4. **Use Efficient JSON Libraries:** Continued the use of `orjson` for JSON serialization for performance efficiency.
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
|
|
⚡️ This pull request contains optimizations for PR #44444
If you approve this dependent PR, these changes will be merged into the original PR branch
artem1205/airbyte-cdk-protocol-dataclasses-serpyco-rs
.📄
AirbyteLogFormatter.format()
inairbyte-cdk/python/airbyte_cdk/logger.py
📈 Performance improved by
13%
(0.13x
faster)⏱️ Runtime went down from
42.9 microseconds
to37.9 microseconds
Explanation and details
To optimize the given Python program, we'll focus on reducing redundancy, unnecessary object creations, and repetitive computations.
filter_secrets
: Usestr.replace
in a more efficient loop.AirbyteLogFormatter.format
: Avoid redundant computations and direct return strings where possible.Below is the optimized code.
Changes and Optimizations.
extract_extra_args_from_record
: Initializeddefault_attrs
once in the constructor to avoid recalculating it for each log record.base_filter_secrets
: Refactored to directly use thebase_filter_secrets
function.orjson
for JSON serialization for performance efficiency.Correctness verification
The new optimized code was tested for correctness. The results are listed below.
✅ 3 Passed − ⚙️ Existing Unit Tests
(click to show existing tests)
✅ 0 Passed − 🌀 Generated Regression Tests
(click to show generated tests)
🔘 (none found) − ⏪ Replay Tests