You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4792e35
Browse filesBrowse the repository at this point in the historyBrowse files
Remote cache: raise read concurrency and stop per-request CAT minting on VPNless (#2246)
Summary:
Remote cache hits are slow mostly because of client-side queueing. On a warm cache Metro starts one `HttpGetStore` GET per module at once (thousands in flight), but `HttpStore` caps its agent at 64 sockets. Most of each logged `Cache get` duration is therefore time spent waiting for a socket; Manifold answers in about 100–150 ms.
On VPNless laptops there is a second cap. Every read carries `x-x2pagentd-inject-cat`, and x2pagentd mints a fresh CAT for every such request (`CatInjectFilter`). That holds reads to about 250/s per laptop, whatever the socket count.
Changes:
- `HttpStore` (metro-cache), both new options documented in `Caching.md`:
- `maxSockets` option; the default stays 64.
- `getParams` option, called before each request (and each retry); the parameters it resolves to are added to `params`, for short-lived credentials. A throw or rejection fails the request with a `NetworkError`, which `HttpGetStore` treats as a miss. Without `getParams`, requests still start synchronously.
- `fb-config/vpnless`: `mintX2PAgentdCat(verifier, validitySeconds)` mints a CAT through x2pagentd's `cats.x2pagentd.local/create` endpoint (the one other tools already use).
- `getManifoldHttpConfig` (reads only):
- 256 sockets, except on VPNless, which keeps 64: those reads go through the laptop's x2pagentd, which other tools share and which stalls upstream under heavy load.
- On VPNless, no inject header. Instead `getParams` mints one `manifold.blobstore` CAT, valid for an hour, reuses it for 50 minutes, then mints again. If minting a replacement fails, reads keep the previous CAT while it is still valid. Reads therefore send the same `crypto_auth_tokens` query parameter that x2pagentd injects today, minted once instead of per read. This does not depend on Manifold accepting reads without a CAT.
- Writes are unchanged.
Rollout notes:
- The `HttpStore` options take effect with the next Metro (MSDK) bump; the prebuilt Metro ignores them until then. The config side loads from the checkout immediately, so until the bump VPNless reads go out with no CAT at all. Manifold accepts that today (verified: reads without a CAT, and with a garbage CAT, return 200 with the payload).
- Transform cache keys hash every file under `xplat/js/config/metro` and `xplat/js/config/vpnless`. As with any config change, commits with this change get remote cache misses until the cache warmer has filled them.
Changelog: [Feature] metro-cache: `HttpStore` accepts `maxSockets`, to raise or lower its connection limit, and `getParams`, to add query parameters (such as a short-lived credential) to every request
Reviewed By: vzaidman
Differential Revision: D132331611
Copy file name to clipboardExpand all lines: docs/Caching.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,10 +44,12 @@ Metro provides these stores for use with [`cacheStores`](./Configuration.md#cach
44
44
-**`HttpStore(options)`** is a bare-bones remote cache client that reads (`GET`) and writes (`PUT`) compressed cache artifacts over HTTP or HTTPS.
45
45
-**`options.endpoint: string`**: Base URL of the cache server. For example, with `'http://www.example.com/endpoint'`, requests go to URLs such as `http://www.example.com/endpoint/c083bff944879d9f528cf185eba0f4962fd4e5b1a6a7d2a1c0bd42c3c0d5f0e1b6a9e7c8` (the hex-encoded cache key).
46
46
-**`options.timeout: number`**: Request timeout in milliseconds. Defaults to 5000.
47
+
-**`options.maxSockets: number`**: Maximum concurrent connections to the cache server. Requests beyond this wait for a free connection, and that wait counts towards the request's duration. Defaults to 64.
47
48
-**`options.family: 4 | 6`**: Same as the `family` parameter to Node's [`http.request`](https://nodejs.org/api/http.html#httprequesturl-options-callback).
-**`options.headers: {[string]: string}`**: HTTP headers sent with every request.
50
51
-**`options.params: URLSearchParams`**: Query parameters appended to every request URL.
52
+
-**`options.getParams: () => Promise<URLSearchParams>`**: Called before every request (and retry); the parameters it resolves to are added to `options.params`. Use it for short-lived credentials such as auth tokens that need refreshing. If it throws or rejects, the request fails with a network error.
51
53
-**`options.additionalSuccessStatuses: Array<number>`**: Additional HTTP status codes treated as success.
52
54
-**`options.maxAttempts: number`**: Maximum attempts per request, with exponential backoff. Defaults to 1 (no retries).
53
55
-**`options.retryStatuses: Set<number>`**: HTTP status codes that trigger a retry.
0 commit comments