Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Migrate from ConcurrentDictionary to Dynamic Static Generic Caches #91

Closed
LordZoltan opened this issue Mar 9, 2019 · 0 comments
Closed
Assignees
Milestone

Comments

@LordZoltan
Copy link
Member

Having identified ConcurrentDictionary as being one of (but not the only) bottleneck, despite its very good performance, I've come up with a new solution which is valid for long-lived objects, such as containers (and, potentially, root target containers).

It requires adding specific TFMs to Rezolver for the runtimes which support System.Reflect.Emit APIs such as AssemblyBuilder, TypeBuilder etc - and leverages the static field initialisers to initialise objects statically which would either:

  • need to be created each time a call is made, but which vary only by a type (which can, therefore, be used as generic arguments
  • use the standard ConcurrentDictionary pattern of a thread-safe GetOrAdd()

Using static initialisers of dynamic types automatically provides thread-safe initialisation but without any performance penalty for accessing the protected data on subsequent reads. Just applying this pattern to both ResolveContext and the ICompiledTarget for strong-typed Resolve operations has provided a big reduction in memory overhead and performance.

@LordZoltan LordZoltan self-assigned this Mar 9, 2019
@LordZoltan LordZoltan added this to the 2.0 milestone Mar 9, 2019
@LordZoltan LordZoltan added this to In progress in Rezolver Board Mar 18, 2019
@LordZoltan LordZoltan mentioned this issue Mar 18, 2019
@LordZoltan LordZoltan moved this from In progress to Developed in Rezolver Board May 8, 2019
Rezolver Board automation moved this from Developed to Done Jul 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Development

No branches or pull requests

1 participant