-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Rework MSE query throttling to take into account estimated number of threads used by a query #14847
Rework MSE query throttling to take into account estimated number of threads used by a query #14847
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #14847 +/- ##
============================================
+ Coverage 61.75% 63.73% +1.98%
- Complexity 207 1469 +1262
============================================
Files 2436 2708 +272
Lines 133233 151441 +18208
Branches 20636 23380 +2744
============================================
+ Hits 82274 96518 +14244
- Misses 44911 47673 +2762
- Partials 6048 7250 +1202
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
f0b0c1f
to
deaca57
Compare
…threads used by a query
pinot-common/src/main/java/org/apache/pinot/common/concurrency/AdjustableSemaphore.java
Outdated
Show resolved
Hide resolved
if (permits < _totalPermits.get()) { | ||
reducePermits(_totalPermits.get() - permits); | ||
} else if (permits > _totalPermits.get()) { | ||
release(permits - _totalPermits.get()); |
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.
This is confusing. If this method can be called concurrently, it doesn't seem we are protecting ourself agains races. If it cannot be called concurrently, it seems odd to use an atomic integer
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.
You're right, we can't actually have concurrent modifications. Only potential concurrent reads during modifications. I think we can simply use a volatile int instead (I guess even the volatile is not strictly necessary as we can tolerate stale values without many issues tbh).
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.
That is what I thought. Volatile should be enough to be correct. In practice, you could even remove the volatile as you suggest, but in theory, that could imply that the reader threads never read the new value. Also, IIRC, in x86, to read a volatile attribute that was not modified is exactly as to read a nonvolatile attribute. The only actual issue is if that attribute ends up creating false sharing with another, frequently written, not volatile attribute
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.
Interesting, thanks for that info!
The only actual issue is if that attribute ends up creating false sharing with another, frequently written, not volatile attribute
Wouldn't the other attribute also need to be volatile?
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.
I was wrong. The issue is when a frequently written volatile is in the same cache as a non-volatile frequently read attribute. Each writes into the volatile will evict the cache line, so other threads reading the non-volatile will need to read the line again (https://medium.com/@ali.gelenler/cache-trashing-and-false-sharing-ce044d131fc0)
deaca57
to
53e22af
Compare
maxConcurrentQueries * numServers / numBrokers
. Since the max concurrent queries is a "per server" config, the calculation incorrectly makes the assumption that queries are executed on a single server (instead of assuming that they're dispatched to all servers which is a better assumption).maxServerQueryThreads * numServers / numBrokers
which only makes the assumption that queries are evenly distributed across brokers (and no assumptions about the fanout to servers). This feature isn't intended to completely prevent large queries from executing so the cluster config should be set to a value that is at least large enough to accommodate queries that can spawn up tomaxServerQueryThreads * numServers / numBrokers
number of threads.