Opened 14 years ago
Closed 14 years ago
#1367 closed defect (done)
Updating ExecutionTime in Engine is not thread-safe
Reported by: | swagner | Owned by: | swagner |
---|---|---|---|
Priority: | medium | Milestone: | HeuristicLab 3.3.3 |
Component: | Core | Version: | 3.3.3 |
Keywords: | Cc: |
Description
The execution time of an Engine is updated using a System.Timers.Timer which processes its Elapsed events using worker threads from the thread pool. If the system is under high load and many worker threads are currently active, it might happen due to context switches that processing a single Elapsed event takes longer than the timer interval. In this case the Elapsed events overlap which results in wrong execution time values.
Change History (9)
comment:1 Changed 14 years ago by swagner
- Status changed from new to accepted
comment:2 Changed 14 years ago by swagner
comment:3 Changed 14 years ago by swagner
Implemented solution as described in the article and incremented timer interval to 250ms in r5240.
comment:4 Changed 14 years ago by swagner
- Owner changed from swagner to cneumuel
- Status changed from accepted to reviewing
comment:5 Changed 14 years ago by cneumuel
- Owner changed from cneumuel to swagner
- Status changed from reviewing to readytorelease
The ExecutionTime is now correctly updated even in my Meta-Optimization experiments.
My performance tests show that increasing the update-interval to 250ms was already a pretty good improvement.
The following ExecutionTimes are from small Meta-Optimization Runs with ParallelEngine. Each evaluation in Meta-Optimization also executes an algorithm which updates its own ExecutionTime. The runs were executed on a blade node with 8 cores, so approximately 9 threads were updating their ExecutionTime concurrently.
100ms | 250ms | 1000ms | |
---|---|---|---|
Run 1 | 01:06:35 | 00:36:41 | 00:30:36 |
Run 2 | 00:48:16 | 00:31:42 | 00:34:22 |
comment:6 Changed 14 years ago by swagner
- Status changed from readytorelease to reviewing
comment:7 Changed 14 years ago by swagner
Prevented ObjectDisposedException which was thrown in Engine when accessing an already disposed timer in r5444.
comment:8 Changed 14 years ago by swagner
- Status changed from reviewing to readytorelease
comment:9 Changed 14 years ago by mkommend
- Resolution set to done
- Status changed from readytorelease to closed
- Version changed from 3.3.2 to 3.3.3
In http://msdn.microsoft.com/en-us/magazine/cc164015.aspx the differences of .NET's timers are discussed. The problem of timer event reentrance is also covered at the end of the article.