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

Over account ram usage of array-based vectors #104159

Merged
merged 1 commit into from
Jan 9, 2024

Conversation

dnhatn
Copy link
Member

@dnhatn dnhatn commented Jan 9, 2024

This is part of the effort to enable heap attack tests.

Currently, when creating Blocks from Vectors, we don't account for the extra bytes used by VectorBlock alongside the Vector. In heap attack tests, the unaccounted memory can be significant, as seen in the manyEval test, where the unaccounted bytes is 40, while the vector is just 128 bytes, resulting in an OOM instead of triggering the circuit breaker.

Ideally, Vector#asBlock should adjust the breaker, and callers should release the returned block. While I tried to implement this, there are many places in our tests where we use Vector#asBlock without releasing the block. This is possible because Vector#asBlock doesn't increase the reference to the vector. In the long run, I think we should remove Vector#asBlock and force that callers use newBlockFromVector from the BlockFactory. This would provide clearer semantics and enable proper tracking of blocks in assertions.

This PR adds the extra bytes used by VectorBlock to ArrayVector, allowing us to run heap-attack tests.

@dnhatn dnhatn requested review from ChrisHegarty and nik9000 January 9, 2024 21:37
@dnhatn dnhatn marked this pull request as ready for review January 9, 2024 21:37
@elasticsearchmachine
Copy link
Collaborator

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

@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Jan 9, 2024
@dnhatn
Copy link
Member Author

dnhatn commented Jan 9, 2024

Thanks, Nik!

@dnhatn dnhatn merged commit a5ab9f3 into elastic:main Jan 9, 2024
15 checks passed
@dnhatn dnhatn deleted the over-estimate branch January 9, 2024 23:17
@dnhatn dnhatn mentioned this pull request Jan 10, 2024
Copy link
Contributor

@ChrisHegarty ChrisHegarty left a comment

Choose a reason for hiding this comment

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

Belated LGTM. Thanks Nhat

dnhatn added a commit that referenced this pull request Jan 10, 2024
This PR enables ESQL heap attack tests. I have run this suite over 500 
iterations with different hardware configurations for the last two days,
and all have been successful with the changes in #104159.

Additionally, this PR adds an action that can trigger OOM to generate a 
heap dump if a test takes more than 5 minutes. I've seen cases
(previously with our CI) where the test didn't result in OOM but was
taking too long. Having the ability to inspect the heap in such cases
would be beneficial.

Closes #103527
Closes #100678
dnhatn added a commit that referenced this pull request Jan 12, 2024
The test failure is related to #104159, where we had an overestimate of 
the RAM usage for X-ArrayVector. Instead of updating the break limits,
this PR uses the breaker utility that @nik9000 wrote to dynamically
compute the limits on-the-fly.

Closes #104191
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) v8.13.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants