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

Increase the default maximum context pool size #24849

Closed
ajcvickers opened this issue May 6, 2021 · 5 comments · Fixed by #24870
Closed

Increase the default maximum context pool size #24849

ajcvickers opened this issue May 6, 2021 · 5 comments · Fixed by #24870
Assignees
Labels
area-dbcontext area-perf closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Milestone

Comments

@ajcvickers
Copy link
Member

Based on findings from the TechEmpower perf work. We probably want a very high default which can then be tuned down if the application wants to reduce maximum memory at the expense of speed.

@ajcvickers ajcvickers added area-dbcontext good first issue This issue should be relatively straightforward to fix. type-enhancement area-perf labels May 6, 2021
@stevendarby
Copy link
Contributor

1024 like the benchmarks?

@roji
Copy link
Member

roji commented May 8, 2021

For completeness, we also discussed making this infinite by default (i.e. int.MaxValue). The issue with that is that if there's suddenly a spike due to some issue (e.g. a temporary network problem causes operations to block for a bit, and therefore many contexts get created), then the excess contexts will never be freed.

@davidfowl
Copy link
Member

What's the strategy for clearing the pool?

@roji
Copy link
Member

roji commented May 9, 2021

@davidfowl at the moment, the only time the pool is cleared is if its disposed; in the typical usage scenario, the pool is a singleton, so it never gets cleared (here's the code).

But note that unlike e.g. database connections, DbContexts are purely an in-memory thing, so keeping around e.g. 1024 for the entire application doesn't seem like a big problem. Are you thinking about this with dotnet/runtime#48567 in mind?

@ajcvickers
Copy link
Member Author

We agreed in triage to make this 1024 so that we don't ship an unbounded pool by default.

@ajcvickers ajcvickers added this to the 6.0.0 milestone May 10, 2021
roji added a commit that referenced this issue May 10, 2021
@roji roji removed the good first issue This issue should be relatively straightforward to fix. label May 10, 2021
@ghost ghost closed this as completed in #24870 May 10, 2021
ghost pushed a commit that referenced this issue May 10, 2021
ericstj pushed a commit to ericstj/efcore that referenced this issue May 11, 2021
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label May 27, 2021
@ajcvickers ajcvickers modified the milestones: 6.0.0, 6.0.0-preview5 May 27, 2021
@ajcvickers ajcvickers modified the milestones: 6.0.0-preview5, 6.0.0 Nov 8, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-dbcontext area-perf closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants