Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Threads

Author: Bruce Moreland

Date: 09:12:52 04/07/99

Go up one level in this thread



On April 07, 1999 at 11:06:54, KarinsDad wrote:

>On April 07, 1999 at 01:29:30, James Robertson wrote:
>
>[snip]
>>
>>Just out of curiosity, how does a critical_section do this? Is it something
>>built into Windows?
>>
>>James
>
>James,
>
>If you can write your "critical section" in assembly as Bruce suggests, do so.
>Any Windows API call is not worth it performance wise, especially system calls.
>
>KarinsDad :)

No way.

Assembly code sucks because it is hard to maintain and is platform dependent.
The performance benefits are often completely not worth it.  Meaning, if you
write some nasty piece of code in assembly, and can't tell the difference
between that and using the portable, well-behaved, maintainable version that
uses the system call, by all means use the system call.

The only reason it's even worth trying assembly code in this case is that the
code can be very small (which is important only from a maintenance standpoint),
it can be containerized so that it's easy to switch back and forth, you can't
really do this sensibly *without* assembly code, and the program *may* spend a
lot of time in that part of the code (so it's worth checking it out).

I have a #define in my program right now that lets me switch back and forth
between an assembly coded spin-lock and a critical-section, with a simple
recompile.  I haven't found a case yet where performance is improved measurably
by using the assembly coded version, so I keep that #define off and stay
compatible with the rest of reality.

I think assembly code is something that you  have if you need it, but you don't
want to use it unless you really need to, and you can almost always avoid it.

Using it in uncontrolled and extensive fashion is like selling your soul.  You
might get a performance increase, but from that point it's hard to make changes
and you're stuck on that platform.  Your ability to do research is retarded (an
experiment that takes ten minutes to set up in C now takes two hours), and you
can't take advantage of a new machine that you happen to get access to.

The sick thing is that I think a lot of the time people do it they don't even
get the performance increase, so they are selling their soul for nothing.

Anybody who spends time rewriting Windows API calls in assembly code is probably
making a huge mistake, since somebody who knows what they are doing has spent a
lot of time on those calls, typically.

bruce



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.