Skip to content

Commit e4dfe52

Browse files
committed
core, graph: Rename GRAPH_AMP_MAX_BLOCK_RANGE, lower default
Rename GRAPH_AMP_MAX_BLOCK_RANGE to just GRAPH_AMP_BLOCK_RANGE Lower the default to 100k blocks from 2M blocks
1 parent 9b4d918 commit e4dfe52

5 files changed

Lines changed: 19 additions & 24 deletions

File tree

core/src/amp_subgraph/runner/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub(in super::super) struct Context<AC> {
1919
pub(super) client: Arc<AC>,
2020
pub(super) store: Arc<dyn WritableStore>,
2121
pub(super) buffer_size: usize,
22-
pub(super) max_block_range: usize,
22+
pub(super) block_range: usize,
2323
pub(super) backoff: ExponentialBackoff,
2424
pub(super) deployment: DeploymentHash,
2525
pub(super) manifest: Manifest,
@@ -46,7 +46,7 @@ impl<AC> Context<AC> {
4646
client,
4747
store,
4848
buffer_size: env.buffer_size,
49-
max_block_range: env.max_block_range,
49+
block_range: env.block_range,
5050
backoff,
5151
deployment,
5252
manifest,

core/src/amp_subgraph/runner/data_stream.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ where
3434
let client = cx.client.cheap_clone();
3535
let manifest = cx.manifest.clone();
3636
let buffer_size = cx.buffer_size;
37-
let max_block_range = cx.max_block_range;
37+
let block_range = cx.block_range;
3838
let stopwatch = cx.metrics.stopwatch.cheap_clone();
3939

4040
debug!(logger, "Creating data stream";
4141
"from_block" => cx.latest_synced_block().unwrap_or(BlockNumber::MIN),
4242
"to_block" => latest_block,
4343
"start_block" => cx.start_block(),
44-
"max_block_range" => max_block_range,
44+
"block_range" => block_range,
4545
);
4646

4747
// State: (latest_queried_block, end_block, is_first)
@@ -52,7 +52,7 @@ where
5252
move |(latest_queried_block, mut end_block, is_first)| {
5353
let block_ranges = next_block_ranges(
5454
&manifest.data_sources,
55-
max_block_range,
55+
block_range,
5656
latest_queried_block,
5757
latest_block,
5858
);
@@ -171,21 +171,16 @@ where
171171

172172
fn next_block_ranges(
173173
data_sources: &[DataSource],
174-
max_block_range: usize,
174+
block_range: usize,
175175
latest_queried_block: Option<BlockNumber>,
176176
latest_block: BlockNumber,
177177
) -> HashMap<usize, RangeInclusive<BlockNumber>> {
178178
let block_ranges = data_sources
179179
.iter()
180180
.enumerate()
181181
.filter_map(|(i, data_source)| {
182-
next_block_range(
183-
max_block_range,
184-
data_source,
185-
latest_queried_block,
186-
latest_block,
187-
)
188-
.map(|block_range| (i, block_range))
182+
next_block_range(block_range, data_source, latest_queried_block, latest_block)
183+
.map(|block_range| (i, block_range))
189184
})
190185
.collect::<HashMap<_, _>>();
191186

@@ -204,7 +199,7 @@ fn next_block_ranges(
204199
}
205200

206201
fn next_block_range(
207-
max_block_range: usize,
202+
block_range: usize,
208203
data_source: &DataSource,
209204
latest_queried_block: Option<BlockNumber>,
210205
latest_block: BlockNumber,
@@ -221,7 +216,7 @@ fn next_block_range(
221216
};
222217

223218
let end_block = [
224-
start_block.saturating_add(max_block_range as BlockNumber),
219+
start_block.saturating_add(block_range as BlockNumber),
225220
data_source.source.end_block,
226221
latest_block,
227222
]

docs/amp-powered-subgraphs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ Amp-powered subgraphs feature introduces the following new ENV variables:
564564
- `GRAPH_AMP_FLIGHT_SERVICE_ADDRESS` – The address of the Amp Flight gRPC service. _Defaults to `None`, which disables support for Amp-powered subgraphs._
565565
- `GRAPH_AMP_FLIGHT_SERVICE_TOKEN` – Token used to authenticate Amp Flight gRPC service requests. _Defaults to `None`, which disables authentication._
566566
- `GRAPH_AMP_BUFFER_SIZE` – Maximum number of response batches to buffer in memory per stream for each SQL query. _Defaults to `1,000`._
567-
- `GRAPH_AMP_MAX_BLOCK_RANGE` – Maximum number of blocks to request per stream for each SQL query. _Defaults to `2,000,000`._
567+
- `GRAPH_AMP_BLOCK_RANGE` – Maximum number of blocks to request per stream for each SQL query. _Defaults to `100,000`._
568568
- `GRAPH_AMP_QUERY_RETRY_MIN_DELAY_SECONDS` – Minimum time to wait before retrying a failed SQL query to the Amp server. _Defaults to `1` second._
569569
- `GRAPH_AMP_QUERY_RETRY_MAX_DELAY_SECONDS` – Maximum time to wait before retrying a failed SQL query to the Amp server. _Defaults to `600` seconds._
570570

graph/src/env/amp.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ pub struct AmpEnv {
1212
/// Maximum number of blocks to request per stream for each SQL query.
1313
/// Limiting this value reduces load on the Amp server when processing heavy queries.
1414
///
15-
/// Defaults to `2,000,000`.
16-
pub max_block_range: usize,
15+
/// Defaults to `100,000`.
16+
pub block_range: usize,
1717

1818
/// Minimum time to wait before retrying a failed SQL query to the Amp server.
1919
///
@@ -33,7 +33,7 @@ pub struct AmpEnv {
3333

3434
impl AmpEnv {
3535
const DEFAULT_BUFFER_SIZE: usize = 1_000;
36-
const DEFAULT_MAX_BLOCK_RANGE: usize = 2_000_000;
36+
const DEFAULT_BLOCK_RANGE: usize = 100_000;
3737
const DEFAULT_QUERY_RETRY_MIN_DELAY: Duration = Duration::from_secs(1);
3838
const DEFAULT_QUERY_RETRY_MAX_DELAY: Duration = Duration::from_secs(600);
3939

@@ -48,15 +48,15 @@ impl AmpEnv {
4848
Some(value)
4949
})
5050
.unwrap_or(Self::DEFAULT_BUFFER_SIZE),
51-
max_block_range: raw_env
52-
.amp_max_block_range
51+
block_range: raw_env
52+
.amp_block_range
5353
.map(|mut value| {
5454
if value == 0 {
5555
value = usize::MAX;
5656
}
5757
value
5858
})
59-
.unwrap_or(Self::DEFAULT_MAX_BLOCK_RANGE),
59+
.unwrap_or(Self::DEFAULT_BLOCK_RANGE),
6060
query_retry_min_delay: raw_env
6161
.amp_query_retry_min_delay_seconds
6262
.map(Duration::from_secs)

graph/src/env/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,8 +610,8 @@ struct Inner {
610610

611611
#[envconfig(from = "GRAPH_AMP_BUFFER_SIZE")]
612612
amp_buffer_size: Option<usize>,
613-
#[envconfig(from = "GRAPH_AMP_MAX_BLOCK_RANGE")]
614-
amp_max_block_range: Option<usize>,
613+
#[envconfig(from = "GRAPH_AMP_BLOCK_RANGE")]
614+
amp_block_range: Option<usize>,
615615
#[envconfig(from = "GRAPH_AMP_QUERY_RETRY_MIN_DELAY_SECONDS")]
616616
amp_query_retry_min_delay_seconds: Option<u64>,
617617
#[envconfig(from = "GRAPH_AMP_QUERY_RETRY_MAX_DELAY_SECONDS")]

0 commit comments

Comments
 (0)