Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Maximising re-use of process/AppDomain
kierenj
#1 Posted : Thursday, August 25, 2016 11:55:29 AM(UTC)
Rank: Member

Groups: Registered
Joined: 8/25/2016(UTC)
Posts: 20
Location: United Kingdom

Thanks: 3 times
Was thanked: 1 time(s) in 1 post(s)
Hi - we're using NCrunch to run some integration tests which use an Entity Framework context which is fairly large.

The startup time for EF to build the model (in-memory) is pretty slow; much slower than the time it takes our framework to restore a copy of the database in SQL Express, or check/seed the database, for instance!

Anyway - a big part of each test's execution is EF building an in-memory model as the context is initialised for the first time. There are solutions for persisting/caching this on disk, but apparently they don't work when using Migrations (which we do).

Re-using processes (I really mean AppDomains) as much as possible would minimise the number of times this model re-build is done, within a single batch. However I can't find a way to indicate this should occur. If I write out the current process ID in my fixture setup methods, I see different values each time.

Can anyone share any tips for this?

Thanks
Kieren
Remco
#2 Posted : Thursday, August 25, 2016 12:27:01 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,974

Thanks: 929 times
Was thanked: 1256 time(s) in 1169 post(s)
Hi Kieren,

Thanks for posting!

NCrunch will re-use processes (and their app domains) whenever it can. Depending on your setup, you'll likely notice NCrunch builds these processes quite often. Basically, NCrunch will spawn a new test process when it needs to run a test task and no other test process is available that can be safely used for the task.

Higher concurrently/parallelisation will require more test processes to exist at any one time. This means that if you have a 'max number of processing threads' set to 3, then NCrunch will need to create 3 test processes to support the execution.

If the codebase is changed, NCrunch must throw away all initialised test processes as the code loaded by them is now different and cannot be reloaded without discarding the processes entirely.

An important setting for reducing the number of process spawning actions is the max test runners to pool setting. When NCrunch isn't using a test process, it will place it in a pool in case it's needed later. If you have a solution with multiple test projects and NCrunch is constantly shuffling the tests in these projects around the queue, its execution sequence can cause it to lean heavily on the process pool. The default value of 1 in this setting can be inadequate in such a situation, and it may be wise to increase it to at least 3, or even 5.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.034 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download