Repository navigation
Add TaxonomyReader#getBulkOrdinals method (#12180) - #12769
Conversation
There was a problem hiding this comment.
This looks great @epotyom - I left some small comments.
I wonder what performance impact this might have for heavy Lucene facet use cases... but we don't need to block this nice API with specific benchmarking. It can come later. Maybe we could (later) fix Lucene's nightly benchmark in luceneutil for faceting tasks to use this new API... maybe open an issue there?
| private void assertGettingPaths( | ||
| DirectoryTaxonomyReader reader, FacetLabel[] expectedPaths, int[] sourceOrds) | ||
| throws IOException { | ||
| // To exercise mix of cache hit and cache misses for getPath and getBulkPath this method: |
| src.close(); | ||
| } | ||
|
|
||
| private void assertGettingOrdinals( |
There was a problem hiding this comment.
Could we maybe add a thread safety test as well, if we aren't already testing across threads? Index many FacetLabel -> ord, open reader, spawn threads all doing random lookups and confirming the ords are correct? Maybe with random cache sizes so we sometimes face evictions?
There was a problem hiding this comment.
There is testCallingBulkPathReturnsCorrectResult test (I renamed it to testGetPathAndOrdinalsRandomMultithreading) which runs multiple threads. It used to only call getBulkPath, I changed it to use assertPathsAndOrdinals, which means that each thread somewhat randomly calls getPath, getBulkPath, getOrdinal and the new getBulkOrdinals. But maybe we can improve it:
- It creates an array of 1K random facets, and the cache size
DEFAULT_CACHE_VALUEis 4K, so there are no evictions AFAIU. I can change the array size to something like 10K to sometimes cause evictions. - I'm not sure if calling all 4 methods in test threads is the right thing to do as it reduces chances for "collisions" e.g. calling getBulkPath and getBulkOrdinals in parallel is unlikely to reveal any issues because these 2 methods use different cache instances, etc. I think I can split into 2 tests: one to randomly call getPath+getBulkPath in multiple threads, and another one to do the same for getOrdinal+getBulkOrdinals?
There was a problem hiding this comment.
Pushed the branch with the changes, please review!
| * found. | ||
| */ | ||
| public int[] getBulkOrdinals(FacetLabel... categoryPath) throws IOException { | ||
| int[] ords = new int[categoryPath.length]; |
There was a problem hiding this comment.
I love the above javadoc, but maybe additionally add comment here that this is the simple & slow base class / default implementation, and note that DirectoryTaxonomyReader has an optimized and more complex version?
|
Thank you for reviewing @mikemccand !
I can make sure that we have a task that calls this method (indirectly) in the next step for this issue - adding bulk Facets#getSpecificValues, will that be ok? |
6c40956 to
7384fea
Compare
7384fea to
dc943c5
Compare
+1, thanks! |
mikemccand
left a comment
There was a problem hiding this comment.
Looks great, thank you @epotyom -- I'll merge.
| String randomArray[] = new String[RandomizedTest.randomIntBetween(1, 1000)]; | ||
| final int maxNumberOfLabelsToIndex = 1000; | ||
| final int maxNumberOfUniqueLabelsToIndex = maxNumberOfLabelsToIndex / 2; | ||
| final int cacheSize = maxNumberOfUniqueLabelsToIndex / 2; // to cause some cache evictions |
|
I think this is safe to backport to 9.x? I'll do that, and move the |
|
Hi, the commit causes test failures like this from time to time: And hundreds of more threads following. Looks like sometimes the ordinals array is initialized by zero length. The followup random then fail because the upper bound passed to |
|
Looks like the ordinals array sizes must be at least 1, so in general the initial setup of the ordinal size must use |
|
Thanks Uwe and sorry! I think Egor is digging on this or I’ll revert soon.
Mike
…On Thu, Nov 9, 2023 at 1:17 PM Uwe Schindler ***@***.***> wrote:
Assigned #12769 <#12769> to
@mikemccand <https://github.com/mikemccand>.
—
Reply to this email directly, view it on GitHub
<#12769 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGCOXG67B2SCUM3KOMVQATYDUMWJAVCNFSM6AAAAAA67KSVAGVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJQHEYTMNJUGE4DIMQ>
.
You are receiving this because you were assigned.Message ID:
***@***.***>
|
|
Hi all,
Sorry for the bug, this pull request should fix it:
#12790
Kind regards,
Egor
On Thu, 9 Nov 2023 at 18:52, Michael McCandless ***@***.***>
wrote:
… Thanks Uwe and sorry! I think Egor is digging on this or I’ll revert soon.
Mike
On Thu, Nov 9, 2023 at 1:17 PM Uwe Schindler ***@***.***>
wrote:
> Assigned #12769 <#12769> to
> @mikemccand <https://github.com/mikemccand>.
>
> —
> Reply to this email directly, view it on GitHub
> <#12769 (comment)>, or
> unsubscribe
> <
https://github.com/notifications/unsubscribe-auth/AAGCOXG67B2SCUM3KOMVQATYDUMWJAVCNFSM6AAAAAA67KSVAGVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJQHEYTMNJUGE4DIMQ>
> .
> You are receiving this because you were assigned.Message ID:
> ***@***.***>
>
—
Reply to this email directly, view it on GitHub
<#12769 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB2PTB64YT2MERZA3TGKEKTYDUQ7NAVCNFSM6AAAAAA67KSVAGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBUGM4TMOJWGM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
| } | ||
| } | ||
| // all ordinals found in cache | ||
| if (indexesMissingFromCache.length == 0) { |
There was a problem hiding this comment.
With AI pocking around the code, I found that this condition never passes.
Fix: #16783
Add TaxonomyReader#getBulkOrdinals method (#12180)
This is the first step for #12180 , next step will be to implement
Facets#getSpecificValues(bulk) that callsgetBulkOrdinals, will do it in a separate PR.