Skip to content

Conversation

@PeteGillinElastic
Copy link
Member

@PeteGillinElastic PeteGillinElastic commented Mar 10, 2025

This is intended to be used to efficiently calculate a write load metric for use by the auto-sharding algorithm which favours more recent loads.

The maths used here is explained in section two of the attached document.

The unit test serves the additional function of illustrating the behaviour of the EWMR in a way which is hopefully easy to understand. In particular, testEwmr_longSeriesWithStepChangeInRate_fitsHalfLife_contrastWithZeroLambda illustrates the issue we have seen in a number of recent support cases, and shows how the new thing (which a suitably chosen lambda) compares with the current metric (which effectively has lambda = 0).

@PeteGillinElastic
Copy link
Member Author

The maths used here is explained in section two of the attached document.

This is intended to be used to efficiently calculate a write load
metric for use by the auto-sharding algorithm which favours more
recent loads.
@PeteGillinElastic PeteGillinElastic added :Data Management/Stats Statistics tracking and retrieval APIs >non-issue labels Mar 10, 2025
@PeteGillinElastic PeteGillinElastic marked this pull request as ready for review March 10, 2025 17:40
@PeteGillinElastic PeteGillinElastic requested a review from a team as a code owner March 10, 2025 17:40
@elasticsearchmachine elasticsearchmachine added the Team:Data Management Meta label for data/management team label Mar 10, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

throw new IllegalArgumentException("lambda must be non-negative but was " + lambda);
}
if (startTimeInMillis <= 0.0) {
throw new IllegalArgumentException("lambda must be non-negative but was " + startTimeInMillis);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

startTime must be ....

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, well spotted.

Copy link
Contributor

@parkertimmins parkertimmins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than a minor exception message fix, this looks good to me. The thread-safety looks correct and I think it accurately reflects the math in the linked pdf.I feel less confident to speak about that math itself; though what I did read made sense. Really cool analysis and work. I particularly like the work to making it numerically stable.

@PeteGillinElastic
Copy link
Member Author

Thanks @parkertimmins !

@PeteGillinElastic
Copy link
Member Author

I belatedly noticed that the code which is going to use this actually measures times using nanoTime() rather than currentTimeMillis(). This class is actually agnostic about the time measurement used. So I can make it explicitly agnostic just by tweaking the parameter names and javadoc. I'm going to do that now — let me know if you'd like a chance to review that, but it should be mechanical.

@PeteGillinElastic PeteGillinElastic merged commit 43eee87 into elastic:main Mar 12, 2025
17 checks passed
@PeteGillinElastic PeteGillinElastic deleted the ES-10037-ewmr branch March 12, 2025 10:10
albertzaharovits pushed a commit to albertzaharovits/elasticsearch that referenced this pull request Mar 13, 2025
This is intended to be used to efficiently calculate a write load
metric for use by the auto-sharding algorithm which favours more
recent loads.

ES-10037 #comment Core algorithm added in elastic#124507
jfreden pushed a commit to jfreden/elasticsearch that referenced this pull request Mar 13, 2025
This is intended to be used to efficiently calculate a write load
metric for use by the auto-sharding algorithm which favours more
recent loads.

ES-10037 #comment Core algorithm added in elastic#124507
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Data Management/Stats Statistics tracking and retrieval APIs >non-issue Team:Data Management Meta label for data/management team v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants