-
Notifications
You must be signed in to change notification settings - Fork 830
address todos #1832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
address todos #1832
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,8 +15,22 @@ | |
| * <p>It is implemented in a generic way so that 3rd party libraries can use it for implementing | ||
| * sliding windows. | ||
| * | ||
| * <p>TODO: The current implementation is {@code synchronized}. There is likely room for | ||
| * optimization. | ||
| * <p><b>Thread Safety:</b> This class uses coarse-grained {@code synchronized} methods for | ||
| * simplicity and correctness. All public methods ({@link #current()} and {@link #observe(double)}) | ||
| * are synchronized, which ensures thread-safe access to the ring buffer and rotation logic. | ||
| * | ||
| * <p><b>Performance Note:</b> The synchronized approach may cause contention under high-frequency | ||
| * observations. Potential optimizations include: | ||
| * | ||
| * <ul> | ||
| * <li>Using {@link java.util.concurrent.locks.ReadWriteLock} to allow concurrent observations | ||
| * <li>Using lock-free data structures with {@link java.util.concurrent.atomic atomic} operations | ||
| * <li>Implementing a lock-free ring buffer with striped buckets | ||
| * </ul> | ||
|
||
| * | ||
| * <p>However, given that Summary metrics are less commonly used (Histogram is generally preferred), | ||
| * and the observation frequency is typically lower than Counter increments, the current | ||
| * implementation provides an acceptable trade-off between simplicity and performance. | ||
| */ | ||
| public class SlidingWindow<T> { | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1526,6 +1526,50 @@ void testObserveMultithreaded() | |||||
| assertThat(executor.awaitTermination(5, TimeUnit.SECONDS)).isTrue(); | ||||||
| } | ||||||
|
|
||||||
| @Test | ||||||
| public void testNativeResetDuration() { | ||||||
|
||||||
| public void testNativeResetDuration() { | |
| void testNativeResetDuration() { |
zeitlinger marked this conversation as resolved.
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| public void testNativeResetDurationNegativeValue() { | |
| void testNativeResetDurationNegativeValue() { |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| public void testNativeResetDurationZeroValue() { | |
| void testNativeResetDurationZeroValue() { |
Uh oh!
There was an error while loading. Please reload this page.