Should sampled retrieval support pieces up to 1,016 MiB?

Open
#763 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
12/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Active
Tech stack
kubernetes, nodejs, typescript

Research direction

This is a decision question, not a ready task: the issue asks whether sampled retrieval should test pieces up to 1,016 MiB. Read the memory and event-loop notes, then the current limits SAMPLED_MAX_BLOCK_DOWNLOAD_BYTES, HTTP2_REQUEST_TIMEOUT_MS, and the Buffer.concat and readBlocks paths the issue names. Done means the expansion decision and its reasoning are recorded in the issue, with follow-up implementation issues opened if yes.

Written by the indexing model from the issue text.

Description

Do we need this?

Sampled retrieval selects pieces up to 100 MiB and aborts downloads over 200 MiB. Should it also test pieces up to 1,016 MiB, the most raw data a 1 GiB piece can hold?

For

  • Pieces over 200 MiB are never tested, so an SP could serve small pieces well and large ones badly without us seeing it (see #428).
  • For four SPs, these pieces are about half or more of what they store.

Against

  • About 92% of pieces are within 200 MiB, and every sampled SP has some.
  • It needs a new download path, longer jobs and up to 1 GiB of egress per check.
  • Slow SPs may time out: 4 of 10 tested SPs average below the 4.2 MiB/s needed to fetch 1,016 MiB in today's 240s, and 1 of 10 below the 1.7 MiB/s needed in 600s.

Data (mainnet, 2026-11-09)

Random 1/64 sample of active pieces not paid for by dealbot: 8,263 pieces across 19 SPs.

Size Pieces Share
Up to 200 MiB 7,642 92.5%
200 MiB to 1 GiB 621 7.5%
Over 1 GiB 0 0%

A separate scan of over-200 MiB pieces, stopped at 12,000 rows, found 7 over 1 GiB. The largest was 5,888 MiB.

If yes: what it takes

Raising the limit alone won't work:

  • Memory: a piece is held twice during Buffer.concat, then copied again by new Uint8Array(pieceBytes) in readBlocks. A 1,016 MiB piece needs about 2 GiB, which is the worker's memory limit.
  • Event loop: Piece.calculate on a whole buffer blocks the event loop. 100 MiB stalled it for 3.5s on a laptop, so 1 GiB would take about 35s, and longer on a 1-CPU pod. The liveness probe allows 3 failures 20s apart.

Proposed approach:

  1. Download the piece to a file under /datasets, the 5Gi emptyDir already mounted on the worker.
  2. Compute CommP from a file stream. Streaming cut the longest stall to 15ms for 100 MiB.
  3. Parse the CAR as a stream, keep a random sample of blocks, and reject blocks over SAMPLED_MAX_BLOCK_DOWNLOAD_BYTES. The decoder otherwise buffers whatever length the CAR claims.
  4. Add a low-weight bucket for 100 MiB to 1,016 MiB, with at most 2 of these downloads per pod. PG_BOSS_LOCAL_CONCURRENCY defaults to 20, which could otherwise fill the volume.

Hashing during the download would avoid the disk, but the two fastest SPs average 48 and 67 MiB/s against about 29 MiB/s for hashing, so it would cap their measured throughput.

Setting Now Proposed
HTTP2_REQUEST_TIMEOUT_MS 240s 600s
MAINNET_SAMPLED_RETRIEVAL_JOB_TIMEOUT_SECONDS 360s 720s
Worker terminationGracePeriodSeconds 480s 840s

Hash speed on a pod and disk write speed still need measuring on staging.

Open questions

  • Should a timeout on a large piece count as a retrieval failure?
  • What weight should the new bucket have? About 5% would keep added egress and timeouts low.
  • Is 1,016 MiB the right upper limit?

Done when

  • We've decided whether to expand, and up to what size, with the reasoning recorded here.
  • If yes, follow-up work is opened for the implementation and deployment changes.
Dominant language
TypeScript
Stars
2
Forks
9
Avg merge
5d 6h
Merged PRs (30d)
9

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from FilOzone/dealbot

All issues in FilOzone/dealbot

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.