Skip to content

Commit 017671c

Browse files
committed
all: Rename 'copy_threshold' to 'rebuild_threshold'
1 parent 2096d90 commit 017671c

File tree

6 files changed

+43
-42
lines changed

6 files changed

+43
-42
lines changed

docs/environment-variables.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,14 @@ those.
227227
1.1 means that the subgraph will be pruned every time it contains 10%
228228
more history (in blocks) than its history limit. The default value is 1.2
229229
and the value must be at least 1.01
230-
- `GRAPH_STORE_HISTORY_COPY_THRESHOLD`,
231-
`GRAPH_STORE_HISTORY_DELETE_THRESHOLD`: when pruning, prune by copying the
232-
entities we will keep to new tables if we estimate that we will remove
233-
more than a factor of `COPY_THRESHOLD` of the deployment's history. If we
234-
estimate to remove a factor between `COPY_THRESHOLD` and
235-
`DELETE_THRESHOLD`, prune by deleting from the existing tables of the
230+
- `GRAPH_STORE_HISTORY_REBUILD_THRESHOLD`,
231+
`GRAPH_STORE_HISTORY_DELETE_THRESHOLD`: when pruning, prune by copying
232+
the entities we will keep to new tables if we estimate that we will
233+
remove more than a factor of `REBUILD_THRESHOLD` of the deployment's
234+
history. If we estimate to remove a factor between `REBUILD_THRESHOLD`
235+
and `DELETE_THRESHOLD`, prune by deleting from the existing tables of the
236236
deployment. If we estimate to remove less than `DELETE_THRESHOLD`
237237
entities, do not change the table. Both settings are floats, and default
238-
to 0.5 for the `COPY_THRESHOLD` and 0.05 for the `DELETE_THRESHOLD`; they
239-
must be between 0 and 1, and `COPY_THRESHOLD` must be bigger than
238+
to 0.5 for the `REBUILD_THRESHOLD` and 0.05 for the `DELETE_THRESHOLD`;
239+
they must be between 0 and 1, and `REBUILD_THRESHOLD` must be bigger than
240240
`DELETE_THRESHOLD`.

graph/src/components/store/mod.rs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,12 +1270,12 @@ pub struct PruneRequest {
12701270
pub final_block: BlockNumber,
12711271
/// The latest block, i.e., the subgraph head
12721272
pub latest_block: BlockNumber,
1273-
/// Use the copy strategy when removing more than this fraction of
1274-
/// history. Initialized from `ENV_VARS.store.copy_threshold`, but can
1275-
/// be modified after construction
1276-
pub copy_threshold: f64,
1273+
/// Use the rebuild strategy when removing more than this fraction of
1274+
/// history. Initialized from `ENV_VARS.store.rebuild_threshold`, but
1275+
/// can be modified after construction
1276+
pub rebuild_threshold: f64,
12771277
/// Use the delete strategy when removing more than this fraction of
1278-
/// history but less than `copy_threshold`. Initialized from
1278+
/// history but less than `rebuild_threshold`. Initialized from
12791279
/// `ENV_VARS.store.delete_threshold`, but can be modified after
12801280
/// construction
12811281
pub delete_threshold: f64,
@@ -1293,11 +1293,11 @@ impl PruneRequest {
12931293
first_block: BlockNumber,
12941294
latest_block: BlockNumber,
12951295
) -> Result<Self, StoreError> {
1296-
let copy_threshold = ENV_VARS.store.copy_threshold;
1296+
let rebuild_threshold = ENV_VARS.store.rebuild_threshold;
12971297
let delete_threshold = ENV_VARS.store.delete_threshold;
1298-
if copy_threshold < 0.0 || copy_threshold > 1.0 {
1298+
if rebuild_threshold < 0.0 || rebuild_threshold > 1.0 {
12991299
return Err(constraint_violation!(
1300-
"the copy threshold must be between 0 and 1 but is {copy_threshold}"
1300+
"the copy threshold must be between 0 and 1 but is {rebuild_threshold}"
13011301
));
13021302
}
13031303
if delete_threshold < 0.0 || delete_threshold > 1.0 {
@@ -1331,19 +1331,20 @@ impl PruneRequest {
13311331
earliest_block,
13321332
final_block,
13331333
latest_block,
1334-
copy_threshold,
1334+
rebuild_threshold,
13351335
delete_threshold,
13361336
})
13371337
}
13381338

13391339
/// Determine what strategy to use for pruning
13401340
///
1341-
/// We are pruning `history_pct` of the blocks from a table that has a ratio
1342-
/// of `version_ratio` entities to versions. If we are removing more than
1343-
/// `copy_threshold` percent of the versions, we prune by copying, and if we
1344-
/// are removing more than `delete_threshold` percent of the versions, we
1345-
/// prune by deleting. If we would remove less than `delete_threshold`
1346-
/// percent of the versions, we don't prune.
1341+
/// We are pruning `history_pct` of the blocks from a table that has a
1342+
/// ratio of `version_ratio` entities to versions. If we are removing
1343+
/// more than `rebuild_threshold` percent of the versions, we prune by
1344+
/// rebuilding, and if we are removing more than `delete_threshold`
1345+
/// percent of the versions, we prune by deleting. If we would remove
1346+
/// less than `delete_threshold` percent of the versions, we don't
1347+
/// prune.
13471348
pub fn strategy(&self, stats: &VersionStats) -> Option<PruningStrategy> {
13481349
// If the deployment doesn't have enough history to cover the reorg
13491350
// threshold, do not prune
@@ -1356,7 +1357,7 @@ impl PruneRequest {
13561357
// that `history_pct` will tell us how much of that data pruning
13571358
// will remove.
13581359
let removal_ratio = self.history_pct(stats) * (1.0 - stats.ratio);
1359-
if removal_ratio >= self.copy_threshold {
1360+
if removal_ratio >= self.rebuild_threshold {
13601361
Some(PruningStrategy::Rebuild)
13611362
} else if removal_ratio >= self.delete_threshold {
13621363
Some(PruningStrategy::Delete)

graph/src/env/store.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ pub struct EnvVarsStore {
8585
pub batch_target_duration: Duration,
8686

8787
/// Prune tables where we will remove at least this fraction of entity
88-
/// versions by copying. Set by `GRAPH_STORE_HISTORY_COPY_THRESHOLD`.
89-
/// The default is 0.5
90-
pub copy_threshold: f64,
88+
/// versions by rebuilding the table. Set by
89+
/// `GRAPH_STORE_HISTORY_REBUILD_THRESHOLD`. The default is 0.5
90+
pub rebuild_threshold: f64,
9191
/// Prune tables where we will remove at least this fraction of entity
92-
/// versions, but fewer than `copy_threshold`, by deleting. Set by
92+
/// versions, but fewer than `rebuild_threshold`, by deleting. Set by
9393
/// `GRAPH_STORE_HISTORY_DELETE_THRESHOLD`. The default is 0.05
9494
pub delete_threshold: f64,
9595
/// How much history a subgraph with limited history can accumulate
@@ -134,7 +134,7 @@ impl From<InnerStore> for EnvVarsStore {
134134
connection_idle_timeout: Duration::from_secs(x.connection_idle_timeout_in_secs),
135135
write_queue_size: x.write_queue_size,
136136
batch_target_duration: Duration::from_secs(x.batch_target_duration_in_secs),
137-
copy_threshold: x.copy_threshold.0,
137+
rebuild_threshold: x.rebuild_threshold.0,
138138
delete_threshold: x.delete_threshold.0,
139139
history_slack_factor: x.history_slack_factor.0,
140140
}
@@ -180,8 +180,8 @@ pub struct InnerStore {
180180
write_queue_size: usize,
181181
#[envconfig(from = "GRAPH_STORE_BATCH_TARGET_DURATION", default = "180")]
182182
batch_target_duration_in_secs: u64,
183-
#[envconfig(from = "GRAPH_STORE_HISTORY_COPY_THRESHOLD", default = "0.5")]
184-
copy_threshold: ZeroToOneF64,
183+
#[envconfig(from = "GRAPH_STORE_HISTORY_REBUILD_THRESHOLD", default = "0.5")]
184+
rebuild_threshold: ZeroToOneF64,
185185
#[envconfig(from = "GRAPH_STORE_HISTORY_DELETE_THRESHOLD", default = "0.05")]
186186
delete_threshold: ZeroToOneF64,
187187
#[envconfig(from = "GRAPH_STORE_HISTORY_SLACK_FACTOR", default = "1.2")]

node/src/bin/manager.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,12 +253,12 @@ pub enum Command {
253253
Prune {
254254
/// The deployment to prune (see `help info`)
255255
deployment: DeploymentSearch,
256-
/// Prune by copying when removing more than this fraction of
257-
/// history. Defaults to GRAPH_STORE_HISTORY_COPY_THRESHOLD
256+
/// Prune by rebuilding tables when removing more than this fraction
257+
/// of history. Defaults to GRAPH_STORE_HISTORY_REBUILD_THRESHOLD
258258
#[clap(long, short)]
259-
copy_threshold: Option<f64>,
259+
rebuild_threshold: Option<f64>,
260260
/// Prune by deleting when removing more than this fraction of
261-
/// history but less than copy_threshold. Defaults to
261+
/// history but less than rebuild_threshold. Defaults to
262262
/// GRAPH_STORE_HISTORY_DELETE_THRESHOLD
263263
#[clap(long, short)]
264264
delete_threshold: Option<f64>,
@@ -1390,7 +1390,7 @@ async fn main() -> anyhow::Result<()> {
13901390
Prune {
13911391
deployment,
13921392
history,
1393-
copy_threshold,
1393+
rebuild_threshold,
13941394
delete_threshold,
13951395
once,
13961396
} => {
@@ -1400,7 +1400,7 @@ async fn main() -> anyhow::Result<()> {
14001400
primary_pool,
14011401
deployment,
14021402
history,
1403-
copy_threshold,
1403+
rebuild_threshold,
14041404
delete_threshold,
14051405
once,
14061406
)

node/src/manager/commands/prune.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ pub async fn run(
161161
primary_pool: ConnectionPool,
162162
search: DeploymentSearch,
163163
history: usize,
164-
copy_threshold: Option<f64>,
164+
rebuild_threshold: Option<f64>,
165165
delete_threshold: Option<f64>,
166166
once: bool,
167167
) -> Result<(), anyhow::Error> {
@@ -198,8 +198,8 @@ pub async fn run(
198198
status.earliest_block_number,
199199
latest,
200200
)?;
201-
if let Some(copy_threshold) = copy_threshold {
202-
req.copy_threshold = copy_threshold;
201+
if let Some(rebuild_threshold) = rebuild_threshold {
202+
req.rebuild_threshold = rebuild_threshold;
203203
}
204204
if let Some(delete_threshold) = delete_threshold {
205205
req.delete_threshold = delete_threshold;

store/postgres/tests/graft.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,11 +613,11 @@ fn prune() {
613613
// Change the thresholds so that we select the desired strategy
614614
match strategy {
615615
PruningStrategy::Rebuild => {
616-
req.copy_threshold = 0.0;
616+
req.rebuild_threshold = 0.0;
617617
req.delete_threshold = 0.0;
618618
}
619619
PruningStrategy::Delete => {
620-
req.copy_threshold = 1.0;
620+
req.rebuild_threshold = 1.0;
621621
req.delete_threshold = 0.0;
622622
}
623623
}

0 commit comments

Comments
 (0)