This file contains 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
// Replaces implementation of Unsafe.allocateMemory/freeMemory | |
// to avoid long time-to-safepoint pauses. | |
// | |
// Compile: gcc -O3 -fno-omit-frame-pointer -fPIC -shared -olibunmalloc.so unmalloc.c | |
// | |
// Usage: java -agentpath:/path/to/libunmalloc.so ... | |
#include <jvmti.h> | |
#include <stdint.h> | |
#include <stdio.h> |
This file contains 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 sun.jvm.hotspot.debugger.Address; | |
import sun.jvm.hotspot.runtime.VM; | |
import sun.jvm.hotspot.tools.Tool; | |
import java.io.IOException; | |
import java.io.RandomAccessFile; | |
/** | |
* Changes -XX:MaxJavaStackTraceDepth flag to 1000000 in runtime | |
* without restarting the JVM. |
This file contains 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
/* | |
* Copyright 2020 Andrei Pangin | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
This file contains 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 string; | |
import org.openjdk.jmh.annotations.*; | |
import java.util.Random; | |
import java.util.concurrent.TimeUnit; | |
@BenchmarkMode(Mode.AverageTime) | |
@Fork(1) | |
@State(Scope.Thread) |
This file contains 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
/* | |
* Copyright 2020 Andrei Pangin | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
This file contains 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
/* | |
* Copyright 2018 Andrei Pangin | |
* | |
* This is a specialized Java port of the FlameGraph script available at | |
* https://github.com/brendangregg/FlameGraph/blob/master/flamegraph.pl | |
* | |
* Copyright 2016 Netflix, Inc. | |
* Copyright 2011 Joyent, Inc. All rights reserved. | |
* Copyright 2011 Brendan Gregg. All rights reserved. | |
* |
This file contains 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
// Compile: | |
// gcc -shared -fPIC -olibsighandle.so sighandle.c | |
// | |
// Run: | |
// java -agentpath:/path/to/libsighandle.so ... | |
// kill -37 <pid> | |
#include <signal.h> | |
#include <stdlib.h> | |
#include <unistd.h> |
This file contains 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 bench; | |
import org.openjdk.jmh.annotations.Benchmark; | |
import org.openjdk.jmh.annotations.Scope; | |
import org.openjdk.jmh.annotations.State; | |
import java.util.HashSet; | |
import java.util.Set; | |
import java.util.concurrent.ThreadLocalRandom; |
This file contains 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 <jvmti.h> | |
#include <stdio.h> | |
static jvmtiIterationControl JNICALL | |
heap_callback(jlong class_tag, jlong size, jlong* tag_ptr, void* user_data) { | |
*tag_ptr = 1; | |
return JVMTI_ITERATION_CONTINUE; | |
} | |
JNIEXPORT jint JNICALL Agent_OnAttach(JavaVM* vm, char* options, void* reserved) { |
This file contains 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 map; | |
import java.io.PrintStream; | |
import java.util.Base64; | |
import java.util.concurrent.ThreadLocalRandom; | |
public class MapGenerator { | |
public static void main(String[] args) throws Exception { | |
try (PrintStream out = new PrintStream("in.txt")) { |