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

Account memory for OrcDeletedRows - fix memory accounting for ORC ACID delete delta #9914

Merged
merged 1 commit into from Nov 19, 2021

Conversation

losipiuk
Copy link
Member

@losipiuk losipiuk commented Nov 9, 2021

No description provided.

@@ -244,6 +251,10 @@ private RowId getRowId(int position)
long row = BIGINT.getLong(page.getBlock(ROW_ID_INDEX), i);
RowId rowId = new RowId(originalTransaction, bucket, statement, row);
deletedRowsBuilder.add(rowId);
rowCount++;
if (rowCount % 1000 == 0) {
systemMemoryUsage.setBytes(rowCount * RowId.INSTANCE_SIZE);
Copy link
Member

Choose a reason for hiding this comment

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

sizeOfObjectArray(rowCount) + rowCount * RowId.INSTANCE_SIZE

Copy link
Member

Choose a reason for hiding this comment

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

Is it worth doing setting this as we loop vs just doing it once at the end?
Also, can we safely ignore the return value of setBytes?

Copy link
Member Author

Choose a reason for hiding this comment

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

The benefit of doing that in the loop (I think) is that we can pause some other query for a while, allowing us to get to the end of loop without OOM. Other than that it does not change much I think.
@findepi am I missing something?

Copy link
Member

Choose a reason for hiding this comment

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

we should assume that building deletedRows list can exhaust node memory.
if we set memory usage only at the end, we still do not protect ourselves against node OOM.

Also, can we safely ignore the return value of setBytes?

we cannot block here (can we?).
we could use trySetBytes here, perhaps.

@losipiuk
Copy link
Member Author

AC

@losipiuk
Copy link
Member Author

losipiuk commented Nov 10, 2021

we cannot block here (can we?).

It does not look like. Maybe with a significant refactoring.

we could use trySetBytes here, perhaps.

I was thinking about that. But then what if it returns that we cannot allocate. Throw exception ourselves?

@findepi
Copy link
Member

findepi commented Nov 10, 2021

we could use trySetBytes here, perhaps.

I was thinking about that. But then what if it returns that we cannot allocate. Throw exception ourselves?

yes, we would throw then.

cc @sopel39 for LocalMemoryContext.setBytes vs trySetBytes.

@@ -244,6 +252,10 @@ private RowId getRowId(int position)
long row = BIGINT.getLong(page.getBlock(ROW_ID_INDEX), i);
RowId rowId = new RowId(originalTransaction, bucket, statement, row);
deletedRowsBuilder.add(rowId);
rowCount++;
if (rowCount % 1000 == 0) {
Copy link
Member

Choose a reason for hiding this comment

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

add a comment why

Copy link
Member Author

Choose a reason for hiding this comment

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

dropped as data is not passed to operator context immediately.

deletedRows = deletedRowsBuilder.build();
// not updating memory usage in the loop, as deletedRows are built, as recorded information is propagated
Copy link
Member

Choose a reason for hiding this comment

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

nit: extra space before as

@losipiuk losipiuk merged commit 92d7eea into trinodb:master Nov 19, 2021
@github-actions github-actions bot added this to the 365 milestone Nov 19, 2021
@losipiuk losipiuk mentioned this pull request Nov 30, 2021
12 tasks
@findepi findepi changed the title Account memory for OrcDeletedRows Account memory for OrcDeletedRows - fix memory accounting for ORC ACID delete delta Mar 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

4 participants