Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add memory tracking to the benchmark scripts #95

Closed
springmeyer opened this issue Dec 15, 2017 · 2 comments
Closed

Add memory tracking to the benchmark scripts #95

springmeyer opened this issue Dec 15, 2017 · 2 comments

Comments

@springmeyer
Copy link
Contributor

Memory usage can be as important of a target as latency when aiming for fast code. This is because an application that might run fast under low memory pressure could all of a sudden run really slow under high memory pressure.

So, it would be great to add memory tracking to the node-cpp-skel benchmarks, such that developers can opt-in easiely to seeing what the peak memory usage was during a benchmark. This should be opt-in because tracking memory might skew the code speed slightly, so developers should only enable when they absolutely need memory tracking.

TODO: define these terms in the C++ glossary: mapbox/cpp#44

@springmeyer
Copy link
Contributor Author

This could be done by:

  1. Accepting a --mem argument to the benchmark scripts and include bytes module
npm install bytes --save
  1. Creating a stats object like:
    var memstats = {
      max_rss:0,
      max_heap:0,
      max_heap_total:0
    };  
  1. If --mem is passed, then check every 100 iterations for memory peak:
          if (track_mem && (runs % 100) == 0) {
              var mem = process.memoryUsage();
              if (mem.rss > memstats.max_rss) memstats.max_rss = mem.rss;
              if (mem.heapTotal > memstats.max_heap_total) memstats.max_heap_total = mem.heapTotal;
              if (mem.heapUsed > memstats.max_heap) memstats.max_heap = mem.heapUsed;
          }
  1. Dump results at end of run
console.log('Benchmark peak mem: ',bytes(memstats.max_rss),bytes(memstats.max_heap),bytes(memstats.max_heap_total));

@GretaCB
Copy link
Contributor

GretaCB commented Jan 9, 2018

Finished per #102

@GretaCB GretaCB closed this as completed Jan 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants