fix(perf): Eliminate ConcatIterator CPU waste in DI resolution#213
Closed
anthony-keller wants to merge 2 commits intoEFNext:v3from
Closed
fix(perf): Eliminate ConcatIterator CPU waste in DI resolution#213anthony-keller wants to merge 2 commits intoEFNext:v3from
anthony-keller wants to merge 2 commits intoEFNext:v3from
Conversation
Add CLAUDE.md to provide guidance for Claude Code when working with this repository. The file documents project overview, build and test commands, multi-version build system (V1/V2/V3), global build settings, architecture and core flow of the trigger library, key internal types, and test project layout. Intended as a quick reference for building, testing, and understanding trigger execution and project structure.
…r CPU waste Replace IEnumerable<T> fields with List<T> to avoid deeply nested ConcatIterator chains from repeated .Concat() calls. Each WithAdditionalTrigger call now uses List.Add() instead. Also cache the service provider hash code, use O(1) List.Count property instead of LINQ .Count(), and add count-based fast paths in ShouldUseSameServiceProvider to short-circuit before SequenceEqual. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
4 tasks
Author
|
@PhenX Based on our usage of this change over the past 2 weeks, it has not caused any issues and we saw significant improvements. |
Member
|
I think I was confronted to this same issue a while ago, fixed it by rewriting the service registration in my code, but that was before I became a contributor. I'll compare both and take best parts :) thank you |
Member
|
I reopened it with your commit here : #215 |
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.

Summary
IEnumerable<T>fields withList<T>inTriggersOptionExtensionto eliminate deeply nestedConcatIteratorchains created by repeated.Concat()calls during trigger registrationGetServiceProviderHashCode()result to avoid re-computing on every EF CoreServiceProviderCachelookupShouldUseSameServiceProviderwith scalar and count-based fast paths before falling back toSequenceEqualList.Countproperty (O(1)) instead of LINQ.Count()extension (O(N)) inPopulateDebugInfoContext
CPU profiling showed 50%+ of Self CPU burned in
ConcatIterator<T>.MoveNext()during DI service resolution. Every request triggers EF Core'sServiceProviderCacheto enumerate the_triggersand_triggerTypesfields, which were lazyIEnumerable<T>chains built via.Concat()— one nesting level per trigger registration.Test plan
dotnet build— 0 errorsdotnet test— all 241 tests pass (166 core + 38 extensions + 22 transactions + 15 integration)🤖 Generated with Claude Code