Skip to content

Instantly share code, notes, and snippets.

View maurorappa's full-sized avatar

maurorappa maurorappa

  • zerolatency
  • Asso
View GitHub Profile
@maurorappa
maurorappa / client.go
Last active October 10, 2024 07:59
workload simulator for VM overprovisioning testing
package main
import (
"bufio"
"bytes"
"flag"
"fmt"
"github.com/BurntSushi/toml"
"github.com/kavehmz/prime"
"io/ioutil"
@maurorappa
maurorappa / Dockerfile
Last active October 10, 2024 08:01
container for collecting server performance in a nice complete json
FROM gcc:11.2.0 as build
RUN apt update && apt install -y p7zip fio python3 g++ ipmitool groff-base dmidecode perl vim python3-pymongo && mkdir /hwtest
COPY . hwtest/
RUN ln -s /usr/local/bin/gcc /usr/bin/gcc && mkdir /etc_phy /data
RUN cd /hwtest && g++ -O3 -DNDEBUG c2clat.cpp -o c2clat -pthread
RUN cd /hwtest && tar xf memtester-4.6.0.tar.gz && tar xf primegen-0.97.tar.gz && cp /hwtest/memtester.c /hwtest/memtester-4.6.0/ && cp /hwtest/primespeed.c /hwtest/primegen-0.97/
RUN cd /hwtest/primegen-0.97/ && make && cp /hwtest/primegen-0.97/primespeed /bin/primespeed
RUN cd /hwtest/memtester-4.6.0/ && make && cp /hwtest/memtester-4.6.0/memtester /bin/memtester
RUN git clone https://github.com/cruvolo/ramspeed-smp.git && cd ramspeed-smp && echo |bash build.sh && cp ramsmp /bin/ramsmp
RUN git clone https://github.com/eembc/coremark-pro.git coremark-pro && cd coremark-pro && make TARGET=linux64 XCMD='-c4' all
microservices in containers without overengineering
all communications by BUS (easy to monitor everything, easy to add new sites, easy to test, easy to implement business logic )
all messages in json with schema (allows easy parsing/storage/replay and multiple service versions to coexists)
central db and Redis NOT in the cluster (shared storage as single point of truth, no cache sync problem)
api routing with nginx or openresty (http routing inside the gateway, no application gw)
How many write syscalls?
# perf stat -e 'syscalls:sys_enter_writev' -p 546925
^C
Performance counter stats for process id '546925':
9 syscalls:sys_enter_writev
3.400728456 seconds time elapsed
@maurorappa
maurorappa / gist:40120b7cbb2123c1c4e3cbd646cd66cb
Created October 9, 2024 06:58
Pin mdraid kernel threads to a CPU
The kernel creates a thread for every md raid configured:
# ps -ef|grep raid
root 912 2 0 15:24 ? 00:00:00 [raid5wq]
root 3383 2 0 15:24 ? 00:00:00 [md0_raid5]
root 3402 2 0 15:24 ? 00:00:03 [md1_raid5]
Being kernel threads, its management is limited, they cannot be pinned to CPU therefore they can move accross all available CPUs, they can get hammered by IRQ, they might have a 'busy' sibling…
Probably dedicated CPU will provide better performance (testing will follow!).
@maurorappa
maurorappa / gist:f1fac27162c53be87e46496eb3415fa5
Created October 9, 2024 06:57
see all new created processes (pid, cmd and args)
bpftrace -e 'tracepoint:syscalls:sys_enter_exec*{ printf("pid: %d, comm: %s, args: ", pid, comm); join(args->argv); }
#sqlite3 /var/lib/grafana/grafana.db
SQLite version 3.7.17
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .output dump.sql
sqlite> .dump dashboard
sqlite> .exit
# tail dump.sql
# tshark -r /root/md.pcap -q -n -z dests,tree
Running as user "root" and group "root". This could be dangerous.
=======================================================================================================================================
IPv4 Statistics/Destinations and Ports:
Topic / Item Count Average Min val Max val Rate (ms) Percent Burst rate Burst start
---------------------------------------------------------------------------------------------------------------------------------------
Destinations and Ports 127892 12.7895 100% 49.6000 0.075
222.10.9.3 127892 12.7895 100.00% 49.6000 0.075
UDP 127892 12.7895 100.00% 49.6000 0.075
https://www.ele.uri.edu/research/hpcl/2012/SBAC.pdf
how it compiled:
objdump -s --section .gnu.build.attributes /usr/lib64/liblzo2.so.2.0.0
or check the spec file! face with tongue
@maurorappa
maurorappa / gist:1d56fbc513a8988a27f4d9a410d0575d
Created October 9, 2024 06:48
Who does adjust my clock?
from man adjtimex :
Linux uses David L. Mills' clock adjustment algorithm (see RFC 1305). The system call adjtimex() reads and optionally sets adjustment parameters for this algorithm.
on Centos7 , you can use systemtap to monitor who calls this syscall.
you need to install all kernel development and debuginfo packages and only then you can run this:
#cat clock.stp
probe kernel.function("sys_adjtimex") { printf("time adjusted by %s(%d)\n",execname(), pid()); }