Skip to content
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

Stop capturing in logging #24197

Merged
merged 1 commit into from
Feb 19, 2021
Merged

Stop capturing in logging #24197

merged 1 commit into from
Feb 19, 2021

Conversation

roji
Copy link
Member

@roji roji commented Feb 19, 2021

LoggingAllocations

On a local 30k iteration Fortunes run, allocations were reduced from 2.5M instances (153.21MB) to 2.23M instances (146.99MB) (10% reduction in instances, 4% in bytes).

Interestingly, no discernible effect on RPS throughput at the perf lab. The GC must be doing its job quite well.

@roji roji merged commit aecae63 into main Feb 19, 2021
@roji roji deleted the RemoveLoggingClosures branch February 19, 2021 19:06
@AndriySvyryd
Copy link
Member

@roji Those instances were probably never GC'ed

@roji
Copy link
Member Author

roji commented Feb 19, 2021

I guess it's possible... Though I can see lots of GC runs occurring in DotMemory, and it would be a bit odd if these 10% of instances (4% of bytes) weren't touched...

In any case, always good to cut down...

@ajcvickers
Copy link
Member

@roji The resulting EventDefinitionBase objects are rooted in a singleton service, which will be rooted in the internal service provider. In a typical application they will not be GC'ed. That being said, I don't know if this relates directly to capturing.

@roji
Copy link
Member Author

roji commented Feb 19, 2021

I don't think this is related to the EventDefinitionBase - it's just about the lambda passed as an argument to EnsureInitialized; it used to reference the logger local variable, making it a closure and therefore a heap allocation. I just changed that to be a static lambda that gets the logger as a parameter.

roji added a commit to roji/efcore that referenced this pull request Feb 19, 2021
@roji roji linked an issue Feb 23, 2021 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve EF Core (non-tracking) query performance on TechEmpower Fortunes
3 participants