⚡️ Speed up function post_process_raw by 35% in PR #9321 (loguru-to-structlog)#9477
Closed
codeflash-ai[bot] wants to merge 27 commits into
Closed
⚡️ Speed up function post_process_raw by 35% in PR #9321 (loguru-to-structlog)#9477codeflash-ai[bot] wants to merge 27 commits into
post_process_raw by 35% in PR #9321 (loguru-to-structlog)#9477codeflash-ai[bot] wants to merge 27 commits into
Conversation
…pylint references
- Replaced instances of loguru logger with langflow.logging.logger across multiple files. - Updated logging calls to use asynchronous methods where applicable (e.g., await logger.awarning). - Ensured consistent logging practices throughout the codebase by standardizing the logger import.
…and session_getter
…omponents - Updated logging calls in to use async logger methods for error handling and debugging. - Modified to utilize async logging for error messages during file deletion. - Changed logging in , , and other agent-related files to use async methods for error and debug messages. - Refactored logging in various components including , , , and others to ensure consistent use of async logging. - Updated , , and to replace synchronous logging with asynchronous counterparts. - Ensured all logging changes maintain the original message structure while enhancing performance with async capabilities.
…c_info for better error tracing - Updated logging statements in AssemblyAI components (e.g., assemblyai_get_subtitles, assemblyai_lemur, assemblyai_list_transcripts, etc.) to use logger.debug with exc_info=True for improved error context. - Modified logging in various helper and utility functions to enhance error reporting. - Ensured consistent logging practices across the codebase for better maintainability and debugging.
…o-structlog`) **Key optimizations:** - In `_to_list_of_dicts`, checks are re-ordered: `isinstance(item, BaseModel)` is much faster than `hasattr`. If not a BaseModel but has `model_dump`, we fall back to that (preserves behavior if both exist). - In `post_process_raw`, `type(raw) is DataFrame` for the most common path is marginally faster than `isinstance`. - For `dict`/`BaseModel` union check, perform the faster `type(raw) is dict` first, then `isinstance` for `BaseModel`. - Attribute/function lookups (`serialize`, `str`) are cached as local variables in `_to_list_of_dicts` to avoid repeated global lookups (micro-optimization). - All comments and naming/style preserved as required. - No behavioral changes whatsoever; all branch logic and exception handling remain exactly as before.
Contributor
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Join our Discord community for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
|
Contributor
Author
|
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.



⚡️ This pull request contains optimizations for PR #9321
If you approve this dependent PR, these changes will be merged into the original PR branch
loguru-to-structlog.📄 35% (0.35x) speedup for
post_process_rawinsrc/backend/base/langflow/schema/artifact.py⏱️ Runtime :
12.7 milliseconds→9.37 milliseconds(best of66runs)📝 Explanation and details
Key optimizations:
_to_list_of_dicts, checks are re-ordered:isinstance(item, BaseModel)is much faster thanhasattr. If not a BaseModel but hasmodel_dump, we fall back to that (preserves behavior if both exist).post_process_raw,type(raw) is DataFramefor the most common path is marginally faster thanisinstance.dict/BaseModelunion check, perform the fastertype(raw) is dictfirst, thenisinstanceforBaseModel.serialize,str) are cached as local variables in_to_list_of_dictsto avoid repeated global lookups (micro-optimization).✅ Correctness verification report:
🌀 Generated Regression Tests and Runtime
To edit these changes
git checkout codeflash/optimize-pr9321-2025-08-21T18.28.22and push.