fix: fix record size estimation to reflect previous behavior#14039
Merged
nsivabalan merged 1 commit intoapache:masterfrom Oct 3, 2025
Merged
fix: fix record size estimation to reflect previous behavior#14039nsivabalan merged 1 commit intoapache:masterfrom
nsivabalan merged 1 commit intoapache:masterfrom
Conversation
Collaborator
nsivabalan
reviewed
Oct 2, 2025
| HoodieInstant instant = instants.next(); | ||
| try { | ||
| HoodieCommitMetadata commitMetadata = commitTimeline.readCommitMetadata(instant); | ||
| final HoodieAtomicLongAccumulator totalBytesWritten = HoodieAtomicLongAccumulator.create(); |
Contributor
There was a problem hiding this comment.
not sure why do we need an accumulator here.
we are processing all these in driver from what I can gauge.
| public long averageBytesPerRecord(HoodieTimeline commitTimeline, CommitMetadataSerDe commitMetadataSerDe) { | ||
| int maxCommits = hoodieWriteConfig.getRecordSizeEstimatorMaxCommits(); | ||
| final AverageRecordSizeStats averageRecordSizeStats = new AverageRecordSizeStats(hoodieWriteConfig); | ||
| final long commitSizeThreshold = (long) (hoodieWriteConfig.getRecordSizeEstimationThreshold() * hoodieWriteConfig.getParquetSmallFileLimit()); |
Contributor
There was a problem hiding this comment.
isn't this file slice threshold or single data file threshold?
looks like it was a bug earlier. and we should fix it now.
Contributor
Author
There was a problem hiding this comment.
#10763 it seems to have always been this case that it's for the entire commit. Additionally, the config description is
public static final ConfigProperty<String> RECORD_SIZE_ESTIMATION_THRESHOLD = ConfigProperty
.key("hoodie.record.size.estimation.threshold")
.defaultValue("1.0")
.markAdvanced()
.withDocumentation("We use the previous commits' metadata to calculate the estimated record size and use it "
+ " to bin pack records into partitions. If the previous commit is too small to make an accurate estimation, "
+ " Hudi will search commits in the reverse order, until we find a commit that has totalBytesWritten "
+ " larger than (PARQUET_SMALL_FILE_LIMIT_BYTES * this_threshold)");
and the git blame is from 2021
| totalRecordsWritten.add(hoodieWriteStat.getNumWrites()); | ||
| }); | ||
| } else { | ||
| totalBytesWritten.add(commitMetadata.fetchTotalBytesWritten() - (commitMetadata.fetchTotalFiles() * metadataSizeEstimate)); |
Contributor
There was a problem hiding this comment.
if we go w/ per file size threshold,
then here also, we need to loop for every writeStat
nsivabalan
approved these changes
Oct 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe the issue this Pull Request addresses
#13995
Summary and Changelog
Revert the behavior to match the previous behavior while still honoring the new config added for metadata size to be subtracted
Impact
more accurate record size estimate
Risk Level
low
Documentation Update
N/A
Contributor's checklist