From 1fb5047f5ebe9c2065a2f2a7c1c75085203fd30b Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Mon, 10 May 2021 17:31:21 +0200 Subject: [PATCH] Increase default context pool size from 128 to 1024 Closes #24849 --- .../EntityFrameworkServiceCollectionExtensions.cs | 12 ++++++------ src/EFCore/Infrastructure/PooledDbContextFactory.cs | 2 +- src/EFCore/Internal/DbContextPool.cs | 2 +- .../DbContextPoolingTest.cs | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/EFCore/Extensions/EntityFrameworkServiceCollectionExtensions.cs b/src/EFCore/Extensions/EntityFrameworkServiceCollectionExtensions.cs index 691e7ba0949..f895b203e10 100644 --- a/src/EFCore/Extensions/EntityFrameworkServiceCollectionExtensions.cs +++ b/src/EFCore/Extensions/EntityFrameworkServiceCollectionExtensions.cs @@ -145,7 +145,7 @@ public static IServiceCollection AddDbContext /// - /// Sets the maximum number of instances retained by the pool. Defaults to 128. + /// Sets the maximum number of instances retained by the pool. Defaults to 1024. /// The same service collection so that multiple calls can be chained. public static IServiceCollection AddDbContextPool( this IServiceCollection serviceCollection, @@ -187,7 +187,7 @@ public static IServiceCollection AddDbContextPool( /// will not be called. /// /// - /// Sets the maximum number of instances retained by the pool. Defaults to 128. + /// Sets the maximum number of instances retained by the pool. Defaults to 1024. /// The same service collection so that multiple calls can be chained. public static IServiceCollection AddDbContextPool( this IServiceCollection serviceCollection, @@ -241,7 +241,7 @@ public static IServiceCollection AddDbContextPool /// - /// Sets the maximum number of instances retained by the pool. Defaults to 128. + /// Sets the maximum number of instances retained by the pool. Defaults to 1024. /// The same service collection so that multiple calls can be chained. public static IServiceCollection AddDbContextPool( this IServiceCollection serviceCollection, @@ -292,7 +292,7 @@ public static IServiceCollection AddDbContextPool( /// will not be called. /// /// - /// Sets the maximum number of instances retained by the pool. Defaults to 128. + /// Sets the maximum number of instances retained by the pool. Defaults to 1024. /// The same service collection so that multiple calls can be chained. public static IServiceCollection AddDbContextPool( this IServiceCollection serviceCollection, @@ -814,7 +814,7 @@ public static IServiceCollection AddDbContextFactory( /// will not be called. /// /// - /// Sets the maximum number of instances retained by the pool. Defaults to 128. + /// Sets the maximum number of instances retained by the pool. Defaults to 1024. /// The same service collection so that multiple calls can be chained. public static IServiceCollection AddPooledDbContextFactory( this IServiceCollection serviceCollection, @@ -858,7 +858,7 @@ public static IServiceCollection AddPooledDbContextFactory( /// will not be called. /// /// - /// Sets the maximum number of instances retained by the pool. Defaults to 128. + /// Sets the maximum number of instances retained by the pool. Defaults to 1024. /// The same service collection so that multiple calls can be chained. public static IServiceCollection AddPooledDbContextFactory( this IServiceCollection serviceCollection, diff --git a/src/EFCore/Infrastructure/PooledDbContextFactory.cs b/src/EFCore/Infrastructure/PooledDbContextFactory.cs index eb218e6bd80..a9e989709be 100644 --- a/src/EFCore/Infrastructure/PooledDbContextFactory.cs +++ b/src/EFCore/Infrastructure/PooledDbContextFactory.cs @@ -34,7 +34,7 @@ public PooledDbContextFactory(IDbContextPool pool) /// Initializes a new instance of the class. /// /// The options to use for contexts produced by this factory. - /// Sets the maximum number of instances retained by the pool. Defaults to 128. + /// Sets the maximum number of instances retained by the pool. Defaults to 1024. public PooledDbContextFactory(DbContextOptions options, int poolSize = DbContextPool.DefaultPoolSize) { var optionsBuilder = new DbContextOptionsBuilder(options); diff --git a/src/EFCore/Internal/DbContextPool.cs b/src/EFCore/Internal/DbContextPool.cs index 56c5fe89bf4..198f9e39cf7 100644 --- a/src/EFCore/Internal/DbContextPool.cs +++ b/src/EFCore/Internal/DbContextPool.cs @@ -29,7 +29,7 @@ public class DbContextPool : IDbContextPool, IDisposable, IA /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public const int DefaultPoolSize = 128; + public const int DefaultPoolSize = 1024; private readonly ConcurrentQueue _pool = new(); diff --git a/test/EFCore.SqlServer.FunctionalTests/DbContextPoolingTest.cs b/test/EFCore.SqlServer.FunctionalTests/DbContextPoolingTest.cs index 870d8fc0695..20e8fa0a872 100644 --- a/test/EFCore.SqlServer.FunctionalTests/DbContextPoolingTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/DbContextPoolingTest.cs @@ -261,7 +261,7 @@ public void Validate_pool_size_default() using var scope = serviceProvider.CreateScope(); Assert.Equal( - 128, + 1024, scope.ServiceProvider .GetRequiredService() .GetService() @@ -276,7 +276,7 @@ public void Validate_pool_size_with_service_interface_default() using var scope = serviceProvider.CreateScope(); Assert.Equal( - 128, + 1024, ((DbContext)scope.ServiceProvider .GetRequiredService()) .GetService() @@ -291,7 +291,7 @@ public void Validate_pool_size_with_factory_default() using var context = serviceProvider.GetRequiredService>().CreateDbContext(); Assert.Equal( - 128, + 1024, context.GetService() .FindExtension().MaxPoolSize); }