On Wed Aug 3 14:01:20 2022 +0000, Torge Matthies wrote:
@piotr So actually how many contexts are reused seems to somehow depend on how many CPUs there are. [msvcr120.c.diff](/uploads/b72cf9ede1319ae6cea220e76aead265/msvcr120.c.diff) Output with a 12 core 24 thread VM:
context: 000001EFC5C80A80 id 1 context: 000001EFC5C81CB0 id 2 context: 000001EFC5C97DE0 id 8 context: 000001EFC5C99A70 id 9 context: 000001EFC5C99810 id 10 context: 000001EFC5C996E0 id 11 context: 000001EFC5C99220 id 12 context: 000001EFC5C99350 id 13 context: 000001EFC5C98D60 id 14 context: 000001EFC5C995B0 id 15 context: 000001EFC5C99940 id 16 context: 000001EFC5C98E90 id 17 context: 000001EFC5C98E90 id 17 context: 000001EFC5C99940 id 16 context: 000001EFC5C995B0 id 15 context: 000001EFC5C98D60 id 14 context: 000001EFC5C99350 id 13 context: 000001EFC5C99220 id 12 context: 000001EFC5C996E0 id 11 context: 000001EFC5C99810 id 10 context: 000001EFC5C99A70 id 9 context: 000001EFC5C97DE0 id 8 context: 000001EFC5C81CB0 id 2 context: 000001EFC5C80A80 id 1 1c64:msvcr120: 897 tests executed (0 marked as todo, 0 failures), 0 skipped.
Output with a 2 core 4 thread VM:
context: 000001C04031D100 id 2 context: 000001C04031E210 id 1 context: 000001C040332580 id 7 context: 000001C0403320C0 id 8 context: 000001C0403321F0 id 9 context: 000001C040331D30 id 10 context: 000001C0403327E0 id 11 context: 000001C040331E60 id 12 context: 000001C040332320 id 13 context: 000001C040331C00 id 14 context: 000001C0403326B0 id 15 context: 000001C040331F90 id 16 context: 000001C0403320C0 id 8 msvcr120.c:1768: Test failed: context changed context: 000001C040332580 id 7 msvcr120.c:1768: Test failed: context changed context: 000001C04031E210 id 1 msvcr120.c:1768: Test failed: context changed context: 000001C04031D100 id 2 msvcr120.c:1768: Test failed: context changed context: 000001C0403327E0 id 17 msvcr120.c:1768: Test failed: context changed context: 000001C040332910 id 18 msvcr120.c:1768: Test failed: context changed context: 000001C0403321F0 id 19 msvcr120.c:1768: Test failed: context changed context: 000001C040331F90 id 20 msvcr120.c:1768: Test failed: context changed context: 000001C040331E60 id 21 msvcr120.c:1768: Test failed: context changed context: 000001C040331D30 id 22 msvcr120.c:1768: Test failed: context changed context: 000001C0403326B0 id 23 msvcr120.c:1768: Test failed: context changed context: 000001C040332320 id 24 msvcr120.c:1768: Test failed: context changed 2630:msvcr120: 897 tests executed (0 marked as todo, 12 failures), 0 skipped.
If I increase the `THREAD_COUNT` I get failures too with 12 cores 24 threads. No idea yet why it chooses physical cores in the first case and logical cores in the second case. How do you think I should implement this behavior?
I guess that native does some kind of context caching in order to improve efficiency (it may be faster to reuse a context instead of creating new one). The test shows that only some contexts are cached (depending on CPU core number). It means that probably, if context cache is full, the contexts are destroyed on thread exit. It would be useful to know how task collection is behaving in this case. Could you please add such test?