Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: piecereader: Allow parallel access #10913

Merged
merged 9 commits into from
May 30, 2023
Merged

Conversation

magik6k
Copy link
Contributor

@magik6k magik6k commented May 23, 2023

Related Issues

Closes #10532
Replaces #10895

Proposed Changes

  • Allow pieceReader reader-getters to define exact read size
  • Rewrite pieceReader.ReadAt to be called in parallel, while still caching small amounts ahead for parallel sequential reads
    • This is necessary, because carv1 reads byte-by-byte for the header/cid varints, saves ~9 requests per block read
  • Kept the old more aggressive prefetching mechanism for ReadSeeker, which is only used by the indexing scan, and makes it wayy faster

Additional Info

  • Make sure tests pass
  • Test on a real setup, best in booster-bitswap
    • With a race detector

This PR is based on v1.23.0 so that it's possible to test with boost

Proposed Changes

Checklist

Before you mark the PR ready for review, please make sure that:

  • Commits have a clear commit message.
  • PR title is in the form of of <PR type>: <area>: <change being made>
    • example: fix: mempool: Introduce a cache for valid signatures
    • PR type: fix, feat, build, chore, ci, docs, perf, refactor, revert, style, test
    • area, e.g. api, chain, state, market, mempool, multisig, networking, paych, proving, sealing, wallet, deps
  • New features have usage guidelines and / or documentation updates in
  • Tests exist for new functionality or change in behavior
  • CI is green

@magik6k magik6k requested a review from a team as a code owner May 23, 2023 11:34
storage/sealer/piece_provider.go Outdated Show resolved Hide resolved
storage/sealer/piece_provider.go Outdated Show resolved Hide resolved
}

func (p *pieceReader) init() (_ *pieceReader, err error) {
stats.Record(p.ctx, metrics.DagStorePRInitCount.M(1))

p.seqMCtx, _ = tag.New(p.ctx, tag.Upsert(metrics.PRReadType, "seq"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

context.Context is never supposed to be stored in a struct, so:
can we have init(ctx context.Context) ?
Here and the next line, can tag.New take that Context and return it as well (since it should be non-destructive).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeahh, moved the ctx into init params, but the MCtx ones will probably have to stay in that struct - opencensus sadly needs a context to record stats on (technically we could hack into it's internal packages, but that's even more gnarly)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea of passing context around is that it follows the goroutine & opencensus is producing a stat on that. Is this stat on a shared thing that cannot be expressed individually by the callers?

storage/sealer/piece_provider.go Outdated Show resolved Hide resolved
storage/sealer/piece_reader.go Show resolved Hide resolved
@magik6k magik6k force-pushed the feat/piecereader-perf branch from 415089f to b58daf5 Compare May 25, 2023 14:05
@snadrus
Copy link
Collaborator

snadrus commented May 25, 2023 via email

@magik6k
Copy link
Contributor Author

magik6k commented May 26, 2023

Merged master into here so that the previous commits can still be depended on in boost

Should be mergeable now.

@magik6k magik6k merged commit 96fa081 into master May 30, 2023
@magik6k magik6k deleted the feat/piecereader-perf branch May 30, 2023 16:49
@rjan90 rjan90 mentioned this pull request Jun 15, 2023
@arajasek arajasek mentioned this pull request Jul 10, 2023
40 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Re-tune piece-reader to allow for random parallel access of data
2 participants