You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "翟玉勇 (JIRA)" <ji...@apache.org> on 2018/09/26 07:08:00 UTC
[jira] [Updated] (KAFKA-7442) forceUnmap mmap on linux
[ https://issues.apache.org/jira/browse/KAFKA-7442?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
翟玉勇 updated KAFKA-7442:
-----------------------
Description:
when resize OffsetIndex or TimeIndex,We should force unmap mmap for linux platform. Rather than waiting fullgc to unmap MappedByteBuffer object
{code}
def resize(newSize: Int) {
inLock(lock) {
val raf = new RandomAccessFile(_file, "rw")
val roundedNewSize = roundDownToExactMultiple(newSize, entrySize)
val position = mmap.position
/* Windows won't let us modify the file length while the file is mmapped :-( */
if(Os.isWindows)
forceUnmap(mmap)
try {
raf.setLength(roundedNewSize)
mmap = raf.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, roundedNewSize)
_maxEntries = mmap.limit / entrySize
mmap.position(position)
} finally {
CoreUtils.swallow(raf.close())
}
}
}
{code}
was:
when resize OffsetIndex or TimeIndex,We should force unmap mmap for linux platform
{code}
def resize(newSize: Int) {
inLock(lock) {
val raf = new RandomAccessFile(_file, "rw")
val roundedNewSize = roundDownToExactMultiple(newSize, entrySize)
val position = mmap.position
/* Windows won't let us modify the file length while the file is mmapped :-( */
if(Os.isWindows)
forceUnmap(mmap)
try {
raf.setLength(roundedNewSize)
mmap = raf.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, roundedNewSize)
_maxEntries = mmap.limit / entrySize
mmap.position(position)
} finally {
CoreUtils.swallow(raf.close())
}
}
}
{code}
> forceUnmap mmap on linux
> ------------------------
>
> Key: KAFKA-7442
> URL: https://issues.apache.org/jira/browse/KAFKA-7442
> Project: Kafka
> Issue Type: Improvement
> Components: log
> Affects Versions: 0.10.1.1
> Reporter: 翟玉勇
> Priority: Minor
>
> when resize OffsetIndex or TimeIndex,We should force unmap mmap for linux platform. Rather than waiting fullgc to unmap MappedByteBuffer object
> {code}
> def resize(newSize: Int) {
> inLock(lock) {
> val raf = new RandomAccessFile(_file, "rw")
> val roundedNewSize = roundDownToExactMultiple(newSize, entrySize)
> val position = mmap.position
> /* Windows won't let us modify the file length while the file is mmapped :-( */
> if(Os.isWindows)
> forceUnmap(mmap)
> try {
> raf.setLength(roundedNewSize)
> mmap = raf.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, roundedNewSize)
> _maxEntries = mmap.limit / entrySize
> mmap.position(position)
> } finally {
> CoreUtils.swallow(raf.close())
> }
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)