Re: Problem with hyperthreading and Indy

Giganews Newsgroups
Subject: Re: Problem with hyperthreading and Indy
Posted by:  mattias fagerlund (matti…@cambrianlabs.com)
Date: Mon, 6 Sep 2004

> I've written a server with Borland Delphi5 using Indy 9.00.14
> as part of a bigger system that doesn't work properly when
> hypertheading is enabled, so if someone has some experience of using
> Delphi5 and Indy in hyperthreaded Pentium4 or SMP machines, I would
> appreciate your help.

I had a multi threaded application that ran perfectly (using Indy) until I
got my hyperthreaded computer - then it started bombing at random times. It
turned out that the bug was actually Indy related (the SSL components -
since fixed and commited) but it's fairly likely that that the bug is yours
and not indys. In my experience, hyper threaded CPUs are MUCH likelier to
trigger a threading bug than a normal CPU - it's also much likelier to
trigger a threading bug than an multi-CPUmachine (again in my experience).

One thing to watch out for is code like this;

...OnExecute...
begin
..
  MyObject : = TComponent.Create(GlobalOwnerObject);
...
end;

TComponent.Create is NOT thread safe if there's a chance that it might be
called from several threads at the same time on the same owner object.
TComponent.Create(nil) is always safe though. Note that protecting the
"Create" part isn't sufficient, the destroy part must also be protected
since it accesses the owners list of children.

This was one the SSL issues that were found and fixed. Make sure that all
methods you call are in fact thread safe and protect all others.

with regards,
mattias

Replies

None

In response to

Problem with hyperthreading and Indy posted by Miguel Colom on Thu, 12 Aug 2004