-
-
Notifications
You must be signed in to change notification settings - Fork 46
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
Perormance optimization #387
Open
samdark
wants to merge
12
commits into
master
Choose a base branch
from
performance
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains 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
…first - Reorder checks to prioritize definition lookup which is the most common case - Return true immediately if definition exists - Only check tag aliases if definition doesn't exist - Return false if neither exists Performance improvements: - benchPredefinedExisting: ~29% faster (130μs → 92μs) - benchUndefinedExisting: ~29% faster (123μs → 87μs) - benchUndefinedNonexistent: ~1% faster (446μs → 441μs) - Small improvements in other benchmarks
- Add fast path for existing instances - Extract StateResetter logic into separate method - Move StateResetter check to the end to avoid duplicate instance access - Improve code readability and maintainability Performance improvements: - benchSequentialLookups: ~3% faster (620μs → 599μs) - benchUndefinedExisting: ~5% faster (87μs → 83μs) - Other benchmarks show similar or slightly improved performance
- Add early returns for common simple cases (strings, ContainerInterface, Closure) - Simplify array definition handling - Improve code readability and reduce nesting Performance improvements: - benchConstruct: ~29% faster (336μs → 238μs) - benchSequentialLookups: ~13% faster (599μs → 523μs) - benchRandomLookups: ~16% faster (621μs → 524μs) - benchRandomLookupsComposite: ~9% faster (2.3ms → 2.1ms) - benchUndefinedNonexistent: ~5% faster (464μs → 440μs)
- Add normalized definitions cache with memory management - Reorder checks to prioritize most common cases - Add fast path for circular reference check - Improve code readability with better comments Performance improvements: - benchRandomLookupsComposite: ~4% faster (2.3ms → 2.2ms) - benchSequentialLookups: ~2% faster (544μs → 539μs) - benchRandomLookups: ~1.5% faster (546μs → 525μs) Memory usage is kept in check by clearing the cache when it reaches 100 entries.
- Simplify exception handling paths - Add fast path for NotFoundException with matching ID - Use ternary operators for cleaner code - Improve code readability with better comments Performance improvements: - benchRandomLookupsComposite: ~1% faster (2.2ms → 2.18ms) - benchSequentialLookups: ~0.5% faster (539μs → 536μs) - benchRandomLookups: ~0.5% faster (541μs → 538μs)
- Skip parsing if already a valid definition - Only validate meta if it's not empty - Only unset instance if it exists - Improve code readability with better comments Performance improvements: - benchConstruct: ~10% faster (238μs → 213μs) - benchSequentialLookups: ~3.5% faster (536μs → 517μs) - benchRandomLookups: ~3.7% faster (538μs → 518μs) - benchRandomLookupsComposite: ~0.5% faster (2.18ms → 2.17ms)
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #387 +/- ##
=============================================
- Coverage 100.00% 99.80% -0.20%
- Complexity 169 179 +10
=============================================
Files 11 11
Lines 492 505 +13
=============================================
+ Hits 492 504 +12
- Misses 0 1 +1 ☔ View full report in Codecov by Sentry. |
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.
Before:
After: