Skip to content

Instantly share code, notes, and snippets.

@dt
dt / i-want-to-evaluate-snug-truffle.md
Created May 11, 2026 23:13
Per-SSTable MVCC Upper Time Bound: Design Evaluation

Per-SSTable MVCC Upper Time Bound: Design Evaluation

Context

PCR cutover today uses RevertRange RPCs that iterate every key in the cluster (modulo TBI block skipping) to find and tombstone writes newer than time T. This is O(changed data) in both reads and writes. The idea: attach an MVCC upper time bound to each SST via a single manifest edit, instantly masking all keys > T from all iterators. No loading blocks, no writing tombstones, no compaction of those tombstones — just one manifest write per store.

@dt
dt / glittery-toasting-pebble.md
Last active April 9, 2026 13:46
Zero-Allocation pprof Labels — design doc

Zero-Allocation pprof Labels

Motivation

We want the cost of applying pprof labels to be low enough that we stop conditionally labeling. Today, CockroachDB only applies labels when a profile is actively being collected, checked via an atomic. This means operations that passed the labeling point before profiling started are unlabeled, goroutine dumps are unlabeled, and when labeling IS on, it costs more than it should.

Why isn't the cost zero today?

pprof.Do(ctx, Labels("req", strconv.Itoa(id)), func(ctx) { ... }) triggers 4-5 heap allocations:

package main
import (
"compress/gzip"
"fmt"
"os"
"runtime"
"sync"
"sync/atomic"
"time"
@dt
dt / debug_4.txt
Created August 12, 2025 22:14
debug=4 example
goroutine profile: total 545
1 @ 0x100df3960 0x100e31b9c 0x101590bfc 0x100e387c4
# goroutine: 37
# created by: 12
# created at: os/signal.Notify.func1.1, GOROOT/src/os/signal/signal.go:152 +0x101590cf8
# state: syscall
# waiting: 92 minutes
# 0x100e31b9b os/signal.signal_recv+0x2b GOROOT/src/runtime/sigqueue.go:149
# 0x101590bfb os/signal.loop+0x1b GOROOT/src/os/signal/signal_unix.go:23
@dt
dt / test
Created February 11, 2022 22:11
// Copyright 2022 The Cockroach Authors.
//
// Licensed as a CockroachDB Enterprise file under the Cockroach Community
// License (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt
package backupccl_test
@dt
dt / google-script-append
Created March 29, 2019 03:42
google append to sheet
var f = SpreadsheetApp.openById('1ZPixvI2lBGPTC-3YmmtbRqEJHU5-A02k9Jfhpw2vw9Q');
var sheet = f.getSheetByName('Sheet1');
function doPost(e) {
Logger.log(e);
console.log(e);
parsedData = JSON.parse(e.postData.contents);
var nextFreeRow = sheet.getLastRow() + 1;
sheet.appendRow([parsedData.co2]);
@dt
dt / co2-sensor-google-log.ino
Last active March 30, 2019 20:58
google logging co2 sensor
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266mDNS.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266WebServer.h>
#include <ArduinoOTA.h>
#include "HTTPSRedirect.h"
#include <SoftwareSerial.h>
@dt
dt / gist:0f658f7a96af08cec26af8f0cfb52d08
Created March 26, 2019 12:17
import timings for tpcc 1k
distsql import, csv reader (i.e. master): 55m
I190326 04:27:02.291051 1 ccl/workloadccl/cliccl/fixtures.go:325 starting import of 9 tables
W190326 04:27:02.293200 1 ccl/workloadccl/fixture.go:541 error retrieving automatic stats cluster setting: pq: unknown setting: "sql.stats.automatic_collection.enabled"
I190326 04:27:12.273697 84 ccl/workloadccl/fixture.go:516 imported warehouse (10s, 1000 rows, 0 index entries, 53 KiB)
I190326 04:27:15.543774 85 ccl/workloadccl/fixture.go:516 imported district (13s, 10000 rows, 0 index entries, 1005 KiB)
I190326 04:27:16.486648 90 ccl/workloadccl/fixture.go:516 imported item (14s, 100000 rows, 0 index entries, 7.8 MiB)
I190326 04:29:01.189457 89 ccl/workloadccl/fixture.go:516 imported new_order (1m59s, 9000000 rows, 0 index entries, 126 MiB)
I190326 04:43:08.922034 88 ccl/workloadccl/fixture.go:516 imported order (16m7s, 30000000 rows, 60000000 index entries, 1.8 GiB)
I190326 04:46:40.282246 87 ccl/workloadccl/fixture.go:516 imported history (19m38s, 30000000 row
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266mDNS.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266WebServer.h>
#include <ArduinoOTA.h>
#include <SoftwareSerial.h>
byte cmdRead[2] = {0x86, 0x00};
@dt
dt / backup-cockroach.sh
Created July 24, 2018 19:39
daily cockroachdb backup script
#!/bin/bash
set -euxo pipefail
# this script runs backups, creating full backups when run on the configured
# day of the week and incremental backups when run on other days, tracking the
# backups it has created recently to correctly construct the list of path for
# the INCREMENTAL option.
full_day="Sunday" # Must match (including case) the output of `date +%A`.
what="DATABASE mydb" # what to backup.