Skip to content

feat(discovery-core): add iobudget batching, cursor types, and new cost constants - #459

Merged
m-kus merged 1 commit into
mainfrom
pr-split/05-iobudget-cursors
Feb 17, 2026
Merged

m-kus merged 1 commit into
mainfrom
pr-split/05-iobudget-cursors

Conversation

@m-kus

@m-kus m-kus commented Feb 9, 2026 •

Copy link
Copy Markdown

TL;DR

Added cursor types and improved I/O budget functionality to support batch discovery operations.

What changed?

  • Added new cursor types (DiscoveryCursor, ChannelCursor, SubchannelCursor) to track progress across paginated discovery calls
  • Enhanced IoBudget with batch budget functionality and a new consume_up_to method for more efficient resource allocation
  • Added cost constants for various discovery operations
  • Added the futures crate dependency to support async operations

This change is Reviewable

m-kus commented Feb 9, 2026 •

Copy link
Copy Markdown
Author

@m-kus
m-kus marked this pull request as ready for review February 9, 2026 19:25
@m-kus
m-kus force-pushed the pr-split/05-iobudget-cursors branch from 9207333 to ab8658c Compare February 9, 2026 19:27
@m-kus
m-kus requested a review from Yoni-Starkware February 9, 2026 19:30
@m-kus
m-kus force-pushed the pr-split/05-iobudget-cursors branch from ab8658c to 680b6bc Compare February 11, 2026 13:05
@m-kus
m-kus force-pushed the pr-split/04-secretfelt-migration branch from 848fff3 to 3ae8597 Compare February 11, 2026 13:05
@m-kus
m-kus force-pushed the pr-split/05-iobudget-cursors branch from 680b6bc to 8cf9538 Compare February 11, 2026 15:07
@m-kus
m-kus force-pushed the pr-split/04-secretfelt-migration branch from 3ae8597 to 210b963 Compare February 11, 2026 15:07
@m-kus
m-kus force-pushed the pr-split/04-secretfelt-migration branch from 210b963 to d666926 Compare February 11, 2026 16:08
@m-kus
m-kus force-pushed the pr-split/05-iobudget-cursors branch from 8cf9538 to 7d40aef Compare February 11, 2026 16:08
@m-kus
m-kus changed the base branch from pr-split/04-secretfelt-migration to graphite-base/459 February 11, 2026 19:05
@m-kus
m-kus force-pushed the pr-split/05-iobudget-cursors branch from 7d40aef to ab28315 Compare February 11, 2026 19:10
@m-kus
m-kus force-pushed the graphite-base/459 branch from d666926 to 0f0ab25 Compare February 11, 2026 19:10
@m-kus
m-kus changed the base branch from graphite-base/459 to main February 11, 2026 19:10

@Yoni-Starkware Yoni-Starkware left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@Yoni-Starkware reviewed 4 files and all commit messages, and made 2 comments.
Reviewable status: 4 of 6 files reviewed, 2 unresolved discussions (waiting on @m-kus).


crates/discovery-core/src/io_budget.rs line 73 at r1 (raw file):

        if cost_per_item == 0 || max_items == 0 {
            return 0;
        }

cost_per_item=0 means you can consume as many items as you want.
If you don't want to support that, please assert that cost_per_item != 0

Code quote:

    pub fn consume_up_to(&self, max_items: usize, cost_per_item: usize) -> usize {
        if cost_per_item == 0 || max_items == 0 {
            return 0;
        }

crates/discovery-core/src/io_budget.rs line 86 at r1 (raw file):

                    Some(current - num_items * cost_per_item)
                }
            })

Suggestion, a bit clearer

Suggestion:

        let max_items_cap = max_items.min(self.batch_budget / cost_per_item);
        if max_items_cap == 0 {
            return 0;
        }
        self.remaining
            .fetch_update(Ordering::SeqCst, Ordering::SeqCst, |current| {
                let num_items = (current / cost_per_item).min(max_items_cap);
                let count = num_items * cost_per_item;
                current.checked_sub(count)
            })

@Yoni-Starkware Yoni-Starkware left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@Yoni-Starkware resolved 1 discussion.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @m-kus).

@Yoni-Starkware Yoni-Starkware left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@Yoni-Starkware made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @m-kus).


crates/discovery-core/src/io_budget.rs line 38 at r2 (raw file):

    /// Sets the batch budget (max budget units per batch). Returns `self` for chaining.
    pub fn with_batch_budget(mut self, batch_budget: usize) -> Self {
        self.batch_budget = batch_budget;

Thinking about this again, why do we need the batch budget here?

Why not as a config of the state reader? batch_size merely limits the size of a single read request. I don't see a problem in handling bigger requests, just in chunks of that size, iteratively.

@m-kus
m-kus changed the base branch from 02-12-fix_use_patched_devnet_add_contract_feature_to_skip_proof_validation to graphite-base/459 February 16, 2026 10:11
@m-kus
m-kus force-pushed the graphite-base/459 branch from 00f57ec to 32f582c Compare February 16, 2026 10:38
@m-kus
m-kus force-pushed the pr-split/05-iobudget-cursors branch from f30ad55 to 06bd4d7 Compare February 16, 2026 10:38
@m-kus
m-kus changed the base branch from graphite-base/459 to main February 16, 2026 10:38
@m-kus
m-kus force-pushed the pr-split/05-iobudget-cursors branch from 06bd4d7 to fbe6761 Compare February 16, 2026 11:57

@m-kus m-kus left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@m-kus made 1 comment.
Reviewable status: 5 of 7 files reviewed, 1 unresolved discussion (waiting on @Yoni-Starkware).


crates/discovery-core/src/io_budget.rs line 38 at r2 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

Thinking about this again, why do we need the batch budget here?

Why not as a config of the state reader? batch_size merely limits the size of a single read request. I don't see a problem in handling bigger requests, just in chunks of that size, iteratively.

Done.

@m-kus
m-kus requested a review from Yoni-Starkware February 16, 2026 12:05
@m-kus
m-kus force-pushed the pr-split/05-iobudget-cursors branch from fbe6761 to 193a70c Compare February 16, 2026 12:08
@m-kus
m-kus enabled auto-merge (squash) February 16, 2026 12:43

@Yoni-Starkware Yoni-Starkware left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

:lgtm:

@Yoni-Starkware reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on m-kus).

@Yoni-Starkware Yoni-Starkware left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@Yoni-Starkware made 1 comment and resolved 1 discussion.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on m-kus).


crates/discovery-core/src/io_budget.rs line 38 at r2 (raw file):

Previously, m-kus (Michael Zaikin) wrote…

Done.

Thanks!

@m-kus
m-kus force-pushed the pr-split/05-iobudget-cursors branch from 193a70c to 8f63cdc Compare February 17, 2026 12:15
@m-kus
m-kus merged commit 8ec28e1 into main Feb 17, 2026
6 checks passed
@m-kus
m-kus deleted the pr-split/05-iobudget-cursors branch February 17, 2026 12:17
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.

2 participants