PooledByteBufAllocatorAlignBenchmark Class — netty Architecture
Architecture documentation for the PooledByteBufAllocatorAlignBenchmark class in PooledByteBufAllocatorAlignBenchmark.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD f2a6748b_3f45_bdff_ac0b_1ebe34c917f2["PooledByteBufAllocatorAlignBenchmark"] 60e4c418_3eb1_2b97_db23_0fdc6d6842d5["PooledByteBufAllocatorAlignBenchmark.java"] f2a6748b_3f45_bdff_ac0b_1ebe34c917f2 -->|defined in| 60e4c418_3eb1_2b97_db23_0fdc6d6842d5 613a6e78_2820_8e58_c371_53e5fca55dff["doSetup()"] f2a6748b_3f45_bdff_ac0b_1ebe34c917f2 -->|method| 613a6e78_2820_8e58_c371_53e5fca55dff c10e909d_2ca9_4f2c_1d85_4a2286f43c8a["doTearDown()"] f2a6748b_3f45_bdff_ac0b_1ebe34c917f2 -->|method| c10e909d_2ca9_4f2c_1d85_4a2286f43c8a f0a8fd43_c6cd_6f4b_e0d0_84b574f030a1["writeRead()"] f2a6748b_3f45_bdff_ac0b_1ebe34c917f2 -->|method| f0a8fd43_c6cd_6f4b_e0d0_84b574f030a1 578050e7_891b_85dd_45cf_3e525b5554c6["write()"] f2a6748b_3f45_bdff_ac0b_1ebe34c917f2 -->|method| 578050e7_891b_85dd_45cf_3e525b5554c6 f892168a_f04e_3997_6940_4dd504a57849["read()"] f2a6748b_3f45_bdff_ac0b_1ebe34c917f2 -->|method| f892168a_f04e_3997_6940_4dd504a57849
Relationship Graph
Source Code
microbench/src/main/java/io/netty/microbench/buffer/PooledByteBufAllocatorAlignBenchmark.java lines 36–161
@State(Scope.Thread)
@Warmup(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(5)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public class PooledByteBufAllocatorAlignBenchmark extends
AbstractMicrobenchmark {
private static final Random rand = new Random();
/**
* Cache line power of 2.
*/
private static final int CACHE_LINE_MAX = 256;
/**
* PRNG to walk the chunk randomly to avoid streaming reads.
*/
private static final int OFFSET_ADD = CACHE_LINE_MAX * 1337;
/**
* Block of bytes to write/read. (Corresponds to int type)
*/
private static final int BLOCK = 4;
@Param({
"0",
"64",
})
private int cacheAlign;
@Param({
"01024",
"04096",
"16384",
"65536",
"1048576",
})
private int size;
private ByteBuf pooledDirectBuffer;
private byte[] bytes;
private int sizeMask;
private int alignOffset;
@Setup
public void doSetup() {
PooledByteBufAllocator pooledAllocator = new PooledByteBufAllocator(true, 4, 4, 8192, 11, 0,
0, 0, true, cacheAlign);
pooledDirectBuffer = pooledAllocator.directBuffer(size + 64);
sizeMask = size - 1;
if (cacheAlign == 0) {
long addr = pooledDirectBuffer.memoryAddress();
// make sure address is miss-aligned
if (addr % 64 == 0) {
alignOffset = 63;
}
int off = 0;
for (int c = 0; c < size; c++) {
off = (off + OFFSET_ADD) & sizeMask;
if ((addr + off + alignOffset) % BLOCK == 0) {
throw new IllegalStateException(
"Misaligned address is not really aligned");
}
}
} else {
alignOffset = 0;
int off = 0;
long addr = pooledDirectBuffer.memoryAddress();
for (int c = 0; c < size; c++) {
off = (off + OFFSET_ADD) & sizeMask;
if ((addr + off) % BLOCK != 0) {
throw new IllegalStateException(
"Aligned address is not really aligned");
}
}
}
bytes = new byte[BLOCK];
Defined In
Source
Frequently Asked Questions
What is the PooledByteBufAllocatorAlignBenchmark class?
PooledByteBufAllocatorAlignBenchmark is a class in the netty codebase, defined in microbench/src/main/java/io/netty/microbench/buffer/PooledByteBufAllocatorAlignBenchmark.java.
Where is PooledByteBufAllocatorAlignBenchmark defined?
PooledByteBufAllocatorAlignBenchmark is defined in microbench/src/main/java/io/netty/microbench/buffer/PooledByteBufAllocatorAlignBenchmark.java at line 36.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free