Skip to content

Instantly share code, notes, and snippets.

@Sap333
Sap333 / gist:da469ff2c28187da77a5
Last active April 7, 2024 09:32 — forked from anonymous/gist:5acb19edda22e18b6d1a
VirtualBox VMs optimization
1. Set paravirtualization provider KVM for Linux (since 2.6.25) guests and Hyper-V for Windows (since Windows 7) guests.
2. Set ICH9 chipset for guest machine (may have some issues).
3. Enable nested paging.
4. Enable VT-x virtualzation. Notice: Runing both software and hardware virtualization simlutaneously slows down the emulation.
5. Enable "Virtual Processor Identifiers" (VPIDs). Has large performance impact but guest's CPU may depend on hosts's CPU:
VBoxManage modifyvm VM_NAME --vtxvpid on
6. Enable large pages - gives up to 5% performance boost:
VBoxManage modifyvm VM_NAME --largepages on
7. Enable SSE 4.1 and 4.2 for guest VM (an experemental option!):
VBoxManage setextradata VM_NAME VBoxInternal/CPUM/SSE4.1 1
@Sap333
Sap333 / sap_make_bundle.sh
Last active November 11, 2015 20:10
Setup bundle builder. Creates/makes runnable installer (bash script) which contains an installer script (bash) and embedded base64 encoded tar archive.
#!/bin/bash
# I need a job!
declare VERSION='1.2' # Script version.
function eexit {
local EXITCODE=2; [ "$1" -eq "$1" ] 2>/dev/null && EXITCODE="$1" && shift
[ $# -ne 0 ] && echo 'Error:' "$@" >&2
exit "$EXITCODE" ; exit 1
}
@Sap333
Sap333 / sap.cphl.sh
Last active November 5, 2015 22:48
Copy a directory tree using hardlinks (converting soft links to hard links).
#!/bin/bash
function printUsage {
echo "Usage:
$(basename "${BASH_SOURCE[0]}") <SRC_DIR> <DST_DIR>
Makes a recursive copy of <SRC_DIR> to <DST_DIR> using harlinks and avoiding softlinks.
If <DST_DIR> exists then creates there a subdirectory with name of <SRC_DIR>. Otherwise,
creates <DST_DIR> and uses it as a destination directory." >&2
exit $0
}
@Sap333
Sap333 / KillAllChildProcessesOnExit.py
Last active May 19, 2024 15:20 — forked from anonymous/KillAllChildProcessesOnExit.py
Kill all child processes on program exit. Also catches (sets up a hande) the SIGTERM signal to process it gracefully. Python. Linux/Posix only.
#!/usr/bin/python3
# It is for Python3 but may work for modern 2.x versions as well.
import os, signal, atexit
# Signletone which is made as a class with static methods.
# The "init()" method must be called before any child process are created.
# "killAllChildrenOnce" or "killAllChildren" methods could be called
# any time to kill all child processes.
# Creates a new process group during initialization and uses it to send