Skip to content

Instantly share code, notes, and snippets.

Avatar

Costa Tsaousis ktsaou

View GitHub Profile
@ktsaou
ktsaou / spinlock.c
Last active Nov 30, 2022
spinlock vs mutex benchmark
View spinlock.c
//
// compile with
// gcc -O2 -o spinlock spinlock.c -lpthread
#define _GNU_SOURCE
#define __USE_GNU
#include <pthread.h>
#include <errno.h>
#include <stdbool.h>
View gist:1a735fe9bdd0fd4b22b9421415f63461
(gdb) taas bt
Thread 463 (Thread 0x7fd5d4952700 (LWP 272185) "DBENGINE"):
#0 futex_abstimed_wait (private=0, abstime=0x0, clockid=0, expected=3, futex_word=<optimized out>) at ../sysdeps/nptl/futex-internal.h:287
#1 __pthread_rwlock_rdlock_full (abstime=0x0, clockid=0, rwlock=0x5615817057c8) at pthread_rwlock_common.c:460
#2 __GI___pthread_rwlock_rdlock (rwlock=0x5615817057c8) at pthread_rwlock_rdlock.c:27
#3 0x00007fd6d2e746e9 in uv_rwlock_rdlock () from target:/lib/x86_64-linux-gnu/libuv.so.1
#4 0x000056157bd0b1a6 in get_descriptor (page_index=0x5615817057a0, start_time_s=1668212224) at database/engine/rrdengine.c:763
#5 0x000056157bd0b24d in try_to_remove_v2_descriptor (ctx=0x56157c34fcc0 <multidb_ctx_storage_tier0>, page_index=0x5615817057a0, start_time_s=1668212224, expired=false) at database/engine/rrdengine.c:772
#6 0x000056157bd0b4b8 in check_journal_file (journalfile=0x5615829dda10) at database/engine/rrdengine.c:830
@ktsaou
ktsaou / stress-with-curl.sh
Last active May 26, 2022
Command line web server stress testing tool, implemented with curl and real-time statistics to netdata
View stress-with-curl.sh
#!/usr/bin/env bash
# Stress With Curl
# Run multiple curl worker to stress a web server
# Real-time statistics at a Netdata server
#
# To use, you need:
# - curl
# - The nc command from the openbsd-netcat package
# - Netdata
View gist:36b7ae1680a909a88642c5d75e9248fb
$ ./compile-gvpe/build-gvpe-linux-static.sh
ME : build-gvpe-linux-static.sh
DIR : /home/costa/src/netdata-demo-site.git/gvpe/compile-gvpe
/home/costa/src/netdata-demo-site.git/gvpe/compile-gvpe > sudo docker run -a stdin -a stdout -a stderr -i -t -v /home/costa/src/netdata-demo-site.git/gvpe/compile-gvpe:/tmp/mapped:rw alpine:edge /bin/sh /tmp/mapped/build-gvpe-linux-static.sh inside-container
/ > apk update
fetch https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
v3.15.0_alpha20210804-4905-ga7f55994b5 [https://dl-cdn.alpinelinux.org/alpine/edge/main]
View netdata-cla
# netdata contributors license agreement
**Thank you for contributing to netdata!**
This agreement is part of the legal framework of the open-source ecosystem
that adds some red tape, but protects both the contributor and the project.
To understand why this is needed, please read [a well-written chapter from
Karl Fogel’s Producing Open Source Software on CLAs](http://producingoss.com/en/copyright-assignment.html).
@ktsaou
ktsaou / autoscaled.sh
Created Sep 10, 2017
autoscale X/Wayland applications based on current DPI settings
View autoscaled.sh
#!/usr/bin/env bash
program="${1}"
append=
# -----------------------------------------------------------------------------
# HiDPI decision
primary_found="no"
@ktsaou
ktsaou / dell-xps9560-linux-cpufreq.sh
Last active Jul 3, 2018
dell XPS9560 cpufreq fix for acpi-cpufreq
View dell-xps9560-linux-cpufreq.sh
#!/bin/sh
base="/sys/devices/system/cpu/cpufreq/policy0/"
ME="${0}"
SCALING_DRIVER="$(<${base}/scaling_driver)"
SCALING_GOVERNOR="$(<${base}/scaling_governor)"
AC_ONLINE=$(</sys/class/power_supply/AC/online)
# install this script in udev
View horizon.scotthelme.co.uk-index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Horizon - Server Monitoring</title>
<script>var netdataTheme = 'slate';</script>
<script type="text/javascript" src="https://horizon.scotthelme.co.uk/reporturi-shared-01/dashboard.js?v20170105-7"></script>
<link href="style.css?d=20170210-2035" rel="stylesheet">
@ktsaou
ktsaou / build-static-gvpe.sh
Last active Apr 9, 2017
script to create a statically linked gvpe and gvpectrl, on a temporary alpine linux docker container
View build-static-gvpe.sh
#!/bin/sh
if [ "${1}" != "inside-container" ]
then
ME="$(basename "${0}")"
DIR="$(dirname "${0}")"
cd "${DIR}" || exit 1
DIR="$(pwd)"