Skip to content

Instantly share code, notes, and snippets.

View farrokhi's full-sized avatar
🚀

Babak Farrokhi farrokhi

🚀
View GitHub Profile
@farrokhi
farrokhi / cleanup_memory.sh
Created January 19, 2020 11:15
Enforce dropping page cache and trigger memory page compactor for Linux MM
#!/bin/sh
set -u
NUMA_BEFORE=`numactl -H | grep free:`
SLAB_BEFORE=`grep Normal /proc/buddyinfo`
printf "Dropping page cache..."
sysctl -qw vm.drop_caches=1
echo
@farrokhi
farrokhi / hugepages_settings.sh
Created January 19, 2020 11:14
Calculate recommended value for HugePages/HugeTLB in Linux
#!/bin/bash
#
# hugepages_settings.sh
#
# Linux bash script to compute values for the
# recommended HugePages/HugeTLB configuration
#
# Note: This script does calculation for all shared memory
# segments available when the script is run, no matter it
# is an Oracle RDBMS shared memory segment or not.
@farrokhi
farrokhi / vim-headers.md
Created January 19, 2020 11:14
vim header file for text documents with proper line-breaking

Text file with hard line-breaks:

# vim:ts=4:sw=4:tw=79:wm=2

Golang source files with proper tab and spacing:

// vim:noet:noai:ts=4:sw=4
@farrokhi
farrokhi / mem_swap_linux.md
Created July 17, 2019 12:18
memory usage and swap investigation in linux
grep -A1 Normal  /proc/zoneinfo  ; echo "--"; sysctl vm.min_free_kbytes ; echo "--"; numactl -H | grep free
@farrokhi
farrokhi / autotune.py
Created May 19, 2019 11:24
FreeBSD autotuning (loader.conf and sysctl.conf)
#!/usr/local/bin/python
"""
Autotuning program.
Garrett Cooper, December 2011
Example:
autotune.py --conf loader \
--kernel-reserved=2147483648 \
--userland-reserved=4294967296
@farrokhi
farrokhi / best-mirror.sh
Last active November 10, 2022 05:35 — forked from lox/mirror_test.sh
A shell script to select the fastest freebsd-update mirror
#!/bin/sh
# best-mirror.sh
#
# Domesticaed for FreeBSD by Babak Farrokhi ([email protected])
#
# This script finds the fastest freebsd-update mirror based on
# data transfer rates from cURL.
#
# Note: I used a static list of mirrors, which is not the best way to
@farrokhi
farrokhi / str-perf-test.py
Last active August 6, 2018 15:38
comparing performance of various string concatenation methods in python
from functools import wraps
import pickle
from random import randint, choice
import string
import pathlib
import time
import sys
big_list = [] # our huge list of tuples
cache_file = "test-data-cache.pickle"
@farrokhi
farrokhi / freebsd-ntpd.md
Created June 18, 2018 14:41
Bind FreeBSD ntpd to given IP address

In order to avoid FreeBSD ntpd listen on wildcard interface, add following lines to /etc/ntp.conf:

interface ignore wildcard
interface listen 10.0.0.1
@farrokhi
farrokhi / cscope.md
Created May 30, 2018 07:40
Setting up cscope for a (large) C project

build/update database:

cd $PROJ_DIR
find . -path .git -path .svn -prune -o -name "*.[ch]" > cscope.files
cscope -bqk

browse code:

cscope -d
@farrokhi
farrokhi / dnskey-result.txt
Last active October 20, 2017 11:10
Sad state of DNSSEC adoption with top domains
#
# The output from my check-dnskey.sh script that requests DNSKEY record
# from top 100 domain names and prints the key if there was any.
# last updated on 2017-oct-20
#
google.com NO
youtube.com NO
facebook.com NO
baidu.com NO
wikipedia.org NO