Skip to content

Instantly share code, notes, and snippets.

View KJTsanaktsidis's full-sized avatar

KJ Tsanaktsidis KJTsanaktsidis

View GitHub Profile
package main
import (
"fmt"
"log"
"os"
"time"
"github.com/Shopify/sarama"
"gopkg.in/confluentinc/confluent-kafka-go.v1/kafka"
Hey @l2g - thanks for putting this together.
I tried to set this up today but I'm running into trouble with the TLS certificates on repo.nuxref.com:
[code]
kj@hyp01:~$ sudo rpm -Uhi https://repo.nuxref.com/fedora/fc33/en/x86_64/custom/nuxref-release-1.0.0-5.fc33.nuxref.noarch.rpm
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.haxx.se/docs/sslcerts.html
curl failed to verify the legitimacy of the server and therefore could not
@KJTsanaktsidis
KJTsanaktsidis / jemalloc.go
Last active September 14, 2021 05:16
Linking jemalloc into a Go program and collecting statistics
package jemalloc
/*
// This cgo directive is what actually causes jemalloc to be linked in to the
// final Go executable
#cgo pkg-config: jemalloc
#include <jemalloc/jemalloc.h>
void _refresh_jemalloc_stats() {
@KJTsanaktsidis
KJTsanaktsidis / valgrind.out
Last active September 23, 2021 03:43
valgrind.out
==731== 7,560 bytes in 315 blocks are still reachable in loss record 608 of 611
==731== at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==731== by 0x5362C35: OPENSSL_LH_insert (in /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1)
==731== by 0x533FF82: ??? (in /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1)
==731== by 0x53403AF: ERR_load_strings_const (in /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1)
==731== by 0x518C26F: ERR_load_SSL_strings (in /usr/lib/x86_64-linux-gnu/libssl.so.1.1)
==731== by 0x518C29C: ??? (in /usr/lib/x86_64-linux-gnu/libssl.so.1.1)
==731== by 0x4D3C47E: __pthread_once_slow (pthread_once.c:116)
==731== by 0x53CB74C: CRYPTO_THREAD_run_once (in /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1)
==731== by 0x518C64A: OPENSSL_init_ssl (in /usr/lib/x86_64-linux-gnu/libssl.so.1.1)
@KJTsanaktsidis
KJTsanaktsidis / rd.h
Created September 23, 2021 07:34
rd.h
// include macros from SystemTap project
#include <sys/sdt.h>
// ... lots of librdkafka code ...
static RD_INLINE RD_UNUSED void *rd_malloc(size_t sz) {
void *p = malloc(sz);
rd_assert(p);
// Add a call to DTRACE_PROBE here to call our probe with the address
@KJTsanaktsidis
KJTsanaktsidis / bpftrace
Created September 23, 2021 07:49
bpftrace
usdt:/usr/local/lib/librdkafka.so.1:librdkafka:rd_malloc {
@allocated_addrs[arg0] = ustack();
@allocation_time[arg0] = nsecs;
}
usdt:/usr/local/lib/librdkafka.so.1:librdkafka:rd_free {
delete(@allocated_addrs[arg0]);
delete(@allocation_time[arg0]);
}
@KJTsanaktsidis
KJTsanaktsidis / bpfout
Created September 23, 2021 08:25
bpfout
@allocated_addrs[140548392353792]:
0x7fd431f0d4d4
0xb4fc7a
0x8b7845
0x8c273d
0x8bb2b6
0x937f85
0x9426b8
0x93f4d5
0x93f9b9
#!/usr/bin/env ruby
require 'open3'
@allocated_addrs = {}
@allocation_time = {}
@symbol_cache = {}
@app_pid = ARGV[0]
def resolve_symbol(addr)
Pointer at 140292879716464:
rd.h:130
rdkafka_partition.c:2924
rdkafka_cgrp.c:2730
rdatomic.h:86
rdkafka_op.c:830
rdkafka_op.c:860
rdkafka_queue.c:510
rdkafka.c:2060
pthread_create.c:474
#!/usr/bin/env ruby
require 'open3'
# rubocop:disable Lint/MissingCopEnableDirective
# rubocop:disable Style/GlobalVars
$stdout_lock = Mutex.new
$stdout.sync = true
Thread.abort_on_exception = true