Skip to content

Instantly share code, notes, and snippets.

@travisdowns
travisdowns / README.md
Last active October 2, 2026 14:56
Claude Code status line: 5-hour usage, time until reset, and a projection to the end of the window

claude-statusline

A Claude Code status line that shows your 5-hour usage, how long until it resets, where usage is heading by the end of the window, and this month's extra usage spend.

annotated status line

  • ctx: how full the current conversation's context window is.
  • 5h usage / time until reset: your subscription's 5-hour usage limit.
  • projected at reset: current usage plus the recent rate times the time left. The 5h segment is colored by it: green up to 50%, shading to yellow at 65% and red at 100% or more.
  • rate: usage per hour over the last --avg minutes.
@travisdowns
travisdowns / README.md
Created July 16, 2026 07:16
static vs static inline: inlining behavior sweep for clang-20 / gcc-13 (seastar PR 3519 discussion)

inline is still an optimization hint (clang-20 demo)

Empirical demo for the claim in scylladb/seastar#3519 (comment): in modern compilers static inline is a materially stronger hint to inline than plain static — the keyword is not just linkage/ODR relief.

Result

With clang-20 at -O2, the same function body is:

@travisdowns
travisdowns / README.md
Created July 15, 2026 06:45
Reproducers for seastar issue #1784 / PR #1788: io_submit EAGAIN abort in aio_general_context::flush()

Reproducers for seastar issue #1784 / PR #1788

io_submit EAGAIN + abort on SEASTAR_ASSERT(clock::now() < retry_until) in aio_general_context::flush().

Two programs:

1. raw_aio_eagain.c — kernel-only demonstration (no seastar)

Shows the kernel mechanics directly: creates an aio context, reads the actual

#!/usr/bin/env bash
set -euo pipefail
export DEBIAN_FRONTEND=noninteractive
# Build Seastar framework from source
# This script clones the Seastar repository, installs dependencies,
# configures the build with required libraries, and compiles the project.
dd if=/dev/urandom of=64mib.bin bs=1024K count=64
echo $((64*1024*1024))
time tail -c +$((16*1024*1024+1)) 64mib.bin | head -c $((32*1024*1024+1)) > out.bin
ls -lh out.bin
@travisdowns
travisdowns / conc-run.sh
Last active July 6, 2020 23:57
set up ec2 ubuntu box
#!/bin/bash
set -euo pipefail
echo "Running $0"
sudo apt update
sudo apt install -y build-essential
mkdir dev && cd dev
git clone https://github.com/travisdowns/concurrency-hierarchy-bench.git
cd concurrency-hierarchy-bench
/*
* cxxstacks.hpp
*/
#ifndef CXXSTACKS_HPP_
#define CXXSTACKS_HPP_
#include <string.h>
#include <string>
@travisdowns
travisdowns / mlp.md
Last active November 30, 2019 19:33

MLP vs size for SKL, SKX and Zen2. Insprired by similar charts produced by Andrei at AnandTech.

Size here is in 8-byte units (sorry), so 10^7 means 80,000,000 bytes.

Data is generated using the console version of MemoryLanes:

MLP_CSV=2 MLP_START=1 MLP_STOP=20000 ./testingmlp > out

Charts generated like:

@travisdowns
travisdowns / cache-counters-rant.md
Created October 13, 2019 16:46
Discussion of x86 L1D related cache counters

The counters that are the easiest to understand and the best for making ratios that are internally consistent (i.e., always fall in the range 0.0 to 1.0) are the mem_load_retired events, e.g., mem_load_retired.l1_hit and mem_load_retired.l1_miss.

These count at the instruction level, i.e., the universe of retired instructions. For example, could make a reasonable hit ratio from mem_load_retired.l1_hit / mem_inst_retired.all_loads and it will be sane (never indicate a hit rate more than 100%, for example).

That one isn't perfect though, in that it may not reflect the true costs of cache misses and the behavior of the program for at least the following reasons:

  • It appplies only to loads and can't catch misses imposed by stores (AFAICT there is no event that counts store misses).
  • It only counts loads that retire - a lot of the load activity in your process may be due to loads on a speculative path that never retire. Loads on a speculative path may bring in data that is never used, causing misses and d