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
#include <jemalloc/jemalloc.h> | |
#include <iostream> | |
class JeInit { | |
private: | |
static chunk_hooks_t old_hooks; | |
public: | |
JeInit() { | |
unsigned narenas; |
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
import com.sun.management.GcInfo; | |
import javax.management.MBeanServer; | |
import java.io.IOException; | |
import java.lang.management.ManagementFactory; | |
import com.sun.management.GarbageCollectorMXBean; | |
import java.lang.management.MemoryUsage; | |
import java.util.Map; | |
import java.util.Random; | |
import java.util.concurrent.Executors; |
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
class Main { | |
private final Map<Integer, Object> map = new ConcurrentHashMap<>(); | |
public Object getOnce(int idx) { | |
Object obj = map.get(idx); | |
if (obj == null) { | |
synchronized(this) { | |
obj = map.get(idx); | |
if (obj == null) { | |
obj = new Object(); |
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
long start = System.nanoTime(); | |
int i = 0; | |
while (i < 10000) { | |
LockSupport.parkNanos(1); | |
i++; | |
} | |
long end = System.nanoTime(); | |
System.out.println((end - start) / 10000); |
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
// Basically I want to initiate the stream from the client and then whenever I get a message from the server | |
// I want to respond immediately over the same stream. | |
private Future<Histogram> doStreamingCalls(Channel channel, final SimpleRequest request, | |
final long endTime) { | |
final TestServiceStub stub = TestServiceGrpc.newStub(channel); | |
final Histogram histogram = new Histogram(HISTOGRAM_MAX_VALUE, HISTOGRAM_PRECISION); | |
final HistogramFuture future = new HistogramFuture(histogram); | |
final StreamObserver<SimpleRequest> requestObserver; |
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
package io.netty.microbench.headers; | |
import io.netty.handler.codec.http.DefaultHttpHeaders; | |
import io.netty.handler.codec.http2.DefaultHttp2Headers; | |
import io.netty.microbench.headers.ExampleHeaders.HeaderExample; | |
import io.netty.util.AsciiString; | |
import io.netty.util.ByteString; | |
import io.netty.util.CharsetUtil; | |
import org.openjdk.jol.info.GraphLayout; |
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
Benchmark (keyDistribution) (mapType) (size) Mode Cnt Score Error Units | |
IntObjectHashMapBenchmark.lookup HTTP2 AGRONA 10 thrpt 80 15615722.317 ± 76797.962 ops/s | |
IntObjectHashMapBenchmark.lookup HTTP2 AGRONA 100 thrpt 80 1562510.865 ± 2332.439 ops/s | |
IntObjectHashMapBenchmark.lookup HTTP2 AGRONA 1000 thrpt 80 120426.474 ± 2340.466 ops/s | |
IntObjectHashMapBenchmark.lookup HTTP2 AGRONA 10000 thrpt 80 10760.255 ± 529.717 ops/s | |
IntObjectHashMapBenchmark.lookup HTTP2 AGRONA 100000 thrpt 80 852.463 ± 1.554 ops/s | |
IntObjectHashMapBenchmark.lookup HTTP2 AGRONA 1000000 thrpt 80 29.976 ± 0.400 ops/s | |
IntObjectHashMapBenchmark.lookup HTTP2 AGRONA 10000000 thrpt 80 2.508 ± 0.028 ops/s | |
IntObjectHashMapBenchmark.lookup HTTP2 NETTY 10 |
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
package better.headers; | |
import io.netty.handler.codec.AsciiString; | |
import sun.misc.Unsafe; | |
import java.lang.reflect.Field; | |
public class Headers { | |
private static final Unsafe theUnsafe; | |
private static final int baseOffset; |
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
// decompress a varint encoded integer | |
uint64_t decompress(uint8_t* mem) { | |
// mask to extract the msb of each individual byte | |
static const uint64_t loMask = 0x8080808080808080; | |
static const uint64_t decompMask[8] = {0x7F, 0x7F7F, | |
0x7F7F7F, 0x7F7F7F7F, | |
0x7F7F7F7F7F, 0x7F7F7F7F7F7F, | |
0x7F7F7F7F7F7F7F, 0x7F7F7F7F7F7F7F7F}; |
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
// print each byte from [begin, end) in groups of four per line | |
void bindump(const uint8_t* begin, const uint8_t* end) { | |
printf("BIN[%p, %p)\n", begin, end); | |
char bytestr[9]; | |
bytestr[8] = '\0'; | |
for (uint8_t j = 1; begin != end; begin++, j++) { | |
uint8_t byte = *begin; | |
for (int i = 0; i < 8; i++) | |
bytestr[i] = '0' + ((byte >> (7-i)) & 1); | |
printf("%s%c", bytestr, j & 3 ? ' ' : '\n'); |