9

I've got an application I've written in Node 7.9. It's not a web server. It's doing various kinds of file manipulations, data transformations, and so on.

I want to make some optimizations to performance for long-running tasks (e.g. a task manipulates 10GB of data and runs for 30 hours).

I can't seem to find any information on how to profile my application for time spent in javascript functions (for example, class methods). I have found some deprecated packages that were sort of similar, but nothing that shows me javascript-level info.

Also, I tried using the webkit built-in profiler, but it doesn't show me info at the javascript function level. In general it shows me things like lots of time spent manipulating maps and such in C functions.

What are the current tools (if any?) for doing this?

Sir Robert
  • 4,686
  • 7
  • 41
  • 57
  • What metrics, specifically, are you looking for? – Raphael Rafatpanah May 15 '17 at 22:44
  • take a look at this. https://nodejs.org/api/debugger.html#debugger_v8_inspector_integration_for_node_js – Dayan Moreno Leon May 15 '17 at 22:48
  • 1
    @RaphaelRafatpanah Specifically time spent in each function. I suspect that most of my functions can be optimized, but that a few are probably the main culprits. – Sir Robert May 15 '17 at 22:53
  • Have you considering just logging the time before and after each function? Or is this tedious given the number of functions you are trying to log? http://stackoverflow.com/questions/313893/how-to-measure-time-taken-by-a-function-to-execute – Raphael Rafatpanah May 15 '17 at 22:55
  • Node's (ECMAScript's?) metaprogramming doesn't seem quite mature enough for that yet when you have more than a few functions. I have dozens to hundreds (depending on which transformations occur). – Sir Robert May 16 '17 at 00:42
  • @DayanMorenoLeon Ok, that's helpful. I didn't have time to test it (profiling via Chrome) but I'll give it a try. It's not a nice solution, imho (I have to have access to xwindows or something), but it will work on a local machine. Is there any server-side solution? Or do you know how I could run chrome headless and get the profile otherwise? – Sir Robert May 16 '17 at 00:43
  • do you want to profile or track performance/metrics? there is no better way to profile/ debug than using the chrome dev tools you should not profile function calls in a permanent/long term operations for this you would have to take snapshots and then combine them for analysis for which maybe https://www.npmjs.com/package/@risingstack/v8-profiler would be a good candidate. – Dayan Moreno Leon May 16 '17 at 01:11
  • 1
    @DayanMorenoLeon Thanks; I don't need to track performance, it's just profiling for optimization. I have processes that need to do heavy number crunching and such for many hours and wanted to prioritize optimizations in a data-centric manner. I meant that I am doing calculations in Microsoft Azure's linux VMs running calculations on 100MM - 1Bn+ records and using chrome windowed in an environment like that doesn't make sense (hence my question about running it headless and getting stats out). – Sir Robert May 17 '17 at 03:13
  • in that case i think the v-8 profiler module would be a good choice, since allows you to take snapshots of your process for later analysis. – Dayan Moreno Leon May 17 '17 at 14:18
  • This is a good question, and it needs a good answer. There is a thing called "zoran", but I haven't been able to make it work yet... – Nick Perkins Jan 20 '18 at 15:27

0 Answers0