Benchmarks demonstrating how struct size and memory layout affect performance due to CPU cache behavior. Companion code for the blog post Every byte matters.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: GPL-2.0 | |
| /* | |
| * shebang_origin.bpf.c - $ORIGIN-relative shebang (#!) interpreter resolution. | |
| * | |
| * A binfmt_misc_ops handler for scripts whose interpreter line is | |
| * "#!$ORIGIN/...": the interpreter is resolved relative to the directory of | |
| * the script and selected via bpf_binprm_set_interp(). Ordinary scripts are | |
| * declined so binfmt_script handles them. | |
| * | |
| * The whole shebang line is in the prefetched bprm->buf, so no file read is |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| description = "Linux Kernel Development Environment"; | |
| inputs = { | |
| nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11"; | |
| }; | |
| outputs = { | |
| self, | |
| nixpkgs, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: GPL-2.0 | |
| /* | |
| * binfmt_misc 'B' (BPF) program: match aarch64 ELF binaries and choose the | |
| * interpreter (qemu-aarch64) dynamically via bpf_binprm_set_interp(). | |
| * | |
| * The program is given the BINPRM_BUF_SIZE file header as context. It inspects | |
| * the ELF header and, on a match, sets the interpreter and returns 1. This | |
| * makes the handler a superset of a traditional magic rule: the program both | |
| * decides the match and computes the interpreter path (it could equally derive | |
| * a path relative to the binary). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "encoding/json" | |
| "fmt" | |
| "os" | |
| "os/exec" | |
| "strings" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ClassPathInfo = provider( | |
| "Provider for classpath information", | |
| fields = { | |
| "compile_jars": "A json fragment containing the mapping of the current jar to its source jar", | |
| }, | |
| ) | |
| def _classpath_aspect_impl(target, ctx): | |
| java_info = target[JavaInfo] | |
| compile_jars = depset( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| FlatBuffer Java rule for Bazel | |
| """ | |
| FlatbufferInfo = provider( | |
| doc = "A provider for FlatBuffer schema files.", | |
| fields = { | |
| "fbs_files": "The list of fbs files that were used as inputs", | |
| }, | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| genrule( | |
| name = "check_cgroup", | |
| outs = ["cgroup_output.txt"], | |
| cmd = """ | |
| set -euo pipefail | |
| echo "==== /proc/self/cgroup ====" > $@ | |
| cat /proc/self/cgroup >> $@ | |
| echo "" >> $@ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/env python3 | |
| import subprocess | |
| import re | |
| import datetime | |
| from collections import defaultdict, Counter | |
| import argparse | |
| import os | |
| import sys |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import os | |
| from xml.etree import ElementTree as ET | |
| from xml.dom import minidom | |
| # Usage: python gen_classpath.py jars.txt /path/to/bazel/workspace | |
| def find_binary_jar(source_jar): | |
| """Replace '-sources.jar' or '-src.jar' with '.jar' or 'lib' prefix if necessary""" | |
| dir_name, file_name = os.path.split(source_jar) |
NewerOlder