How can I make a program which uses all cores and 100% of cpu power?

Murilo murilomiranda92 at hotmail.com
Fri Dec 6 01:38:40 UTC 2019


On Friday, 11 October 2019 at 06:18:03 UTC, Ali Çehreli wrote:
> Your threads must allocate as little memory as possible because 
> memory allocation can trigger garbage collection and garbage 
> collection stops all threads (except the one that's performing 
> collection).
> We studied the effects of different allocation schemes during 
> our last local D meetup[1]. The following program has two 
> similar worker threads. One allocates in an inner scope, the 
> other one uses a static Appender and clears its state as needed.
> The static Appender is thread-safe because each thread gets 
> their own copy due to data being thread-local by default in D. 
> However, it doesn't mean that the functions are reentrant: If 
> they get called recursively perhaps indirectly, then the 
> subsequent executions would corrupt previous executions' 
> Appender states.

Thanks for the information, they were very helpful.


More information about the Digitalmars-d-learn mailing list