Skip to content

Performance and Garbage Collection #78

Closed
@PeteDuncanson

Description

@PeteDuncanson

Hi Daniel,

We've been running some performance tests on a site we are hoping to go live with next month and noticed each request is gobbling roughly 4MB of unmanaged memory each time that I'm trying to track down.

In our work we tried a few things but I'd love your thoughts. I think a fix is possible I just wanted to run some stuff by you if possible.

  • We've got a tool thats throwing 15 concurrent requests into our site generating a total 600 requests for our web page. First run on my machine it gobbles up 450MB of unmanaged memory and second run added another 150MB which looked like it might be maxing out and forcing some GC of some sort but a 3rd run showed it pushing ever higher again.
  • Memory usage jumps when we execute our commands in the JS engines (seen by monitoring memory usage while stepping through our code), we are runnning some chunky JSON through it (100Kb+) for each request but we init each engine with our bundled JS (300K including React and React-Router) only on start up of the engine to limit usage. Its this initial JSON that we need to seed the component with thats causing a jump in the memory. Its just pushed in as a string so I would hope the Garbage Collection in ClearScript (well V8 under the hood) would just clear it up but it seems to not be until we really push the usage up.
  • We've modified JSPool (and JavascriptSwitcher as a result) to give us a .CollectGarbage() method we can call on the V8 engine when its returned to the pool, that has more than halved the memory usage. Had to use the agressive GC to get this to happen though (see https://clearscript.codeplex.com/discussions/576460).
  • We are only passing formatted strings into the JS engine to be executed, not references to actual objects so ClearScript/V8 shouldn't be keeping anything from being GC'ed that we can see and all this is done in ReactEnvironment which should be thrown away at each request so .net GC should be doing its thing anyway.
  • There is a definate "jump" on the unmanaged heap after every request (shown when just pressing refresh without our test running), initially 4MB now more like 1.5MB after my hackery :)

Any ideas on what other steps we can take?

I'm tempted to try throwing away the engine each time and see if we can get any better memory usage. This would be just a test to see if it makes a difference.

Cheers

Pete

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions