Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
sudo sh -c 'for CPU in /sys/devices/system/cpu/cpu[0-9]* ; do echo powersave > $CPU/cpufreq/scaling_governor ; done'
sudo sh -c 'for CPU in /sys/devices/system/cpu/cpu[0-9]* ; do echo 800000 > $CPU/cpufreq/scaling_min_freq ; done'
sudo sh -c 'for CPU in /sys/devices/system/cpu/cpu[0-9]* ; do echo 2000000 > $CPU/cpufreq/scaling_setspeed ; done'
sudo sh -c 'for CPU in /sys/devices/system/cpu/cpu[0-9]* ; do echo 2000000 > $CPU/cpufreq/scaling_max_freq ; done'
@jpetazzo
jpetazzo / README.md
Last active August 29, 2015 14:01
BTRFS, schmetterFS

First, we need recent btrfs tools. Otherwise, we're entering a world of pain.

So:

apt-get build-dep btrfs-tools
apt-get install liblzo2-dev libblkid-dev
git clone git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-progs.git
make -j -C btrfs-progs
So this is on my "puny" i7, which is a "Intel(R) Core(TM) i7-2720QM CPU @ 2.20GHz".
During the bench I think it was running at 2 GHz, and it's supposed to be able to boost at 3.3 GHz.
(But I hard-capped the speed because I don't like when my laptop starts to levitate because of fanspeed ;-))
The 'numbers' are in 1000s of bytes per second processed.
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes
md2 0.00 0.00 0.00 0.00 0.00
mdc2 0.00 0.00 0.00 0.00 0.00
md4 21071.83k 63368.19k 147767.22k 221280.60k 258719.74k
#!/bin/sh
# Set minimal MTU to an impossible amount.
MINMTU=99999
INTERFACES=$(ip ro list | grep ^default | sed 's/.*dev \([^ ]*\) .*/\1/')
for I in $INTERFACES
do
MTU=$(ip link show $I | grep mtu | sed 's/.*mtu \([^ ]*\) .*/\1/')
[ $MTU -lt $MINMTU ] && MINMTU=$MTU
done
@jpetazzo
jpetazzo / trace.py
Created January 8, 2014 18:32
Debugging decorator.
def trace(f):
def wrapped_f(*args, **kwargs):
print ("Calling {0} with args={1} and kwargs={2}"
.format(f.__name__, args, kwargs))
return_value = f(*args, **kwargs)
print ("Return value={0!r}".format(return_value))
return return_value
return wrapped_f
@trace
@jpetazzo
jpetazzo / Dockerfile
Last active December 30, 2015 16:09
Work around Docker terminal issues.
FROM ubuntu
RUN apt-get -qy install tmux openssh-server
CMD \
ssh-keygen -f /root/.ssh/id_rsa -N "" >/dev/null &&\
cp /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys &&\
mkdir /var/run/sshd &&\
/usr/sbin/sshd &&\
sleep 1 &&\
ssh-keyscan localhost > /root/.ssh/known_hosts 2>/dev/null &&\
ssh -t localhost tmux
@jpetazzo
jpetazzo / README.md
Created December 4, 2013 02:12
Zerohub

Zerohub

This is used to have a bunch of ZeroRPC clients and workers talking to each other.

WARNING: this is not compatible with heartbeats and streaming!

Clients connect to the "in" side of the hub.

Workers connect to the "out" side of the hub.

@jpetazzo
jpetazzo / README.md
Created December 3, 2013 19:58
Example of memory cgroup information

Let's start a container:

root@dockerhost:~# docker run -d -i ubuntu bash
0d62d8b0dc65998b0dc5b88d4e2bd331f560579199f05869088ac98266dac0b1

Now let's check the cgroup values:

@jpetazzo
jpetazzo / inherit.go
Created November 28, 2013 17:01
Sometimes you think you understand a language, and then, you stumble on obvious things and feel very embarrassed.
package main
import "fmt"
type Base struct {
}
func (b *Base) Area () int {
return 2*b.Radius()
}
@jpetazzo
jpetazzo / etc_network_interfaces
Last active December 27, 2015 00:49
Example of /etc/network/interfaces file with docker0 configuration
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet dhcp