Skip to content
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

Daylight Savings Time Optimization Followups #56124

Closed
3 of 7 tasks
nik9000 opened this issue May 4, 2020 · 3 comments
Closed
3 of 7 tasks

Daylight Savings Time Optimization Followups #56124

nik9000 opened this issue May 4, 2020 · 3 comments
Assignees
Labels
:Analytics/Aggregations Aggregations Meta Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)

Comments

@nik9000
Copy link
Member

nik9000 commented May 4, 2020

After we merge #55559 we'll have a few things to clean up:

  • Implement interval rounding (Speed up time interval arounding around dst #56371)
  • Cache LocalTimeOffset.Lookups to avoid building them over and over again. They are quite expensive to build and would likely cache very well.
  • Investigate how expensive loading the min and max is. Maybe we can cache them on the reader or something.
  • Plug this in to auto_date_histogram. It could speed it up a ton. (Speed up rounding in auto_date_histogram #56384)
  • Remove the optimization that rewrites non-fixed time zones into fixed ones in date_histogram. It won't really do anything after we get interval rounding. (Drop rewriting in date_histogram #57836)
  • Speed up nextRoundingValue to make date histogram on date ranges faster.

Maybe:

  • Plug this in to composite. It might not benefit much from it but then again it might. It is worth checking.
@nik9000 nik9000 self-assigned this May 4, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo (:Analytics/Aggregations)

@elasticmachine elasticmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label May 4, 2020
@nik9000
Copy link
Member Author

nik9000 commented Jun 8, 2020

* Cache `LocalTimeOffset.Lookup`s to avoid building them over and over again. They are quite expensive to build and would likely cache very well.

The kind of cache that we'd need to build makes this maybe not something we should do. We'd get terrible hit rate if we just used the range and zone id as the key and java.util.time isn't that slow to give us the data that we need. I'll think about this one some more.

nik9000 added a commit to nik9000/elasticsearch that referenced this issue Jun 8, 2020
This deprecates `Rounding#round` and `Rounding#nextRoundingValue` in
favor of calling
```
Rounding.Prepared prepared = rounding.prepare(min, max);
...
prepared.round(val)

``` because it is always going to be faster to prepare once. There
are going to be some cases where we won't know what to prepare *for*
and in those cases you can call `prepareForUnknown` and stil be faster
than calling the deprecated method over and over and over again.

Ultimately, this is important because it doesn't look like there is an
easy way to cache `Rounding.Prepared` or any of its precursors like
`LocalTimeOffset.Lookup`. Instead, we can just build it at most once per
request.

Relates to elastic#56124
nik9000 added a commit that referenced this issue Jun 9, 2020
This deprecates `Rounding#round` and `Rounding#nextRoundingValue` in
favor of calling
```
Rounding.Prepared prepared = rounding.prepare(min, max);
...
prepared.round(val)

``` because it is always going to be faster to prepare once. There
are going to be some cases where we won't know what to prepare *for*
and in those cases you can call `prepareForUnknown` and stil be faster
than calling the deprecated method over and over and over again.

Ultimately, this is important because it doesn't look like there is an
easy way to cache `Rounding.Prepared` or any of its precursors like
`LocalTimeOffset.Lookup`. Instead, we can just build it at most once per
request.

Relates to #56124
nik9000 added a commit to nik9000/elasticsearch that referenced this issue Jun 9, 2020
This deprecates `Rounding#round` and `Rounding#nextRoundingValue` in
favor of calling
```
Rounding.Prepared prepared = rounding.prepare(min, max);
...
prepared.round(val)

``` because it is always going to be faster to prepare once. There
are going to be some cases where we won't know what to prepare *for*
and in those cases you can call `prepareForUnknown` and stil be faster
than calling the deprecated method over and over and over again.

Ultimately, this is important because it doesn't look like there is an
easy way to cache `Rounding.Prepared` or any of its precursors like
`LocalTimeOffset.Lookup`. Instead, we can just build it at most once per
request.

Relates to elastic#56124
nik9000 added a commit that referenced this issue Jun 9, 2020
This deprecates `Rounding#round` and `Rounding#nextRoundingValue` in
favor of calling
```
Rounding.Prepared prepared = rounding.prepare(min, max);
...
prepared.round(val)

```

because it is always going to be faster to prepare once. There
are going to be some cases where we won't know what to prepare *for*
and in those cases you can call `prepareForUnknown` and stil be faster
than calling the deprecated method over and over and over again.

Ultimately, this is important because it doesn't look like there is an
easy way to cache `Rounding.Prepared` or any of its precursors like
`LocalTimeOffset.Lookup`. Instead, we can just build it at most once per
request.

Relates to #56124
nik9000 added a commit to nik9000/elasticsearch that referenced this issue Jun 10, 2020
When reducing `auto_date_histogram` we were using `Rounding#round`
which is quite a bit more expensive than
```
Rounding.Prepared prepared = rounding.prepare(min, max);
long result = prepared.round(date);
```
when rounding to a non-fixed time zone like `America/New_York`. This
stops using the former and starts using the latter.

Relates to elastic#56124
nik9000 added a commit that referenced this issue Jun 10, 2020
When reducing `auto_date_histogram` we were using `Rounding#round`
which is quite a bit more expensive than
```
Rounding.Prepared prepared = rounding.prepare(min, max);
long result = prepared.round(date);
```
when rounding to a non-fixed time zone like `America/New_York`. This
stops using the former and starts using the latter.

Relates to #56124
nik9000 added a commit to nik9000/elasticsearch that referenced this issue Jun 10, 2020
When reducing `auto_date_histogram` we were using `Rounding#round`
which is quite a bit more expensive than
```
Rounding.Prepared prepared = rounding.prepare(min, max);
long result = prepared.round(date);
```
when rounding to a non-fixed time zone like `America/New_York`. This
stops using the former and starts using the latter.

Relates to elastic#56124
nik9000 added a commit that referenced this issue Jun 11, 2020
… (#57958)

When reducing `auto_date_histogram` we were using `Rounding#round`
which is quite a bit more expensive than
```
Rounding.Prepared prepared = rounding.prepare(min, max);
long result = prepared.round(date);
```
when rounding to a non-fixed time zone like `America/New_York`. This
stops using the former and starts using the latter.

Relates to #56124
@nik9000
Copy link
Member Author

nik9000 commented Mar 17, 2021

I think we're mostly comfortable where we are for now. I think we will end up plugging composite into these optimization eventually but that isn't a short term thing. The others don't seem to be a problem.

@nik9000 nik9000 closed this as completed Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Aggregations Aggregations Meta Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)
Projects
None yet
Development

No branches or pull requests

2 participants