Skip to content

Instantly share code, notes, and snippets.

Avatar

Reynold Xin rxin

View GitHub Profile
@rxin
rxin / lzf-1k.dump
Created Jul 14, 2014
Compression codec buffer allocation
View lzf-1k.dump
Every 1000 com.ning.compress.lzf.LZFOutputStream instances allocate 198976424 bytes.
Every 1000 org.xerial.snappy.SnappyOutputStream instances allocate 67660104 bytes.
View mmap-cn.md

mmap是lazy加载数据进内存的. 在映射内存的时候, 不会引起任何I/O. 加载的时候I/O会有readahead, 这个可以由madvise调整; 内存的分配是按page为单位添加内存, 可以由下面代码得到证明.

import sun.misc.Unsafe;
import sun.nio.ch.DirectBuffer;

import java.io.File;
import java.io.RandomAccessFile;
import java.lang.reflect.Field;
import java.nio.ByteBuffer;