Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Unexpected 50ms delay for all jobs(Scheduled job is often executed excatly 50ms after the scheduling time, why?)
Unexpected 50ms delay for all jobs [message #1017225] Mon, 11 March 2013 04:58 Go to next message
Leung Wang Hei is currently offline Leung Wang Hei
Messages: 62
Registered: July 2010
Member
Job is often found to be executed exactly 50ms after the scheduling time.

To reproduce:
1. Create a plugin project with RCP application with a view template
2. Replace of the attached View.java
3. Double click at any table item and schedule the job for 1 second.

Here is the output:
1362985303755 --- schedule job in ms: 1000
1362985303755 job scheduled
1362985304805 job about to run
1362985304805 --- do job.  Wait time=1050


Seems it is related to a 50 ms sleep in WorkerPool.startJob(Worker)

long hint = manager.sleepHint();  // return 0 if some jobs are waiting

...

job = manager.startJob();

...

//if we didn't sleep but there was no job available, make sure we sleep to avoid a tight loop (bug 260724)
if (hint <= 0 && job == null)
     sleep(50);


As said in bugzilla https://bugs.eclipse.org/bugs/show_bug.cgi?id=260724]:
Quote:

If the startJob() returns null, it implies the wait queue is empty and there are no sleeping jobs that are ready to run. The only case I can think of this happening is if multiple threads are awake at once in this loop. If there was one job waiting, the sleep hint would be 0 for all threads, but then only one thread will pop the job from the queue and the others will get null.


I break at the sleep(50) line and found the following sequence, not exactly as described above:

1. Schedule job for 1000ms
2. WorkPool triggered after 1000ms
3. sleepHint=0, job=null >> sleep(50)
4. Next iteration in the while loop
5. sleepHint= -ve, job=actual job object
6. Job done. 50ms after the expected schedule time.

Setting priority and user, system flag gives no difference.

Is there some setting in Job and/or JobManager causing this issue?
  • Attachment: View.java
    (Size: 4.43KB, Downloaded 67 times)

[Updated on: Mon, 11 March 2013 05:00]

Report message to a moderator

Re: Unexpected 50ms delay for all jobs [message #1019737 is a reply to message #1017225] Sat, 16 March 2013 10:23 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de Alwis
Messages: 163
Registered: January 2012
Senior Member

Please file a bug!

Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Re: Unexpected 50ms delay for all jobs [message #1020927 is a reply to message #1019737] Tue, 19 March 2013 03:45 Go to previous message
Leung Wang Hei is currently offline Leung Wang Hei
Messages: 62
Registered: July 2010
Member
Bug filed: 403717

https://bugs.eclipse.org/bugs/show_bug.cgi?id=403717
Previous Topic:Support for developing WinCE application by using Eclipse IDE
Next Topic:Jcolon: Automatic Semicolon Inserter for Java in Eclipse 4
Goto Forum:
  


Current Time: Tue Jul 22 19:52:41 EDT 2014

Powered by FUDForum. Page generated in 0.14525 seconds