Note that there are some explanatory texts on larger screens.

plurals
  1. POJava ScheduledExecutorService - Need advice on real time performance issue
    primarykey
    data
    text
    <p>I have a created a multithreaded application that executes different tasks with the same ScheduledExecutorService (method scheduleAtFixedRate and a fixed threadpool of 10 threads). However all threads except one main task (not to be confused with the main thread!) are asleep most of the time, until there is user input. The data that is shared between the main task and the other (user input) threads is protected by lock objects in synchronized blocks. </p> <p>The main task executes a reoccuring task at a fairly large frequency, let's say 25 Hz (i.e. period of 40 ms), and it's important that this task is executed timely. Typically this is also the case, but unfortunately not all the time. Other "nice" applications are also running on the same computer (Linux OP), but CPU&lt;&lt;100%.</p> <p>During 60 minutes of measurement (i.e. 90000 samples) the actual period between two consecutive samples were >= 60 ms in about 50 cases, and in about 30 of these the period was over 100 ms, in a couple of really bad cases (fairly close to each other in time, in the order of seconds), the period was between 1000 and 2300 ms. No user input was given during measurement. Looking at the data logs, it seems obvious that something has prevented the executor from doing its job during these intervals, since they are often followed by a "catch up" of the Executor, i.e. multiple logs from the application within 2 or 3 ms.</p> <p>I've tried periodic garbage collection at each execution of the task, but (at least in the short term perspective) it only seems to make things worse. I have also measured the execution time of the task. It is mostly around 1 ms, and it should not cause the Executor to break down (or should it?). There <em>are</em> deviations here too, occasionally in the order of 100 ms, but they would explain less than 50% of the delays. I have tried looking for TaskRejectedExceptions, found nothing.</p> <p>So my questions now are basically: What can I expect from a ScheduledExecutorService over time? Is this likely to be a thread problem, despite the fact that only the main task should be running during these circumstances? What might cause the ScheduledExecutor to stop executing temporarily, only to flood the logs with its "catch up" data, and is there any method to control this annoying behaviour? Could any of this be related to the fact that my JVM is just a normal JVM without real time priority capabilities? Any help, ideas or theories on where to start digging, are truly appreciated!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload