On 28.02.2010 00:48, James Mansion wrote:
> Robert Jordan wrote:
>> It was an example why results might be different.
>>
>>
> Relevant?

Who?

>> It is not. The GC is interacting with low-level OS parts and can
>> be triggered any time during your benchmarks.
>>
> Lets back up, becuase I still think there has been some hand-waving. If
> the answer
> is really 'its stuck in GC and yes it sucks' then fine, but the speed
> difference
> is very large for this code, and it doesn't look right unless the
> Windows code is
> very bad. The order of magnitude difference is hard to explain by OS
> interface
> efficiency differences, unless the OS interfaces are being used badly.

Feel free to disassemble a method compiled under Windows
and Linux. You'll find no differences.


Now on TLS:

---
// compile with: cl /Od tls.c
#include <windows.h>

int __declspec(thread) foo;

int
main (void)
{
        int i;
        DWORD ticks;
        DWORD tls = TlsAlloc ();

        ticks = GetTickCount ();
        for (i = 0; i < 100000000; i++) {
                foo = i + 1;
        }
        printf ("elapsed %d for __thread\n", GetTickCount () - ticks);

        ticks = GetTickCount ();
        for (i = 0; i < 100000000; i++) {
                TlsSetValue (tls, (LPVOID)(i + 1));
        }
        printf ("elapsed %d for TlsSetValue\n", GetTickCount () - ticks);
}
---

See the difference?

And yes, Mono is compiled w/out __thread support on Windows.
Patches are welcome ;)

Robert

_______________________________________________
Mono-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to