Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import os
from pyroute2 import TaskStats
from pyroute2.netlink import NLM_F_REQUEST
from pyroute2.netlink.taskstats import tcmd
from pyroute2.netlink.taskstats import TASKSTATS_CMD_GET
clk_tck = os.sysconf('SC_CLK_TCK')
clk_tck_factor = int(1e9 / clk_tck)
from collections import namedtuple
from time import sleep
import sys
import os
NICE_FIELD = 19 - 1
DELAYACCT_BLKIO_TICKS_FIELD = 42 - 1
clk_tck_factor = int(1e9 / os.sysconf('SC_CLK_TCK'))
$ sudo gdb --pid=$PID -ex 'gcore' -ex 'detach' -ex 'quit'
@hashbrowncipher
hashbrowncipher / cassandra.conf
Created October 23, 2016 19:26
Upstart script for Cassandra
description "Cassandra"
start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [06]
limit nofile 1000000 1000000
limit memlock unlimited unlimited
setuid cassandra
Eden Sizing
There are limits to the size that Eden is allowed to be. Those limits are calculated in calculate_default_min_length:
G1YoungGenSizer::recalculate_min_max_young_length -> G1YoungGenSizer::calculate_default_min_length
G1CollectorPolicy::update_young_list_target_length is responsible for
determining the actual size of the young list. If doing a young GC, it will
call G1CollectorPolicy::calculate_young_list_target_length. This function
attempts to find the largest eden size that will allow (predicted) GC pauses to
remain under the pause time target. Presumably after a certain eden size, there
@hashbrowncipher
hashbrowncipher / latency.markdown
Created October 26, 2016 21:16 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@hashbrowncipher
hashbrowncipher / parallel_find
Last active October 28, 2016 16:57
A parallel version of find(1), implementing a DFS-ish over cwd.
//A parallel version of find(1), implementing a DFS-ish over cwd.
//Compile with -lpthread
#include <dirent.h>
#include <fcntl.h>
#include <pthread.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
$ sudo ./ocperf.py stat -e cpu_clk_thread_unhalted.ref_xclk,cpu_clk_thread_unhalted.ref_xclk_any,cpu_clk_unhalted.one_thread_active -a -- sleep 5
perf stat -e cpu/event=0x3c,umask=0x1,name=cpu_clk_thread_unhalted_ref_xclk/,cpu/event=0x3c,umask=0x1,any=1,name=cpu_clk_thread_unhalted_ref_xclk_any/,cpu/event=0x3c,umask=0x2,name=cpu_clk_unhalted_one_thread_active/ -a -- sleep 5
Performance counter stats for 'system wide':
295,538,267 cpu_clk_thread_unhalted_ref_xclk [100.00%]
579,495,176 cpu_clk_thread_unhalted_ref_xclk_any [100.00%]
283,950,270 cpu_clk_unhalted_one_thread_active
5.000637559 seconds time elapsed
package com.josnyder;
import java.lang.management.ManagementFactory;
import javax.management.InstanceAlreadyExistsException;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import org.apache.cassandra.service.CassandraDaemon;
class HotspotMBeanCassandraDaemon extends CassandraDaemon {
protected void setup() {
diff --git a/src/main/java/com/tagtraum/perf/gcviewer/view/renderer/TotalTenuredRenderer.java b/src/main/java/com/tagtraum/perf/gcviewer/view/renderer/TotalTenuredRenderer.java
index 344965d..f8e31a0 100644
--- a/src/main/java/com/tagtraum/perf/gcviewer/view/renderer/TotalTenuredRenderer.java
+++ b/src/main/java/com/tagtraum/perf/gcviewer/view/renderer/TotalTenuredRenderer.java
@@ -49,6 +49,8 @@ public class TotalTenuredRenderer extends PolygonChartRenderer {
polygon.addPoint(0, (double)tenured.getTotal());
}
polygon.addPoint(tenured.getTimestamp() - model.getFirstPauseTimeStamp() + event.getPause(),
+ lastTotal);
+ polygon.addPoint(tenured.getTimestamp() - model.getFirstPauseTimeStamp() + event.getPause(),