Isolate CPU divisor pools per thread
This commit is contained in:
1 parent
cd69c08fb4
commit
8e9390bc5e
7 files changed
+61
-34
No files matched your search
@@ -81,12 +81,12 @@ namespace PerfectNumbers.Core
|
||||
{
|
||||
if (_primes is not null)
|
||||
{
|
||||
ArrayPool<ulong>.Shared.Return(_primes, clearArray: false);
|
||||
ThreadLocalArrayPool<ulong>.Shared.Return(_primes, clearArray: false);
|
||||
}
|
||||
|
||||
if (_exponents is not null)
|
||||
{
|
||||
ArrayPool<byte>.Shared.Return(_exponents, clearArray: false);
|
||||
ThreadLocalArrayPool<byte>.Shared.Return(_exponents, clearArray: false);
|
||||
}
|
||||
|
||||
_arraysFromPool = false;
|
||||
@@ -119,12 +119,12 @@ namespace PerfectNumbers.Core
|
||||
{
|
||||
if (_primes is not null)
|
||||
{
|
||||
ArrayPool<ulong>.Shared.Return(_primes, clearArray: false);
|
||||
ThreadLocalArrayPool<ulong>.Shared.Return(_primes, clearArray: false);
|
||||
}
|
||||
|
||||
if (_exponents is not null)
|
||||
{
|
||||
ArrayPool<byte>.Shared.Return(_exponents, clearArray: false);
|
||||
ThreadLocalArrayPool<byte>.Shared.Return(_exponents, clearArray: false);
|
||||
}
|
||||
|
||||
_arraysFromPool = false;
|
||||
@@ -134,8 +134,8 @@ namespace PerfectNumbers.Core
|
||||
|
||||
if (capacity >= PerfectNumberConstants.PooledArrayThreshold)
|
||||
{
|
||||
_primes = ArrayPool<ulong>.Shared.Rent(capacity);
|
||||
_exponents = ArrayPool<byte>.Shared.Rent(capacity);
|
||||
_primes = ThreadLocalArrayPool<ulong>.Shared.Rent(capacity);
|
||||
_exponents = ThreadLocalArrayPool<byte>.Shared.Rent(capacity);
|
||||
_arraysFromPool = true;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in new issue
Block a user