GNU Make parallel - how to record idle vs active CPU time for a job

落爺英雄遲暮 提交于 2019-12-11 03:27:06

问题


I'm using make --jobs=<num> to do parallel builds on a multi-core machine.

I want to have a robust method to record how long it takes for a given target to get built using the pre-action, build, post-action model.

This answer says:

Also, start and end times are not all there is to know about how long an action takes, when you are running things in parallel; rule A might take longer that rule B, simply because rule B is running alone while rule A is sharing the processor with rules C through J.

Therefore, in order to have a accurate 'duration to build a target', I have to record the worker thread's percentage of time active and multiply that by the recorded duration of a target to get real duration.

Running make with --trace - and --jobs of course - gives a bunch of these statements whose mapping to OS thread IDs I'm unsure of

Main thread handle = 00000098

I need to be able to map an OS thread ID to a make thread handle

QUESTIONS

  1. Are these thread handles internal to make or do they correspond to OS thread IDs that I could profile with ProcMon?
  2. How do I go from make's thread handles to OS thread IDs?

UPDATE

@Kaz makes a good point about prerequisites: what if some or all or none are made?
Answer: I will take care of that in my parsing of the output. Since I'm makeing with --print-data-base I can parse how much of the time spent to build a target was due to target itself vs its prerequisites.

来源:https://stackoverflow.com/questions/39086951/gnu-make-parallel-how-to-record-idle-vs-active-cpu-time-for-a-job

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!