Documentation
¶
Overview ¶
Package bench assembles the deterministic per-partition costs of doc 14 into the hundred-billion projection. It measures the two numbers that are counted, not timed, on a real corpus partition: the .meguri bytes per URL (section 3.8) and the seen-set bits per URL with its achieved false-positive rate (section 3.7). Then it multiplies each by a stated partition count to project the fleet totals (section 6), keeping the multiplication visible so a reader can substitute their own count and recompute.
The split is the one doc 14 section 2 draws: byte and bit counts are deterministic, so they need no best-of-N and no contention defense and live here; the contended latencies (schedule selection, queue ops, dedup throughput) stay in the go test -bench micro-benchmarks where benchstat can defend them. This package owns only the part of the proof that is a count.
Index ¶
- Constants
- func BaselineReport(bl Baseline) string
- func HostKeyRangeReport(r HostKeyRange) string
- func RebalanceReport(c RebalanceCost) string
- func Report(meas Measured, proj Projection, walls []Wall) string
- func ThroughputReport(t Throughput) string
- type Baseline
- type HostKeyRange
- type Measured
- type PolitenessPoint
- type Projection
- type RebalanceCost
- type RegionCost
- type Throughput
- type Wall
Constants ¶
const ( // PinnedCorpusHostKeyLo and PinnedCorpusHostKeyHi bound the host-key range the // frozen corpus covers: the lowest and highest meguri.HostKeyOf over its // distinct hosts. Every corpus host-key falls in [lo, hi]. PinnedCorpusHostKeyLo uint64 = 0x094047007b11482a PinnedCorpusHostKeyHi uint64 = 0xbd81fc1c46f41981 // PinnedCorpusHosts is the count of distinct hosts the range spans, the host // groups the corpus seeds resolve to. PinnedCorpusHosts int = 11 )
The benchmark corpus is a frozen Common Crawl slice (CC-MAIN-2026-25, the seed domains in corpus/MANIFEST). M1 through M5 seeded it by domain: the gates loaded every captured URL and never asked which slice of the host-key space those domains land in. At 100B pages a benchmark cannot enumerate domains; it pins a host-key range and crawls the hosts whose key falls in it, the way the fleet router slices ownership by host-key range (the HostKeyLo/HostKeyHi a partition's .meguri header and the partition map both carry). Pinning the range makes the benchmark slice reproducible as a key interval, not a domain list, and ties it to the jump-hash ownership math the fleet runs at scale (doc 12, doc 14, audit 288).
The pinned bounds below are the min and max HostKeyOf over the frozen corpus's distinct hosts, computed once and frozen here. A gate recomputes the range from corpus/urls.jsonl and asserts it still matches, so a corpus that drifts off the pin fails loudly rather than silently re-baselining a measurement.
Variables ¶
This section is empty.
Functions ¶
func BaselineReport ¶
BaselineReport renders the doc 14 section 7 seen-set baseline comparison: the naive exact-key frontier floor paired against meguri's measured seen-set, with the named external systems cited as the floor's ceiling, not measured here.
func HostKeyRangeReport ¶
func HostKeyRangeReport(r HostKeyRange) string
HostKeyRangeReport renders the pinned range for the bench command, the methodology line that records the benchmark corpus is a host-key interval, not a domain list.
func RebalanceReport ¶
func RebalanceReport(c RebalanceCost) string
RebalanceReport renders the doc 12 section 8 rebalance-vs-bandwidth arm: when the fleet grows from one source partition to NewParts, how many hosts and URLs move, the .meguri bytes that ships, and the transfer-time floor at the stated device bandwidth. It is printed under the walls so the redistribution floor that Walls names in formula gets a measured count beside it. The bandwidth is the caller-named wall, not a measured disk; the fleet-box re-run that times a real link is the companion noted in the block.
func Report ¶
func Report(meas Measured, proj Projection, walls []Wall) string
Report renders the measured per-partition costs, the fleet projection, and the three named walls as one stable human-readable block, the form `meguri bench` prints. It is the assembled D19 statement: every fleet number sits next to the measured per-partition cost and the count it was multiplied by, and every wall is named with its formula, so nothing fleet-scale appears as a bare round number.
func ThroughputReport ¶
func ThroughputReport(t Throughput) string
ThroughputReport renders the doc 14 section 5.3 throughput analysis: the measured scheduler selection rate against the politeness ceiling the same partition imposes, the fetcher-bound gap between them, and the polite-dispatch ceiling as the number of active hosts grows. It is printed under the main report so the headline scheduler number never stands without the host-set ceiling it actually runs against.
Types ¶
type Baseline ¶
type Baseline struct {
NaiveBitsPerURL float64 // 128, the exact-key floor of a naive frontier
MeguriBitsPerURL float64 // measured seen-set bits/url
MemoryRatio float64 // naive / meguri, the paired ratio
NaiveFleetBytes float64 // naive bits/url x TotalURLs / 8
MeguriFleetBytes float64 // meguri bits/url x TotalURLs / 8
Calc string // the paired multiplication, shown
// The approximate-membership model arm: a plain bloom filter sized to hit
// meguri's own measured false-positive rate, computed from the optimal-bloom
// formula m/n = -ln(p)/(ln2)^2, not run. It is the fair lower bound on any
// approximate set at the same accuracy, and the gap to meguri's measured cost is
// the premium meguri pays for the exact tier (zero false negatives plus the
// ability to enumerate), named not hidden. Zero when no FP rate was measured.
BloomFPRate float64 // the FP rate the bloom is sized for, meguri's own
BloomBitsPerURL float64 // optimal bloom bits/url at BloomFPRate
BloomFleetBytes float64 // bloom bits/url x TotalURLs / 8
MeguriPremiumBits float64 // meguri bits/url minus the bloom optimum
}
Baseline is the doc 14 section 7 paired comparison of meguri's seen-set against a naive exact-key frontier. It is the deterministic, counts-not-timed arm of the baseline comparison: the memory a naive frontier must spend to answer the same dedup question, paired against meguri's measured cost, projected to the fleet. The named external systems (Nutch, a RocksDB frontier, Frontera) are cited separately because measuring their real overhead needs the systems themselves on a fleet box; this arm fixes the floor they cannot beat.
func NaiveFrontierBaseline ¶
NaiveFrontierBaseline builds the seen-set baseline comparison: the naive exact-key store at 128 bits/url against meguri's measured seen-set bits/url, both projected to the stated fleet total. The ratio is the paired number doc 14 section 7 asks for, the factor by which the approximate tiered filter undercuts an exact key set before any LSM or per-record overhead is added.
type HostKeyRange ¶
HostKeyRange is the host-key interval a corpus slice covers, the range-pinned form of the benchmark seed set. Lo and Hi are the inclusive bounds; Hosts is the distinct host count inside them.
func CorpusHostKeyRange ¶
func CorpusHostKeyRange(hostKeys []uint64) HostKeyRange
CorpusHostKeyRange computes the host-key range over a set of distinct host keys: the min and max key and the host count. It is how the gate derives the live range from the corpus to check it against the pin. An empty input yields a zero range.
func PinnedRange ¶
func PinnedRange() HostKeyRange
PinnedRange returns the frozen host-key range the gate checks the corpus against.
func (HostKeyRange) Contains ¶
func (r HostKeyRange) Contains(hostKey uint64) bool
Contains reports whether a host-key falls inside the range, the test a fleet partition runs to decide it owns a host's URLs.
func (HostKeyRange) SpanFraction ¶
func (r HostKeyRange) SpanFraction() float64
SpanFraction is the share of the full 64-bit host-key space the range covers, a rough gauge of how much of the fleet's key space the corpus slice exercises. The frozen corpus spans a wide interval because its seed hosts scatter across the hash, so the fraction is near one even though only a handful of hosts land in it.
type Measured ¶
type Measured struct {
URLs int // distinct urls in the partition, the divisor for every per-url cost
Hosts int // distinct hosts
FileBytes int // the encoded .meguri size
BytesPerURL float64 // FileBytes / URLs, the section 3.8 redistribution number
Regions []RegionCost // per-region byte breakdown from the footer directory
SeenSetBits int // resident filter bits over the held keys
BitsPerURL float64 // SeenSetBits / URLs, the section 3.7 seen-set number
FPProbes int // held-out keys probed for a filter false positive
FPHits int // probes the filter false-positived on
FPRate float64 // FPHits / FPProbes, the rate achieved at BitsPerURL
FalseNegatives int // held keys the one-sided filter missed; must be 0
}
Measured holds the deterministic per-partition costs measured on a real partition. Every field is a counted quantity, not a target and not a timing, so it carries no best-of-N: the file is encoded once and its bytes counted, the seen-set is filled once and its bits counted. These are the numbers the fleet projection multiplies, so they are reported as measured before any projection is allowed to use them (doc 14, sections 3.7, 3.8, the D19 rule).
func Measure ¶
Measure counts the deterministic per-partition costs on one real partition. It encodes the partition to a .meguri file and counts the bytes per URL and per region, then fills a seen-set sized to the real key count and counts the bits per URL, the achieved false-positive rate against held-out probe keys, and the false-negative count that a one-sided filter must keep at zero. It mutates nothing the caller owns and times nothing, so the result is reproducible to the byte.
type PolitenessPoint ¶
PolitenessPoint is one point on the polite-dispatch ceiling curve: when the ActiveHosts fastest hosts of a partition are simultaneously dispatchable, the partition can be fetched at most CeilingFPS fetches per second without breaking any host's crawl delay.
func PolitenessCurve ¶
func PolitenessCurve(part *format.Partition, ks []int) []PolitenessPoint
PolitenessCurve returns the polite-dispatch ceiling at each active-host count in ks, the curve doc 14 section 5.3 plots throughput against. It sorts the partition's hosts by their per-host fetch rate (fastest first) and prefix-sums, so the ceiling at k active hosts is the most a crawler could politely fetch if it kept the k fastest hosts busy. The shape is the central scaling fact of a polite crawler: throughput rises with the number of active hosts and with nothing else, which is why a frontier that holds millions of hosts resident is the lever, not a faster scheduler (IRLbot section 4, BUbiNG section 3). A k past the host count is clamped to the whole partition.
type Projection ¶
type Projection struct {
TotalURLs float64 // the canon scale target, 100 billion
URLsPerPartition float64 // the pinned per-partition capacity, the lever
PartitionCount float64 // TotalURLs / URLsPerPartition, derived not assumed
SeenSetFleetBytes float64 // measured bits/url x TotalURLs / 8
SeenSetFleetCalc string // the multiplication, shown
SeenSetPerPart float64 // SeenSetFleetBytes / PartitionCount, the per-machine share
MeguriFleetBytes float64 // measured bytes/url x TotalURLs
MeguriFleetCalc string // the multiplication, shown
MeguriPerPart float64 // MeguriFleetBytes / PartitionCount, one file per partition
}
Projection is the section 6 fleet projection: each fleet total is one measured per-partition cost times a stated count. The multiplication is kept as a string next to the product so a reader can read off the per-partition number and the count, substitute their own count, and recompute, which is the form D19 requires of every hundred-billion figure.
func Project ¶
func Project(meas Measured, totalURLs, urlsPerPartition float64) Projection
Project multiplies the measured per-partition costs out to the fleet totals at a stated total URL count and per-partition capacity. The partition count falls out as total/per-partition rather than being assumed, so the count is derived from a real measured capacity (doc 14, section 6.1). Both fleet totals are the measured-times-count form, with the multiplication captured in the *Calc strings.
type RebalanceCost ¶
type RebalanceCost struct {
NewParts int // partitions the fleet grew to (the source was partition 0)
SourceHosts int // hosts on the source before the move
SourceURLs int // URLs on the source before the move
SourceBytes int // encoded .meguri size of the source
MovedHosts int // hosts that changed owner and ship out
MovedURLs int // URLs carried by the moved hosts
ShippedBytes int // encoded .meguri size of all the ship slices
Destinations int // distinct new owners the source ships to
MovedFraction float64 // ShippedBytes / SourceBytes
BandwidthMBps float64 // the device-bandwidth floor the caller names
TransferSec float64 // ShippedBytes / (BandwidthMBps x 1e6)
Calc string // the shown division
}
RebalanceCost is the deterministic, counts-not-timed arm of the doc 12 section 8 rebalance-vs-bandwidth measurement: when the fleet grows from a single source partition to newParts partitions, how many hosts and URLs move off the source, how many .meguri bytes that ships, what fraction of the source file that is, and the transfer-time floor at a stated device bandwidth. It is the count side of the device-bandwidth wall (Walls' redistribution floor): a byte-counting pass can measure the moved bytes exactly, and divides them by a bandwidth the caller names rather than a disk this pass cannot touch. The at-scale re-run on the fleet box that measures a real disk and link is the timed companion.
func Rebalance ¶
Rebalance measures what one source partition ships when the fleet grows from holding it whole to newParts partitions. It runs the real jump-hash rebalance (the source is partition 0 under the new map; Redistribute groups the hosts whose owner changed by new owner and slices each out as its own .meguri-ready partition), encodes those ship slices to count the bytes that cross the wire, and divides by the named bandwidth. Because the URL table is sorted by HostKey a moved host is a contiguous range, so the cost is the moved bytes over the bandwidth wall, not a row-by-row migration. The kept-plus-moved URL count equals the source's, the proof that a host moves whole or not at all (D2).
type RegionCost ¶
RegionCost is one row of the .meguri byte breakdown: a named region, its bytes, and its share per URL. The breakdown is not optional (doc 14, section 3.8): it shows where the compression came from and which regions are the floor.
type Throughput ¶
type Throughput struct {
SchedulerFPS float64 // measured scheduler selections/s, the operator's benchstat figure
PoliteCeilingFPS float64 // sum over all hosts of 1/crawl_delay, the partition's polite ceiling
MedianHostFPS float64 // 1/crawl_delay at the median host, the per-host floor
ActiveHosts int // hosts with a crawl delay, the ceiling's host count
FetcherBoundGap float64 // SchedulerFPS / PoliteCeilingFPS, how many times the scheduler outruns this host set
HostsToSaturate float64 // active hosts (at the median delay) needed before the scheduler stops being the slack
Curve []PolitenessPoint // the ceiling at a few active-host counts
}
Throughput is the doc 14 section 5.3 throughput analysis: the scheduler's own selection rate measured against the politeness ceiling the same partition imposes, so the gap between them is named, never hidden. The scheduler rate is the measured selections-per-second the operator passes in from BenchmarkCorpusDispatchSelections (this byte-and-curve pass does not time a loop); everything else is computed from the partition's real crawl delays.
func Analyze ¶
func Analyze(part *format.Partition, schedulerFPS float64) Throughput
Analyze builds the throughput analysis for a partition given the measured scheduler selection rate. The fetcher-bound gap is the scheduler rate over the polite ceiling: a gap far above one means the crawler is fetcher-bound, that the scheduler finishes its selection long before politeness lets the next fetch go, the regime every polite web crawler sits in. The hosts-to-saturate count is the scheduler rate divided by the median single-host rate, the number of active hosts a partition would need before the scheduler itself became the bottleneck.
type Wall ¶
Wall names a physical floor a meguri number is reported against, never around (doc 14, section 10). The politeness floor this package measures from the partition's own crawl-delay distribution; the fsync and device-bandwidth floors are device properties named here with their formula and measured by the hardware gates, because a byte-counting pass cannot measure a disk.
func Walls ¶
Walls returns the three honest walls, with the politeness floor filled in from the partition's host crawl delays. The single-host floor is 1/crawl_delay by the definition of politeness, and the partition's polite dispatch rate is the sum over its hosts of one-over-each-delay, the host-parallelism sum doc 14 section 5.3 reports against. The fsync and bandwidth floors carry their formula and the box that measures them, not a number this pass invented.