Skip to content

Instantly share code, notes, and snippets.

View CAFxX's full-sized avatar

Carlo Alberto Ferraris CAFxX

View GitHub Profile
@CAFxX
CAFxX / Rethinking Data Placement in Distributed Databases: The Case for Automatic Row Migration.md
Last active February 13, 2026 02:12
Rethinking Data Placement in Distributed Databases: The Case for Automatic Row Migration

Rethinking Data Placement in Distributed Databases: The Case for Automatic Row Migration

Two Roles, One Key

In every horizontally scalable database—Spanner, CockroachDB, YugabyteDB, TiDB, and their descendants—a primary key quietly serves two masters. It is a logical identifier, the application's stable handle for a specific entity. And it is a physical address, the value that determines which node in the cluster stores the row. These two roles are in fundamental tension.

The tension is visible within a single table. A Documents table keyed by DocumentId—a UUID chosen for global uniqueness—scatters documents uniformly across ranges, because range-partitioned databases assign rows to nodes based on key order. But if most transactions access documents belonging to the same tenant, the physical layout is exactly wrong: rows that are always read together are distributed as far apart as the key space allows. The logical choice (UUID for uniqueness) directly conflicts with the physical need (shared

@CAFxX
CAFxX / post.md
Last active January 12, 2026 02:45

The distance between deciding and doing is the single most reliable predictor of whether your life will be extraordinary or ordinary. Not talent, not circumstances, not even the quality of your decisions-but how quickly you collapse the space between intention and reality. Think of this gap as a kind of friction coefficient on your existence: the smaller it is, the more of your internal force actually translates into external motion. When you can move from "I should do this" to physically doing it within hours instead of weeks, you're not just accomplishing more-you're operating in a fundamentally different mode of being where your thoughts have immediate consequences in the world, where your inner life and outer life are in constant, tight conversation.

This matters profoundly because success isn't really about outcomes-it's about iteration speed. The person who can decide and act in the same breath gets ten attempts at something while someone with a week-long gap between decision and execution gets one. Th

@CAFxX
CAFxX / most_frequent_http_headers_keys.csv
Last active December 10, 2025 06:19
Most frequent 10000 HTTP headers keys/values
item frequency
user-agent 739871221
accept-encoding 733869339
accept-language 733614410
accept 729745441
date 724032586
sec-fetch-mode 723555429
sec-fetch-site 723539507
sec-fetch-dest 723538347
content-type 718705785
@CAFxX
CAFxX / golang_bulk_alloc.md
Last active December 5, 2025 05:57
Golang bulk allocations

Bulk memory allocations for Go

Consider the following code:

s := make([]*Foo, N)
for i := range s {
  s[i] = new(Foo)
  // ...
}
@CAFxX
CAFxX / interncache.go
Created December 3, 2025 03:20
interncache
package interncache
import (
"encoding/binary"
"iter"
"maps"
"math"
"math/bits"
"math/rand/v2"
"sync/atomic"
@CAFxX
CAFxX / genRangeTableCode.go
Last active October 13, 2025 08:25
unicode.RangeTable code generator
package main
import (
"fmt"
"math/bits"
"slices"
"sort"
"strings"
"unicode"
)
@CAFxX
CAFxX / postgresql_per_session_transaction_commit_delay.md
Last active June 23, 2025 07:32
Per-session/transaction commit delay

Notes for a proposal to add per-session and/or per-transaction commit delay to postgresql.

Per session/transaction commit delay

Currently postgres has the commit_delay and commit_sibling global configurations.

To better support mixed workloads it would be significantly easier if a bit more flexibility was permitted, e.g. by allowing individual sessions or transactions to specify different acceptable commit delays, while still providing all required guarantees.

Proposal

@CAFxX
CAFxX / golang_heap_reuse.md
Last active June 16, 2025 04:57
Transparent heap object reuse for Go

Transparent heap object reuse for Go

a.k.a. have most hot allocation paths be transparently served by dedicated freelists managed by the compiler and runtime

Important

This document is a work in progress. Early feedback and discussions are welcome.

Known TODOs:

  • How to handle slices
@CAFxX
CAFxX / pwgen.go
Last active May 1, 2025 12:58
pwgen
// https://go.dev/play/p/374e3zUuZmE
package main
import (
"crypto/rand"
"flag"
"fmt"
"maps"
"math/big"
@CAFxX
CAFxX / prompt.txt
Last active April 19, 2025 00:22
Possible partial gemini 2.5 system prompt
As part of a reasoning step, Gemini 2.5 Pro Preview 03-25 randomly blurted out:
---
If multiple possible answers are available in the sources, present all possible answers.
If the question has multiple parts or covers various aspects, ensure that you answer them all to the best of your ability.
When answering questions, aim to give a thorough and informative answer, even if doing so requires expanding beyond the specific inquiry from the user.
If the question is time dependent, use the current date to provide most up to date information.
If you are asked a question in a language other than English, try to answer the question in that language.
Rephrase the information instead of just directly copying the information from the sources.