-
Notifications
You must be signed in to change notification settings - Fork 2
perf: optimize env file operations for 112x speedup #23
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
Closed
vilsonrodrigues
wants to merge
10
commits into
msgflux:main
from
vilsonrodrigues:perf/optimize-env-file-check-v2
Closed
perf: optimize env file operations for 112x speedup #23
vilsonrodrigues
wants to merge
10
commits into
msgflux:main
from
vilsonrodrigues:perf/optimize-env-file-check-v2
Conversation
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
- Complete project structure overview - Common commands and workflows - Release process (always use ./scripts/release.sh) - Architecture details and optimizations - Linting, testing, and CI/CD guides - Troubleshooting tips This file provides context for Claude Code to work more effectively with the project without repeating instructions.
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
* docs: Add CLAUDE.md with project guidelines - Complete project structure overview - Common commands and workflows - Release process (always use ./scripts/release.sh) - Architecture details and optimizations - Linting, testing, and CI/CD guides - Troubleshooting tips This file provides context for Claude Code to work more effectively with the project without repeating instructions. * Add CHANGELOG.md for release tracking 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * RELEASE: v0.2.0 This release updates: - version.py: 0.1.0 → 0.2.0 - CHANGELOG.md: Added release section for v0.2.0 After merging this PR: - publish.yml workflow will trigger automatically - Package will be built and published to PyPI - GitHub release will be created with tag v0.2.0 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
…heckout (msgflux#19) * docs: Add CLAUDE.md with project guidelines - Complete project structure overview - Common commands and workflows - Release process (always use ./scripts/release.sh) - Architecture details and optimizations - Linting, testing, and CI/CD guides - Troubleshooting tips This file provides context for Claude Code to work more effectively with the project without repeating instructions. * Add CHANGELOG.md for release tracking 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: optimize env parser latency with advanced caching - Add field name to env name mapping cache for faster lookups - Add absolute path cache to avoid repeated pathlib operations - Add type introspection cache for complex types (Union/Optional) - Optimize _preprocess_env_value with fast paths for primitive types - Optimize _get_env_name with fast path for no transformations - Optimize _decode_from_dict with atomic encoder/decoder cache - Add comprehensive benchmark suite with cold vs warm analysis - Move profile_settings.py to benchmark/ directory - All tests passing (22/22) and lint/format checks clean Performance improvements: - Main benchmark: 0.023ms per load (excellent consistency) - Cold start: 1.489ms (1.3x faster than pydantic) - Warm cached: 0.011ms (117.5x faster than pydantic) - 129.6x speedup from cold to warm caching * docs: update README with new performance metrics and optimizations - Update benchmark results: 0.023ms per load (down from 2.271ms) - Add cold vs warm performance comparison: 117.5x faster when cached - Document advanced caching strategies implemented - Update comparison table with new performance metrics - Reflect 129.6x internal speedup from cold to warm caching * fix: improve mergebot update command with better error handling and fork support - Add branch existence validation before attempting checkout - Add proper handling for PRs from forks with clear messaging - Add detailed error messages for branch deletion, permission issues - Add branch comparison logic to check if update is actually needed - Add comprehensive debug logging for troubleshooting - Handle edge cases where branch was deleted after merge - Provide helpful instructions for manual updates when automation fails * fix: improve mergebot /update command with better fork handling and checkout This commit fixes several issues with the `/update` command in the mergebot workflow: **Problems fixed:** 1. Checkout was trying to fetch branch from base repo instead of head repo 2. Branch comparison used incorrect reference format for same-repo PRs 3. Fork validation happened too late, causing unnecessary operations **Changes:** - Add early exit for fork PRs in "Get PR info" step with clear error message - Specify repository parameter in checkout action to fetch from correct repo - Simplify branch comparison to use simple branch reference for same-repo PRs - Update validation conditions to skip unnecessary steps for fork PRs - Remove redundant "Handle fork PR" step (now handled earlier) - Add better logging for debugging **Benefits:** - Fork PRs now get immediate, clear feedback that update is not supported - Same-repo PRs can now be updated correctly without checkout errors - Better performance by skipping unnecessary operations for forks - Cleaner code flow and easier maintenance 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
Fix template literal interpolation issue by extracting pr.base.ref to
a local variable before using it in the comment body. This prevents
YAML parsing errors with the GitHub Actions workflow.
The issue occurs when GitHub Actions tries to parse the workflow file
and encounters ${pr.base.ref} inside a JavaScript template literal,
which can be confused with GitHub Actions variable interpolation syntax.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Replace all problematic template literals with backticks inside YAML with
array-based string construction using .join('\n'). This prevents YAML parser
errors when GitHub Actions tries to validate the workflow file.
Changes:
- Fork PR message: Use array of strings instead of multiline template literal
- Success message: Extract to variable to avoid inline template complexity
- Failure message: Use array of strings for code block formatting
This approach avoids:
- Escaped backticks in YAML (\`\`\`)
- Complex template literals inside YAML string literals
- YAML scanner errors with 'could not find expected :'
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Performance optimizations: - Replace Path().absolute() with os.path.abspath() (2x faster) - Replace Path.exists() with os.path.exists() (3.5x faster) - Add fast return on cache hit to avoid unnecessary checks - Remove pathlib import (no longer needed) Results: - First load: 1.818ms (1.5x faster than pydantic-settings) - Cached loads: 0.016ms (112x faster than pydantic-settings) - All 22 tests passing ✅ README improvements: - Show first-time load numbers first (what users will see when testing) - Add separate section for cached performance with clear context - Merge redundant sections into clear "Why Choose msgspec-ext?" - Add practical use cases for each performance scenario - Explain caching benefits in accessible language 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
fca70a4 to
68b0785
Compare
Contributor
Author
|
Closing this PR due to merge conflicts. Recreating with a clean branch in a new PR. |
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
Optimizes environment file check operations by replacing slower pathlib operations with faster os.path equivalents, resulting in massive performance improvements.
Performance Improvements
First-time load:
Cached loads (repeated loads in long-running apps):
Changes
Code Optimizations
Path().absolute()withos.path.abspath()(2x faster)Path.exists()withos.path.exists()(3.5x faster)README Improvements
Testing
Related
This PR focuses specifically on optimizing the env file check operations. A separate investigation into MessagePack vs JSON (branch
perf/investigate-msgpack-vs-json) concluded that MessagePack doesn't provide real-world benefits for this use case.