2013 R3 is not usable for production apps for me

The choice was NOT yielding reliably (or at all) or this behavior
We’re aware of it

Can’t remember where I read that. It was within the last month or so.

At any rate, I took your last example in the cocoa feedback and looked at the Activity Monitor process sampling under 2013r2 and 2013r3. The shape of the calls definitely differ. Under r2, you can see the internal calls coming back out of depth.
Under 2013r3, the call depth stays at the same depth a lot longer before coming back out.

Without labels for what the framework calls, we can only roughly guess at what is happening, but yes, I agree the support system for thread dispatch is behaving differently.

Michael. one thought…

Would your app work if you had your threads end, but get periodically restarted by a recurrent timer?
That might affect improve the interaction with the thread dispatch system.

We us a lot of threads for asynchronous communications, background data loading. All our threads END and get restarted. We aren’t seeing the continual CPU usage under 2013r3. That’s why I suspect ending and restarting your threads might help. Sorry, don’t have time to test that out for you here.

Michael, can you have your thread end and then get restarted (if not already running) by a periodic timer?
I think that might help with the new bad interaction with the thread dispatcher.

We use a lot of threads, but they all end and get restarted. No problems with high CPU usage for us under 2013r3.
Sorry, don’t have time to test it here for you

Weird… posting issue on forum. Might see a semi duplicate post above. The first post attempt didn’t appear so I rewrote

No.

At this time I am posting, the system shows that the last poster was Joe. And there are no traces of his activity here.

Ok. I made a post and Joe’s post showed up, but mine not. We must post some garbage to the last post appear. Last post never shows up.

.

[quote=35633:@Michael Diehr]I have a lot of code that looks like this:

cThread.Run (a Thread subclass)
while true
if (there is stuff to do)
do a chunk
sleep(1) // yield some time, then come back and do more work
else
// nothing is happening
sleep(10) // no work to be done, sleep a little longer
end if
wend[/quote]

I don’t have Xojo installed at the moment (to frustrated to work with in windows). But, I did not know you could write “Sleep(1)” instead of “me.sleep(1)” in your thread.run

I don’t have Xojo installed at the moment (to frustrated to work with in windows). But, I did not know you could write “Sleep(1)” instead of “me.sleep(1)” in your thread.run

It depends on where the code is. If it’s part of an instance on a window, then the Run event is actually part of the window’s code, so “me” is required. If it’s in the definition of a thread subclass, then the code is owned by the thread, and “me” is optional.

Has to to be me.sleep, otherwise compiler doesn’t know

Tested the timer work around and it appears to avoid the CPU cycle burn. By scheduling the sleep and restart of the thread via a timer, the CPU burn rate remain comparably low under 2013r2 and 2013r3.

added timer1 with a period of 1 and mode = timer.modeOFF
timer1 action is

  if checkbox1.value then
    if thread1.State = Thread.NotRunning then
      thread1.run
    else
      if thread1.State <> Thread.NotRunning then
        thread1.kill
      end
    end    
  end if
  

Changed your thread run to

  dim a as integer
  dim i as integer
  
  'do some busy work to use CPU cycles
  for i = 1 to 100000
    a = a * 1.0
  next
  
  timer1.Period = 1000 'the equivalent amount to sleep
  timer1.Mode = timer.ModeSingle
  timer1.Reset 'after which timer will restart this thread

Changed your CheckBox1.action to

timer1.Reset

junk post to make prior post appear

Has anyone of you considered using a Semaphore for putting a thread to sleep until it’s ready to be used again?

I.e, instead of Thread.Suspend, use a Semaphore that’s getting locked. And instead of Thread.Resume unlock the Semaphore.

Though, I admit, I do rely on Thread.Suspend/Resume a lot as well, and am now worried that this will keep my app’s CPU usage high, too.

Besides, yesterday I found that Threads do not play well with the Profiler - I get useless results. Also, it leads to crashes when killing threads because the Profiler code seems to change the app’s behavior. Sigh.

Jeez, I just added a long post here and now it’s disappeared after pressing “Post a Reply”. !@#$% forum!

Ah, cursing helps.

Treat the forum like it’s always going to glitch out and you’ll never be disappointed. Ctrl + A, Ctrl + C before you post. Works for the Xojo IDE too.

If you agree with this issue (and the cursing), please add your vote here: https://forum.xojo.com/5081-last-post-not-appearing-in-long-fragmented-threads/p1

Haha, Joshua. Feel like cursing now, too? :smiley: