[YANGTOOLS-309] DurationStatsTracker is highly inefficient Created: 11/Sep/14 Updated: 10/Apr/22 Resolved: 15/Sep/14 |
|
| Status: | Resolved |
| Project: | yangtools |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | ||
| Reporter: | Robert Varga | Assignee: | Robert Varga |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Operating System: All |
||
| External issue ID: | 1813 |
| Description |
|
DurationStatsTracker is calculating running average in the fast path, incurring at least 4 volatile reads, 2 double-precision multiplies, 1 double-precision division and two compare-and-swaps. Optionally this includes another 2 CASes and 2 volatile writes. Reading the stats afterwards is a breeze, though. This is obviously biased in the wrong direction, so it needs fixing. |
| Comments |
| Comment by Tom Pantelis [ 11/Sep/14 ] |
|
The easiest thing is to put a sync block around it then nothing needs to be volatile (or Atomic) and no CAS needed. The updates should really be done atomically anyway. Of course the get's would need to be sync'ed too. With sync block we'd hit just 1 write memory barrier instead 1 for each volatile. The lock overhead would be negligible as it would be uncontended, at least for commits which are single-threaded. |
| Comment by Robert Varga [ 11/Sep/14 ] |
|
https://git.opendaylight.org/gerrit/11061 |