-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[core] Add limitation to the buffer spill disk usage #3108
Conversation
paimon-common/src/test/java/org/apache/paimon/fs/ByteArraySeekableStreamTest.java
Outdated
Show resolved
Hide resolved
@@ -154,7 +161,16 @@ public long getOccupancy() { | |||
@Override | |||
public boolean flushMemory() throws IOException { | |||
spill(); | |||
return true; | |||
return getDiskUsage() < maxDiskSize.getBytes(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also modify ExternalBuffer
for append table.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
public ChannelWithMeta(FileIOChannel.ID channel, int blockCount, int numBytesInLastBlock) { | ||
this.channel = channel; | ||
this.blockCount = blockCount; | ||
this.numBytesInLastBlock = numBytesInLastBlock; | ||
this.size = channel.getPathFile().length(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pass size from outside instead of access file again.
@@ -90,7 +96,16 @@ public void reset() { | |||
@Override | |||
public boolean flushMemory() throws IOException { | |||
spill(); | |||
return true; | |||
return getDiskUsage() < maxDiskSize.getBytes(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should check first before spill?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, updated
@@ -147,6 +163,7 @@ private void spill() throws IOException { | |||
? inMemoryBuffer.getNumBytesInLastBuffer() | |||
: segment.size(); | |||
writer.writeBlock(Buffer.create(segment, bufferSize)); | |||
numEstimatedBytes += bufferSize; | |||
} | |||
LOG.info( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just cache writer.getSize()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get it, directly use FileChannel.getSize()
can avoid an extra system call to get the file length, Right ?
@@ -24,11 +24,17 @@ public class ChannelWithMeta { | |||
private final FileIOChannel.ID channel; | |||
private final int blockCount; | |||
private final int numBytesInLastBlock; | |||
private final long numEstimatedBytes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can get real size, see comments.
paimon-core/src/main/java/org/apache/paimon/sort/BinaryExternalSortBuffer.java
Outdated
Show resolved
Hide resolved
@@ -309,6 +309,13 @@ public class CoreOptions implements Serializable { | |||
.withDescription( | |||
"Amount of data to build up in memory before converting to a sorted on-disk file."); | |||
|
|||
public static final ConfigOption<MemorySize> WRITE_BUFFER_MAX_DISK_SIZE = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Documentation.OverrideDefault("infinite")?
Looks good to me! |
Purpose
Linked issue: close #3104
Tests
API and Format
Documentation