-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Time series based workload sort optimization through Lucene segment sorting in DocumentReader #6814
Comments
@dblock @reta @nknize @backslasht @Bukhtawar , what do you guys think on this ? |
@gashutos thank you, have you seen this one TimeSeries optimizations in OpenSearch ? On more general note, the improvements are looking really worth the optimization, but I do not see clear means on how we could rightly conclude that the index fits this type of workload (== has time series and getting ingested in particular order), unless we restrict it to data streams where @timestamp is explicit (Elasticsearch shared similar optimizations https://www.elastic.co/blog/optimizing-sort-queries-in-elasticsearch-for-faster-results). |
@reta I think that proposal has some limitations with Point based sort optimizations we have now. I am still confirming that with Rishabh if I am not missing something. By merging dimensions, we will lose ability to have them sort based on Point Based values. I think ir-respective of that, the code change with this approach are very less and gets sizable improvement, while we fine grain above approach, we can productize and improve with mentioned approach, since changes are within OpenSearch repo itself. |
@gashutos - This looks like a promising optimization, few questions.
|
Tagging @nknize |
Couple of quick questions:
|
@nknize @backslasht thank you for looking at proposal. @nknize while I am checking 1st & 3rd one, just quick clarification on 2nd one...
This I was talking about #3734 proposed by Rishabh. That appraoch has some contradiction with point based optimization from the high level it looks like to me. |
Ah, it's been a while since we worked that one! So at the Lucene level that's for dedicated I'd start first by exploring the shuffle merge policy and benchmarking to assess any gains there. I definitely have reservations about forcing a specific |
@nknize I did benchmarking for ShuffleMergePolicy, I think numbers are not promising. I take away two things from it,
Below are the results aI collected from http_logs workload on single shard with 3.7 G size. initially this shard has 135 segments and then forced merge to single segment.
I think, this policy we can improve more within segment merge itself but still if we look at real production scenario, we will still end up having segments (group of segments) in asc order of timestamp, newer segments would be latest.
I see the code right now, the way we create IndexWriter and DocumentReader from it only once upon boot up. I was thinking if we can make this sorting order based on sort type during query time, then your concern would be justified right ? let me dig into that more and find if we can have a way around for that.... |
@backslasht @reta ,
I think we may not need to bind this segment ordering to only one type of workload (time series based). If data is uniformerly distributed across segments, order of traversing through segments wont matter. I did this exercises in nyc_txy workload on total_amount/tip_amount fields and I dont see any regression over queries there. This optimization we will only apply when query types has
This I am still running and will probably have results in some time, will keep posted here. |
Observation
I have noticed through http_logs worklad of OSB, that desc sort on @timestamp field is taking a lot more then asc order sort. There is definitly an improvement we can do here arranging lucene segments in respective order of asc/desc based on sort type specified. We can address this on query time and before I put down my POC numbers & performance gains we got with this, let me give you context.
For the context,
We enabled NumericField Point based sort optimiaztions for all NumericTypes in these 2 PRs (6321 & 6424).
As mentioned in PRs, the performance gains we got through this was a lot, as it skips iterate/compare over non-competitive documents based on its Point values. The basic concept here is, we give a target value and try to find 'k' closest points to these target value and skip other value which we consider non-competitive. Lucene already does it on _score values. now instead of _score, we do it on Point values through above optimizations.
Suggested fix
Now in time series based workload, since all latest timestamp comes in last for a shard in its segment arrangment, the desc query tends to take lot of time and if we reorder them in descending order at DocumentReader level, we can skip iterating over non-competitive segments which were aligned ahead of competitive segments in case of time series event.
Descending/ascending order document retrieval in timeseries workload is very common scenario and based on POC, I see we are gaining 3x to 4x on this optimization.
All we need to do is, at query time, we need to provide sort order for segment here in subReaderSorted while creating DocumentReader object.
Below are the numbers for my POC. Sorting is performed on @timestamp field
This work load is used (http_logs)
The operation was performed on single index size of 12.9 G with 4 shards with 136 segments on it.
If you see, we are gaining anywhere between 3x to 4x here on @timestamp field sorting.
Few considerations before implemeting this,
The text was updated successfully, but these errors were encountered: