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

Fixing memory leak due to HoodieLogFileReader holding on to a logblock #346

Merged
merged 1 commit into from Mar 16, 2018

Conversation

n3nash
Copy link
Contributor

@n3nash n3nash commented Mar 14, 2018

  • Removed inMemory HashMap usage in merge(..) code in LogScanner

- Removed inMemory HashMap usage in merge(..) code in LogScanner
@n3nash
Copy link
Contributor Author

n3nash commented Mar 14, 2018

screen shot 2018-03-13 at 11 15 17 pm

screen shot 2018-03-13 at 11 15 33 pm

Copy link
Member

@vinothchandar vinothchandar left a comment

Choose a reason for hiding this comment

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

@n3nash can you help me understand where the long lived block is held? both places look like temporary allocations to me..

HoodieAvroDataBlock dataBlock) throws IOException {
// TODO (NA) - Instead of creating a new HashMap use the spillable map
Map<String, HoodieRecord<? extends HoodieRecordPayload>> recordsFromLastBlock = Maps
Copy link
Member

Choose a reason for hiding this comment

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

This intermediate map was causing the issue? I guess we don't need this anymore given we are lazy reading the metadata and the content is only read when we are sure we want to merge?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

2 issues. This one is just extra overhead which we don't need and cannot afford. So yes, we merge only when we are sure so this is not needed.

@@ -56,7 +56,6 @@
private static final byte[] oldMagicBuffer = new byte[4];
private static final byte[] magicBuffer = new byte[6];
private final Schema readerSchema;
private HoodieLogBlock nextBlock = null;
Copy link
Member

Choose a reason for hiding this comment

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

does this cause additional memory overhead?

Copy link
Contributor Author

@n3nash n3nash Mar 16, 2018

Choose a reason for hiding this comment

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

For this issue. The following is my analysis. Essentially, we pass an inputstream from HoodieLogFileReader to the LogBlocks. An inputstream can be shared in more than 1 logblock. A list of logBlocks are kept until they are merged. So until all logblocks holding the inputstream generated in HoodieLogFileReader are GC'd, they will continue to hold memory. So the last block read is kept in this variable nextBlock and so till the HoodieLogFileReader instance in GC'd this will cause memory overhead.

Copy link
Member

Choose a reason for hiding this comment

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

Per the screenshot in the ticket, most retained memory comes from private List<IndexedRecord> records; in the AvroDataBlock and not the inputStream itself? The inputstream being held does not seem to have causing these issues..
This might be just a large data block being loaded into memory?

Copy link
Member

Choose a reason for hiding this comment

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

But I think we will hold onto the last block in each file and that's what you are seeing..

@vinothchandar vinothchandar merged commit 123da02 into apache:master Mar 16, 2018
vinishjail97 added a commit to vinishjail97/hudi that referenced this pull request Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants