tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Semantics of copying mutex/rwlock

> OK I wrote a simple benchmark.  It turns out malloc() is quite
> expensive, it's about 6 times slower to call malloc() for each mutex,
> compared to init/destroy pair.

(a) But you need to malloc only the new mutexes, whereas you need to
destroy/init all, including the old ones.  Or do you mean you profiled
actual use and found this difference between the two paradigms?

(b) Is this code run often enough that its performance matters?

If the answer to (b) is "no" (which I'd say is probably true of most
applications, but for all I know you might be dealing with one of the
exceptions), then I'd say you should use whichever one leads to cleaner
code, rather than worrying about which is faster.

/~\ The ASCII                             Mouse
\ / Ribbon Campaign
 X  Against HTML      
/ \ Email!           7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

Home | Main Index | Thread Index | Old Index