-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
LUCENE-8213: Introduce Asynchronous Caching in LRUQueryCache #815
Conversation
08080fc
to
819acd2
Compare
I ran luceneutil for wikipedia 10M with the concurrent searching and latency calculation patch applied. https://gist.github.com/atris/e0fa10e79fb5ef62bd571406acf98433 There was no significant degradation to QPS, and the P999 and P100 latencies generally saw an improvement |
It should be enough to report the stats after the last iteration - it is cumulative, so the previous ones just add noise? I agree QPS looks pretty noisy, probably no real change. Could you post the latency stats in a more readable table here? It looks as if you have markdown there: I think github will accept that |
I dont think thats true, since each run is its own JVM? |
Another set of runs on wikimedium all with concurrent searching enabled:
Seems there is no degradation? |
Rebased with master. Any thoughts on this one? Seems like a useful change with no degradation in the happy path? |
It is true -- |
+1 to inline the latency results in a readable way here. |
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
Outdated
Show resolved
Hide resolved
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
Outdated
Show resolved
Hide resolved
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
Outdated
Show resolved
Hide resolved
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
Outdated
Show resolved
Hide resolved
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
Outdated
Show resolved
Hide resolved
@mikemccand Thanks for the inputs, updated the PR. Please let me know your comments |
Any further thoughts on this one? |
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
Outdated
Show resolved
Hide resolved
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
Outdated
Show resolved
Hide resolved
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
Outdated
Show resolved
Hide resolved
@mikemccand Thanks for reviewing -- updated per comments. Please see and let me know your thoughts. |
lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java
Outdated
Show resolved
Hide resolved
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
Outdated
Show resolved
Hide resolved
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
Outdated
Show resolved
Hide resolved
@mikemccand Thanks, fixed. Interestingly, moving the asynchronous load check to |
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
Outdated
Show resolved
Hide resolved
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
Outdated
Show resolved
Hide resolved
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
Outdated
Show resolved
Hide resolved
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
Outdated
Show resolved
Hide resolved
List<Query> inFlightQueries() { | ||
lock.lock(); | ||
try { | ||
return new ArrayList<>(inFlightAsyncLoadQueries); |
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'm still confused about lock
-- do we always hold the lock when checking if query is already in the map? If so, we don't need a ConcurrentHashMap
? If not, why do we even have the lock
since it is a ConcurrentHashMap
.
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.
Not all places which access inFlightAsyncLoadQueries
take a lock -- the main being cacheAsynchronously
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 specific access site does not lead a lock -- thanks for highlighting that, fixed!
@mikemccand Thanks for your inputs, updated the same |
Ahh that is a nice side effect! |
Indeed! Does the latest iteration look ready? Anything that sticks out? |
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
Outdated
Show resolved
Hide resolved
return in.scorerSupplier(context); | ||
} | ||
else { | ||
docIdSet = cache(context); |
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 think this means async caching can be more efficient, because with single threaded caching, multiple threads could do the work to try the cache the same Query
, with only one of them winning in the end, but with async caching, we ensure only one search thread does the caching? So e.g. red-line QPS (capacity) could be a bit higher with async, if queries are often duplicated at once?
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.
+1, that is a great observation, thanks for highlighting it!
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
Outdated
Show resolved
Hide resolved
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
Outdated
Show resolved
Hide resolved
@mikemccand Updated the PR, please see and let me know. |
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
Outdated
Show resolved
Hide resolved
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
Outdated
Show resolved
Hide resolved
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
Outdated
Show resolved
Hide resolved
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
Outdated
Show resolved
Hide resolved
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
Outdated
Show resolved
Hide resolved
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
Outdated
Show resolved
Hide resolved
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
Outdated
Show resolved
Hide resolved
@mikemccand Updated, please see |
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 left some minor comments ... I think this is ready after that! Thanks @atris! This is an exciting change, especially because it means in some cases (same query in flight in multiple query threads), if you pass an Executor
to IndexSearcher
, it's more efficient than the single threaded case.
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
Outdated
Show resolved
Hide resolved
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
Outdated
Show resolved
Hide resolved
Thanks @mikemccand ! This was an extensive review -- thank you for spending the time on it! |
Ran the Lucene test suite on the latest iteration -- came in clean. |
No description provided.