main
ply4 git calls29 ms42 KiB3 cachedprotocol v2
78 lines2.7 KiBRaw
1// MurmurHash3_x86_32 (Austin Appleby, public domain), seed 0. The bucket is this hash mod 10_000.
2// A unit's bucket never changes for a fixed (flag, salt, unit), so raising the allocation only adds units.
3import { BUCKETS } from './ttl.ts';
5const C1 = 0xcc9e2d51;
6const C2 = 0x1b873593;
8function rotl(value: number, bits: number): number {
9 return (value << bits) | (value >>> (32 - bits));
12function mix(k: number): number {
13 return Math.imul(rotl(Math.imul(k, C1), 15), C2);
16/** MurmurHash3_x86_32. `seed` defaults to 0. The result is an unsigned 32-bit integer. */
17export function murmur3_32(data: Uint8Array, seed = 0): number {
18 let h1 = seed >>> 0;
19 const blocks = data.length >>> 2;
20 for (let i = 0; i < blocks; i++) {
21 const offset = i * 4;
22 const k = (data[offset]! | (data[offset + 1]! << 8) | (data[offset + 2]! << 16) | (data[offset + 3]! << 24)) >>> 0;
23 h1 ^= mix(k);
24 h1 = (Math.imul(rotl(h1, 13), 5) + 0xe6546b64) >>> 0;
25 }
26 const tail = blocks * 4;
27 const rest = data.length & 3;
28 if (rest > 0) {
29 let k = 0;
30 if (rest >= 3) k ^= data[tail + 2]! << 16;
31 if (rest >= 2) k ^= data[tail + 1]! << 8;
32 k ^= data[tail]!;
33 h1 ^= mix(k);
34 }
35 h1 ^= data.length;
36 h1 ^= h1 >>> 16;
37 h1 = Math.imul(h1, 0x85ebca6b);
38 h1 ^= h1 >>> 13;
39 h1 = Math.imul(h1, 0xc2b2ae35);
40 h1 ^= h1 >>> 16;
41 return h1 >>> 0;
44function u32le(value: number): Uint8Array {
45 const bytes = new Uint8Array(4);
46 new DataView(bytes.buffer).setUint32(0, value, true);
47 return bytes;
50/**
51 * Length-prefixed UTF-8 of (flag, salt, unit). A NUL inside a field cannot alias another field,
52 * because each field carries its byte length.
53 */
54export function hashMaterial(flagKey: string, salt: string, unitId: string): Uint8Array {
55 const encoded = [flagKey, salt, unitId].map(part => new TextEncoder().encode(part));
56 const size = encoded.reduce((sum, part) => sum + 4 + part.length, 0);
57 const out = new Uint8Array(size);
58 let offset = 0;
59 for (const part of encoded) {
60 out.set(u32le(part.length), offset);
61 offset += 4;
62 out.set(part, offset);
63 offset += part.length;
64 }
65 return out;
68/** Bucket in [0, 9999]. Stable for (flagKey, salt, unitId). */
69export function bucketOf(flagKey: string, salt: string, unitId: string): number {
70 return murmur3_32(hashMaterial(flagKey, salt, unitId), 0) % BUCKETS;
73/** True when the unit is inside `basisPoints` (0–10000). One basis point is one bucket, so raising it only adds units. */
74export function inBucket(bucket: number, basisPoints: number): boolean {
75 if (!Number.isInteger(basisPoints) || basisPoints <= 0 || !Number.isInteger(bucket) || bucket < 0 || bucket >= BUCKETS) return false;
76 if (basisPoints >= BUCKETS) return true;
77 return bucket < basisPoints;
Diagnostics4 git calls · 29 ms
CallStatusSizeTime029 ms
discover200152 B2 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=152
git.server.agent=gitty/1.0
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch object-format
git.server.fetch=shallow filter sideband-all
git.protocol.version=2
git.pkt.frames=8
git.pkt.data=6
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=152
git.pkt.payload.max=34
ls-refs200145 B · hit3 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
git.response.bytes=145
git.response.cache=HIT
git.response.duration_ms=3
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=145
git.pkt.payload.max=76
git.ls_refs.count=2
git.ls_refs.head=refs/heads/main
fetchblob:none · deepen 1020040 KiB · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=41349
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=blob:none
git.fetch.filter.requested=tree:0
git.fetch.filter.fallback=blob:none
git.fetch.filter.learned=false
git.fetch.wants=526b305930b8ef382f2d7a1f9c0238730a585921
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=6
git.pkt.data=4
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=41349
git.pkt.payload.max=41254
git.sideband.band1.bytes=41253
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=61
git.pack.bytes=41253
git.pack.ofs_delta=0
git.pack.ref_delta=0
git.pack.chain.max=0
git.pack.trailer=ab60efef4b7243678c75de64a4386986ee885c1c
git.pack.full=61
Open pack map
fetch2001.2 KiB · hit24 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=24
git.response.bytes=1227
git.response.cache=HIT
git.response.duration_ms=24
git.fetch.wants=eef9f481b647c0c5473e5c74a7d755d0fec0f7ce
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=1227
git.pkt.payload.max=1206
git.sideband.band1.bytes=1205
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/ply-web.git
Ref
refs/heads/main
Commit
526b305930b8ef382f2d7a1f9c0238730a585921
cf-ray
a5e2e6aecfadecfa
Request
ad570e26…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format