On Tue, Feb 03, 2004 at 07:25:04AM +0100, Fredrik (Naranek) Hubinette (Real Build Master) @ Pike (-) developers forum wrote:
However, I'm still not entirely sure that this will be fast enough to be worth it. There will still be a lot of locking operations,
Most apps are single-threaded, so mutex ops will be no-ops effectively, but for those apps where multi-threading is important, the gain could overweight the loss, I guess.
Really, mutex op is quite fast (I guess max 3 instructions on most CPUs), so - is it really _so_ bad?
I think so.
Like I said before, I was experimenting with this a while back, and I added mutexes to a bunch of places in pike which had to be locked, and I used atomic operations to protect all add_ref() and free* operations.
At the time I less than half-way done, Pike was already 30% slower, and that was while running a single-threaded application, so it didn't actually have to wait for those mutexes, it just had to lock them. That's when I started realizing that Pike was going to become pretty slow when all my work was done, so I gave up and started thinking about alternative ways.
3 instructions might not sound very bad, but you have to consider that on a dual-cpu system, those instructions have to go out on the cpu bus and do some cache-coherency stuff to make sure that the other cpu isn't trying to do the same thing at the same time.
Also, you also need to realize that pike executes tens of millions of add_ref/free_* and other operations which would need to be locked per second.
However, there is hope. I'm not suggesting that this is impossible, I'm just saying that I have tried and failed, and hopefully something can be learned from that experience.
/ Fredrik (Naranek) Hubinette (Real Build Master)
Previous text:
2004-02-03 11:12: Subject: Re: Default backend and thread backends?
On Tue, Feb 03, 2004 at 07:25:04AM +0100, Fredrik (Naranek) Hubinette (Real Build Master) @ Pike (-) developers forum wrote:
However, I'm still not entirely sure that this will be fast enough to be worth it. There will still be a lot of locking operations,
Most apps are single-threaded, so mutex ops will be no-ops effectively, but for those apps where multi-threading is important, the gain could overweight the loss, I guess.
Really, mutex op is quite fast (I guess max 3 instructions on most CPUs), so - is it really _so_ bad?
Regards, /Al
/ Brevbäraren