-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Limit frequency of feature last-used time updates #133004
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
Limit frequency of feature last-used time updates #133004
Conversation
Pinging @elastic/es-security (Team:Security) |
Hi @joegallo, I've created a changelog YAML for you. |
This test failure is real:
If we end up doing something like what this PR is proposing, then we'd need to address this test assertion: Lines 434 to 436 in 1f9b6bb
|
Perhaps it's worth doing the same benchmarks with different intervals to see where we get diminishing returns. I agree that 10 seconds is probably too coarse.
That assertion doesn't seem to provide much value from what I can tell. I suspect we can relax it or remove it entirely. |
Heh, it's possible the value might even just be if the logic is "don't bash the same value in repeatedly!" (i.e. if the minimum millis diff is just 1). Anyway, I'll run my benchmark a few times and see what I find. |
Heh, yeah, at least for the feature I'm benchmarking, if we change it to only updating the usage timestamp if the timestamp has increased, then the lock contention falls out completely. See bfdeb0c. |
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.
can't find any fault with this approach
x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java
Show resolved
Hide resolved
Hi @joegallo, I've updated the changelog YAML for you. |
It turns out that this was related to #111473. |
I ran into this while benchmarking some search code that uses a licensed feature. There was enough lock contention on updating the last used time for that feature that it showed up in a lock flamegraph, so I added this logic to update the last used time less often.
I'm not attached to ten seconds, I think we would probably see an improvement if we even just limit it to once a second. 🤷(edit: I changed the logic.)For most features, I don't think this would make a difference, but I know for example that the
redact
processor is running a check on every document, so I could see how the existing logic could cause a problem.It's not useful to have multiple threads banging away on the map just to put the same value in repeatedly, so now the logic is that the last used time is only updated if it has increased (or if it isn't present at all, as it would be on a fresh start).