Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Partitioned memory pools #362

Closed
wants to merge 1 commit into from
Closed

Conversation

benaadams
Copy link
Contributor

The increase in use of memory pools is leading to and will inevitably lead to greater and greater contention.

Contention

This loosens the contention on the memorypool by partitioning ProcessorCount times and choosing the first pool to try as ManagedThreadId % ProcessorCount.

Also steals from other pools when preferred pool is empty.

@davidfowl
Copy link
Member

Not a fan of this being in the ctor. It could be in a factory method though

@benaadams
Copy link
Contributor Author

Going to change it up then...

@benaadams benaadams changed the title Pre-allocate memory pool [Experiment] Partitioned memory pools Nov 17, 2015
@benaadams
Copy link
Contributor Author

@halter73 give this a go?

Taken @rynowak's round robining idea from #390 (comment); but using ManagedThreadId % ProcessorCount rather than Interlocked.Increment which would be an obvious choice; however would put contention on a single numeric; though lighter than CAS.

Hopefully it will still provide enough distribution.

@DamianEdwards
Copy link
Member

Rebased on 7e8a405 and measured. This one seems totally broken. It gets slower with each run and leaves the dnx process eating CPU even when not serving requests.

@benaadams
Copy link
Contributor Author

Yeah found it to be broken last night ;-(

@benaadams benaadams changed the title [Experiment] Partitioned memory pools Partitioned memory pools Nov 19, 2015
@benaadams
Copy link
Contributor Author

@DamianEdwards is fixed

@AspNetSmurfLab
Copy link

Measured again. It's very slightly up from the dev branch baseline (~499k):

Running 10s test @ http://10.0.0.100:5001/plaintext
  32 threads and 256 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     6.30ms    7.52ms 100.86ms   92.93%
    Req/Sec    15.84k     1.39k   32.81k    88.84%
  5071775 requests in 10.10s, 638.46MB read
Requests/sec: 502177.87
Transfer/sec:     63.22MB

@benaadams
Copy link
Contributor Author

This is more a pre-solution for the contention that will happen with more memory pool use with SocketOutput and the pre-computed Headers change

@benaadams
Copy link
Contributor Author

See @halter73 is working on something far better; closing this...

@benaadams benaadams closed this Nov 24, 2015
@benaadams benaadams deleted the memory-pool branch May 10, 2016 02:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants