PDA

View Full Version : Qt + OS X 10.9 = threading issues?



agarny
23rd June 2014, 16:09
Hi,

I am developing an application that can be used to run mathematical simulations. Each simulation is run in its own thread. Every works fine and everything, except that I recently noticed that if I have two simulations S1 and S2, then if I first run S1 then it will run ‘slowly’. From there, if I rerun S1 or run S2, then S1 or S2 will run ‘fast’. In other words, no matter which simulation I run the first time, it will run ‘slowly’ while any subsequent simulation will run fast. Just to give you an idea, the first time I run a particular simulation, it takes ~28.9 s to run while subsequent runs of that same simulation take ~12.7 s (!!).

In an attempt to pinpoint what might be causing this, I tried my application on Windows and Linux, and I didn’t experience that behaviour. From there, I thought I would try my application on older versions of OS X (I tried Mac OS X 10.7 and OS X 10.8), and again I didn’t experience that behaviour. Next, I decided to test previous versions of my application and they all experienced the same behaviour on OS X 10.9, but not on Mac OS X 10.7 or OS X 10.8.

So, there is clearly an issue between my application and OS X 10.9. Now, it may be worth pointing out that the different versions of my application were built using different versions of Qt (as well as of LLVM, of which I use its JIT engine to run my simulations). So, could it be that there is something in Qt that is not working ‘properly’ with OS X 10.9 (e.g. threading)? Alternatively, maybe there is something in LLVM that I don’t do and which is ‘required’ to work ‘properly’ in OS X 10.9?

So, has anyone ever come across something similar and/or would know how to fix this issue?

Cheers, Alan.

anda_skoa
23rd June 2014, 16:26
Hard to tell, but since you experience a slow down on the first run that does not appear in subsequent run it looks a lot like something related to the JIT and/or disk buffers.

Cheers,
_

agarny
23rd June 2014, 16:41
Thanks for your reply, anda_skoa. I agree that it's not an easy one to pinpoint, but I should probably have mentioned that no disk accesses are performed during the simulation. So, disk buffering is not an 'option' here. On the other hand, the JIT might be a route worth investigating even though this wouldn't explain (to me, at least) why if I run simulation S1 then it's 'slow', but then if I run simulation S2 then it's 'fast'. Indeed, before running the simulation I will generate the JIT code. Also, it's not only the simulation (and therefore JIT code) that is slow, it's the whole simulation thread. In other words, anything I do within that simulation thread is slow the first time round.

agarny
19th September 2014, 11:17
FWIW, this issue has been resolved by upgrading LLVM from version 3.4.2 to version 3.5.