Skip to content

Instantly share code, notes, and snippets.

From 461be79cb4e3275b54727fff506799c063ae13ed Mon Sep 17 00:00:00 2001
From: Florian Lehner <[email protected]>
Date: Wed, 11 Jun 2025 21:29:53 +0200
Subject: [PATCH] Support new flight recorder format
Signed-off-by: Florian Lehner <[email protected]>
---
cmd/gotraceui/goroutine.go | 4 ++--
cmd/gotraceui/span.go | 5 ++---
go.mod | 4 ++--
@florianl
florianl / go_test.go
Last active June 2, 2025 07:00
interpreter/go - Benchmark
$ benchstat old.txt new.txt
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/ebpf-profiler/interpreter/go
cpu: 12th Gen Intel(R) Core(TM) i7-12700H
│ old.txt │ new.txt │
│ sec/op │ sec/op vs base │
Golang-20 6.352m ± 1% 4.877m ± 7% -23.23% (p=0.000 n=10)
│ old.txt │ new.txt │
@florianl
florianl / Makefile
Created January 9, 2025 10:19
Off-CPU demo program
.PHONY: all
all:
gcc -o bottleneck main.c -pthread
package modulo
func fastModulo(x, n uint32) uint32 {
return uint32((uint64(x) * uint64(n)) >> 32)
}
func regularModulo(x, n uint32) uint32 {
return x % n
}
@florianl
florianl / maing.o
Created July 6, 2024 13:14
HTB qdisc with two classes
package main
import (
"fmt"
"net"
"os"
"github.com/florianl/go-tc"
"github.com/florianl/go-tc/core"
"github.com/jsimonetti/rtnetlink"
@florianl
florianl / nvidia-smi.bt
Created January 12, 2024 07:52
Listen to nvidia-smi ioctl commands
#!/usr/bin/env bpftrace
/*
* sudo bpftrace nvidia-smi.bt -o nvidia-smi.$(date +%s%N | cut -b1-13).out
*
* Dump is limited to 64 byte as enforced by BPFTRACE_STRLEN and stack size limitations.
*/
BEGIN
{
printf("Tracing nvidia-smi ioctl calls ... Hit Ctrl-C to end.\n\n");
@florianl
florianl / lookups.go
Created June 28, 2022 18:58
continous map lookups
package main
import (
"fmt"
"math/rand"
"os"
"unsafe"
"github.com/cilium/ebpf"
)
@florianl
florianl / main.go
Created January 24, 2022 20:10
eBPF program on perf event in Go
package main
import (
"errors"
"log"
"os"
"os/signal"
"strconv"
"syscall"
@florianl
florianl / xdp-example.go
Created November 11, 2021 20:21
xdp ebpf example
package main
import (
"fmt"
"log"
"net"
"github.com/cilium/ebpf"
"github.com/cilium/ebpf/asm"
"github.com/cilium/ebpf/rlimit"
@florianl
florianl / fibonacci.go
Created February 24, 2020 19:20
Calculate the fibonacci number in three different ways
package main
import (
"math/rand"
"time"
)
//go:noinline
func fibonacciRecursive(n uint32) uint32 {
if n < 2 {