Skip to content

Conversation

@dnhatn
Copy link
Member

@dnhatn dnhatn commented Jul 29, 2025

I ran a time-series benchmark and saw overhead when converting longs to doubles. This change removes the TODO and implements the sealed interface for ToDouble.

@dnhatn dnhatn requested a review from nik9000 July 29, 2025 06:42
@dnhatn dnhatn marked this pull request as ready for review July 29, 2025 06:42
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Jul 29, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

* but it gets the job done for now.
*/
public interface ToDouble {
public sealed interface ToDouble permits SortableLongToDouble, SortableIntToFloat, SortableShortToHalfFloat, LongToScaledFloat {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: I do not think we need permits when all implementations are in the same file, do we?

/**
* Convert from the stored {@link long} into the {@link double} to load.
* Sadly, this will go megamorphic pretty quickly and slow us down,
* but it gets the job done for now.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change enough to prevent megamorphic call?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd have expected that you'd need to make a copy of read(BlockFactory factory, Docs docs, int offset) for each one. but I could certainly be wrong here.

Copy link
Contributor

@idegtiarenko idegtiarenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not mind the change, however I am interested to know if that actually improves the benchmark

@martijnvg
Copy link
Member

@dnhatn Are you planning to merge this? I think this would be beneficial, especially in SingletonDoubleBuilder?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL >non-issue Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants