-
-
Notifications
You must be signed in to change notification settings - Fork 94
Performance optimisations #481
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
base: dev
Are you sure you want to change the base?
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||
Test Results 51 files + 34 51 suites +34 32m 55s ⏱️ + 22m 6s Results for commit 32f4d9d. ± Comparison against base commit 2f9d974. This pull request removes 5 and adds 15 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Co-authored-by: qodo-merge-for-open-source[bot] <189517486+qodo-merge-for-open-source[bot]@users.noreply.github.com>
|
😔 An error occurred while trying to generate Jira ticket requirements. |
User description
PR Type
Enhancement, Tests, Documentation
Description
HandlingResultswith single-field pattern (158x faster for single results)ContextItemsdictionary (104 bytes saved per message)DictionarywithKeyValuePairarray (5x faster, 3x less allocation)CancellationTokenSourcecreation with guards to avoid unnecessary linked tokensT[]toIReadOnlyList<T>to avoid array allocationsImplementedOptimizationsValidationBenchmarks- validates all implemented optimizationsOptimizationComparisonBenchmarks- compares current vs optimized implementationsContextAllocationBenchmarks- measures context creation overheadAllocationHotspotsBenchmarks- identifies common allocation patternsChannelBatchingBenchmarks- compares 6 batching approachesCheckpointBenchmarks,FilterPipelineBenchmarks,SubscriptionMessageProcessingBenchmarksPERFORMANCE_ANALYSIS.md- documents 13 identified issues with severity levelsVALIDATION_REPORT.md- confirms implementation of P0/P1 optimizationsBENCHMARK_RESULTS_SUMMARY.md- executive summary with priority matrixREADME.md- benchmarks suite documentation and usage guideCommitPositionSequenceto use modern C# tuple syntaxDiagram Walkthrough
File Walkthrough
22 files
ImplementedOptimizationsValidationBenchmarks.cs
Benchmark validation for implemented performance optimizationssrc/Benchmarks/Benchmarks/ImplementedOptimizationsValidationBenchmarks.cs
implemented optimizations
(after changes)
CancellationTokenSource optimizations
OptimizationComparisonBenchmarks.cs
Optimization comparison benchmarks for P0 itemssrc/Benchmarks/Benchmarks/OptimizationComparisonBenchmarks.cs
single-result optimization
ContextAllocationBenchmarks.cs
Context allocation overhead benchmarkssrc/Benchmarks/Benchmarks/ContextAllocationBenchmarks.cs
HandlingResults
message processing simulation
AllocationHotspotsBenchmarks.cs
Allocation hotspots and string operation benchmarkssrc/Benchmarks/Benchmarks/AllocationHotspotsBenchmarks.cs
CancellationTokenSource creation
StringBuilder)
FilterPipelineBenchmarks.cs
Filter pipeline processing benchmarkssrc/Benchmarks/Benchmarks/FilterPipelineBenchmarks.cs
CheckpointBenchmarks.cs
Checkpoint commit operation benchmarkssrc/Benchmarks/Benchmarks/CheckpointBenchmarks.cs
SubscriptionMessageProcessingBenchmarks.cs
Subscription message processing throughput benchmarkssrc/Benchmarks/Benchmarks/SubscriptionMessageProcessingBenchmarks.cs
ChannelBatchingBenchmarks.cs
Channel batching optimization approach benchmarkssrc/Benchmarks/Benchmarks/ChannelBatchingBenchmarks.cs
other alternatives
Benchmarks.ChannelBatchingBenchmarks-report.html
Channel batching benchmark results reportsrc/Benchmarks/Benchmarks/BenchmarkDotNet.Artifacts/results/Benchmarks.ChannelBatchingBenchmarks-report.html
100)
approach
have zero allocation
Benchmarks.CheckpointBenchmarks-report-github.md
Checkpoint benchmarks results reportsrc/Benchmarks/Benchmarks/BenchmarkDotNet.Artifacts/results/Benchmarks.CheckpointBenchmarks-report-github.md
counts (10, 100)
Benchmarks.ChannelBatchingBenchmarks-report-github.md
Channel batching benchmark results reportsrc/Benchmarks/Benchmarks/BenchmarkDotNet.Artifacts/results/Benchmarks.ChannelBatchingBenchmarks-report-github.md
testing
approaches (ArrayPool, CollectionsMarshal, pre-allocated arrays)
statistics
Benchmarks.ImplementedOptimizationsValidationBenchmarks-report.html
Implemented optimizations validation benchmark reportsrc/Benchmarks/Benchmarks/BenchmarkDotNet.Artifacts/results/Benchmarks.ImplementedOptimizationsValidationBenchmarks-report.html
CancellationTokenSource optimizations
Benchmarks.AllocationHotspotsBenchmarks-report.html
Allocation hotspots benchmark analysis reportsrc/Benchmarks/Benchmarks/BenchmarkDotNet.Artifacts/results/Benchmarks.AllocationHotspotsBenchmarks-report.html
names, LINQ operations, and CancellationTokenSource
Benchmarks.ImplementedOptimizationsValidationBenchmarks-report-github.md
Implemented optimizations GitHub-formatted benchmark reportsrc/Benchmarks/Benchmarks/BenchmarkDotNet.Artifacts/results/Benchmarks.ImplementedOptimizationsValidationBenchmarks-report-github.md
HandlingResults: 725ns to 4.3ns for single result)
Benchmarks.CheckpointBenchmarks-report.html
Checkpoint benchmarks performance reportsrc/Benchmarks/Benchmarks/BenchmarkDotNet.Artifacts/results/Benchmarks.CheckpointBenchmarks-report.html
CommitPositionSequence operations
Benchmarks.ContextAllocationBenchmarks-report.html
Context allocation benchmarks performance reportsrc/Benchmarks/Benchmarks/BenchmarkDotNet.Artifacts/results/Benchmarks.ContextAllocationBenchmarks-report.html
HandlingResults, and full message processing
Benchmarks.AllocationHotspotsBenchmarks-report-github.md
Allocation hotspots GitHub-formatted benchmark reportsrc/Benchmarks/Benchmarks/BenchmarkDotNet.Artifacts/results/Benchmarks.AllocationHotspotsBenchmarks-report-github.md
reduction)
patterns
Benchmarks.OptimizationComparisonBenchmarks-report.html
Optimization comparison benchmarks reportsrc/Benchmarks/Benchmarks/BenchmarkDotNet.Artifacts/results/Benchmarks.OptimizationComparisonBenchmarks-report.html
HandlingResults
validation
Benchmarks.SubscriptionMessageProcessingBenchmarks-report-github.md
Subscription message processing GitHub-formatted benchmark reportsrc/Benchmarks/Benchmarks/BenchmarkDotNet.Artifacts/results/Benchmarks.SubscriptionMessageProcessingBenchmarks-report-github.md
processing benchmarks
Benchmarks.ContextAllocationBenchmarks-report-github.md
Context allocation GitHub-formatted benchmark reportsrc/Benchmarks/Benchmarks/BenchmarkDotNet.Artifacts/results/Benchmarks.ContextAllocationBenchmarks-report-github.md
benchmarks
processing
Benchmarks.SubscriptionMessageProcessingBenchmarks-report.html
Subscription message processing benchmark reportsrc/Benchmarks/Benchmarks/BenchmarkDotNet.Artifacts/results/Benchmarks.SubscriptionMessageProcessingBenchmarks-report.html
creation
Benchmarks.OptimizationComparisonBenchmarks-report-github.md
Optimization comparison GitHub-formatted benchmark reportsrc/Benchmarks/Benchmarks/BenchmarkDotNet.Artifacts/results/Benchmarks.OptimizationComparisonBenchmarks-report-github.md
8 files
AsyncHandlingFilter.cs
Optimize CancellationTokenSource creation with guardssrc/Core/src/Eventuous.Subscriptions/Filters/AsyncHandlingFilter.cs
unnecessary linked token sources
different
EventHandlingResult.cs
Optimize HandlingResults with single-field patternsrc/Core/src/Eventuous.Subscriptions/Handlers/EventHandlingResult.cs
ConcurrentBagwith optimized single nullable field + Listfallback
allocations
System.Collections.ConcurrentimportContextItems.cs
Lazy initialize ContextItems dictionarysrc/Core/src/Eventuous.Subscriptions/Context/ContextItems.cs
GetItemandTryGetItemmethods to handle null dictionaryChannelExtensions.cs
Change channel batch return type to IReadOnlyListsrc/Core/src/Eventuous.Subscriptions/Channels/ChannelExtensions.cs
T[]toIReadOnlyListfor betterflexibility
buffer.ToArray()withbuffer.AsReadOnly()to avoid arrayallocation
ReadBatchesandReadAllBatchesto use newreturn type
CommitPositionSequence.cs
Modernize CommitPositionSequence LINQ syntaxsrc/Core/src/Eventuous.Subscriptions/Checkpoints/CommitPositionSequence.cs
Tuple.Createwith tuple expression syntax in Zip operationItem1/Item2to named fieldsposition1/position2== nullto== defaultfor tuple comparisonEventSubscription.cs
Replace logging scope Dictionary with KeyValuePair arraysrc/Core/src/Eventuous.Subscriptions/EventSubscription.cs
DictionarywithKeyValuePair
object>[]for logging scopeProvides 5x faster performance and 3x less allocation for logging
scope creation
Updated scope initialization to use array of KeyValuePair tuples
Reduces per-message allocation overheadChannelWorkers.cs
Update BatchedChannelWorker to use IReadOnlyListsrc/Core/src/Eventuous.Subscriptions/Channels/ChannelWorkers.cs
BatchedChannelWorkerconstructor parameter type fromProcessElementtoProcessElement>of arrays
CheckpointCommitHandler.cs
Update CheckpointCommitHandler to use IReadOnlyListsrc/Core/src/Eventuous.Subscriptions/Checkpoints/CheckpointCommitHandler.cs
Processmethod parameter type fromCommitPosition[]toIReadOnlyListof arrays
4 files
PERFORMANCE_ANALYSIS.md
Comprehensive performance analysis and optimization guidesrc/Core/src/Eventuous.Subscriptions/perf/PERFORMANCE_ANALYSIS.md
Eventuous.Subscriptions
recommendations
faster HandlingResults, 5x faster logging)
optimizations
VALIDATION_REPORT.md
Performance optimizations validation and implementation reportsrc/Core/src/Eventuous.Subscriptions/perf/VALIDATION_REPORT.md
savings from lazy init
optimization
Benchmarks.BENCHMARK_RESULTS_SUMMARY.md
Benchmark results summary and optimization priority matrixsrc/Benchmarks/Benchmarks/BenchmarkDotNet.Artifacts/results/Benchmarks.BENCHMARK_RESULTS_SUMMARY.md
optimizations
logging, 104B lazy init savings
README.md
Comprehensive benchmarks documentation and usage guidesrc/Benchmarks/Benchmarks/README.md
benchmarks suite
metrics
FilterPipelineBenchmarks) and reasons for disabling
and continuous benchmarking practices
7 files
docker-compose.yml
Disabled EventStore service in docker-composesamples/kurrentdb/docker-compose.yml
Eventuous.slnx
Renamed ESDB samples folder to KurrentDBEventuous.slnx
/Samples/Esdb/to/Samples/KurrentDB/samples/esdb/tosamples/kurrentdb/KurrentDB Bookings.run.xml
Added KurrentDB Bookings run configuration.run/KurrentDB Bookings.run.xml
Samples.Esdb.BookingsprofileBenchmarks.csproj
Added source generators and disabled slow benchmarkssrc/Benchmarks/Benchmarks/Benchmarks.csproj
(Eventuous.Subscriptions.Generators, Eventuous.Shared.Generators)
Compile Remove list
Bookings.Payments.csproj
Updated Postgres sample to use KurrentDB shared codesamples/postgres/Bookings.Payments/Bookings.Payments.csproj
esdbtokurrentdbdirectoryBookings.Domain.csproj
Updated Postgres domain sample to use KurrentDB shared codesamples/postgres/Bookings.Domain/Bookings.Domain.csproj
esdbtokurrentdbdirectoryBookings.csproj
Added executable output type to KurrentDB Bookingssamples/kurrentdb/Bookings/Bookings.csproj
OutputTypeproperty set toexeto explicitly define executableoutput
1 files
Bookings.csproj
Formatting adjustment in Postgres Bookings projectsamples/postgres/Bookings/Bookings.csproj
before closing tag)
48 files