Tracing/Profiling D Applications

Christian Köstlin christian.koestlin at gmail.com
Fri May 27 13:55:45 UTC 2022


On 2022-05-26 22:19, Ali Çehreli wrote:
> On 5/26/22 12:54, Christian Köstlin wrote:
> 
>  > I want to be able to dump
>  > tracings even while the program is still running. Then I would have to
>  > collect the tls data of all still running threads.
> 
> I am not sure without testing but I am under the impression that mutexes 
> can be very slow especially if the data collection is happening very 
> frequently. The threads may not have breathing room to perform their 
> tasks. Since dumping would be much slower compared to the performance 
> penalty of grabbing a mutex that it can be measured as zero-cost in the 
> dumping time. :) So, you may still want to collect per-thread and 
> combine incrementally as you dump? Perhaps a premature optimization... 
> Please test. :)

You are certainly right.. It really depends on the usecase. I also think 
my current approach is not good to e.g. do syscall tracing of something 
like read. I wonder how I can synchronize the "dumping" and the 
collection of the threads. Would be cool to have an efficient lockless 
implementation of appender ...


> If you want to combine before dumping, then collector registration may 
> be needed so that the dumper can contact each collector and say "please 
> add your data".
> 
>  > __gshared does not put
>  > the shared type attribute the the profiler.
> 
> Correct.
thanks!


>  > If I use shared I would also
>  > have to make all methods I call on the shared profiler shared and also
>  > would have to have a shared appender (or cast shared away)?
> 
> Possibly. :/
> 
> Ali
> 



---
Christian


More information about the Digitalmars-d-learn mailing list