filprofiler icon indicating copy to clipboard operation
filprofiler copied to clipboard

Track memory from subprocesses

Open itamarst opened this issue 5 years ago • 6 comments

multiprocessing and other similar systems are basically the same program, just with multiple processes. That memory should be tracked together.

Implementation ideas:

  1. Each subprocess tracks its own info.
  2. Share critical info with parent (callstack ids and the like).
  3. Have global counter, perhaps shared via messages, perhaps in shared memory.
  4. Each process has local counter, and if it's diverged sufficiently from global one, send out message with update.

itamarst avatar Sep 21 '20 12:09 itamarst

Easier alternative: just record each process separately.

itamarst avatar Mar 01 '21 21:03 itamarst

Indeed, it seems easier to record each process separately and then collate the results when creating the svg.

ehiggs avatar Jun 23 '21 16:06 ehiggs

When I said "record each process separately" I meant "and have separate SVGs", just to be clear. The data cannot be combined if recorded separately, because it's peak memory usage. So peak for process A might be at time T0, peak for process B might be at time T1, but combined peak (which is what is relevant for hardware provisioning) might be time T2.

I am not sure what design I will go for with Fil, yet, but for the production-grade high performance version I'm working on I will probably combine everything (it uses sampling, so there's less data to copy around, so the overhead isn't as bad).

What is your specific use case for multiple process profiling?

itamarst avatar Jun 23 '21 16:06 itamarst

My use case is celery workers. I can test using specific tests on the workers but it would be nice to just test the whole system in unison to see if we are getting memory leaks in the way the workers are handled by the processes.

ehiggs avatar Jun 24 '21 09:06 ehiggs

Thanks, that's helpful. For that maybe you just want to look at overall system memory (or maybe process memory) over time using psutil? Will also save you the performance overhead of the open source version of Fil.

itamarst avatar Jun 24 '21 15:06 itamarst

This is not a priority at the moment. This will get added to https://pythonspeed.com/sciagraph/ first, and if that turns out to be portable might do it for Fil, but may or may not happen here, on the theory that if one is doing manual develop-time profiling, it's possible to modify code, whereas Sciagraph needs to support unchanged production code.

itamarst avatar Jan 26 '22 17:01 itamarst