If profiling is turned on it is turned on for all threads.
Ok, I was suspecting something like that. Are there plans for profiling concurrent programs or even interactions of threads?
Profiling 2 records the number of words allocated in each function. It works by pretending that the heap segment is full for each allocation so forcing a call into the RTS. This adds a considerable overhead but does produce accurate figures rather than samples. It measures the allocation made and takes no account of whether or when the data structures are garbage collected.
Thanks for making that clear.
Profiling 1 samples the program counter to find out where the code is spending most of its time. It only really works properly in Linux. Mac OS X does not have thread-specific CPU timers. In Linux a timer is set for each thread which causes it to be interrupted every millisecond of CPU time. One millisecond seems like a reasonable figure but you could try changing it. You would have to modify Processes::StartProfilingTimer in the RTS.
Ok, maybe I'll try this. What happens if the thread is inside the RTS (but not engaged in GC, which is counted) when the timer goes off? Are those samples just ignored or do they count as UNKNOWN?
Andreas Schropp wrote:
Are there plans for profiling concurrent programs or even interactions of threads?
Makarius and I have discussed more detailed instrumentation of concurrent programs but so far nothing has been implemented. It requires some sort of graphical performance monitoring rather like the Windows perfmon because it's more about the change in properties over time than simple counts.
What happens if the thread is inside the RTS (but not engaged in GC, which is counted) when the timer goes off? Are those samples just ignored or do they count as UNKNOWN?
When the timer goes off the interrupt handler attempts to trace the stack to find out the Poly function that was executing. If it is in the RTS it will report the function that called the RTS. Because the timer can go off at any point it's possible that the handler won't be able to find a function in which case it will report UNKNOWN.
David