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

[Indexer-Grpc-V2] Add FileStoreUploader. #15724

Merged
merged 1 commit into from
Jan 23, 2025
Merged

[Indexer-Grpc-V2] Add FileStoreUploader. #15724

merged 1 commit into from
Jan 23, 2025

Conversation

grao1991
Copy link
Contributor

@grao1991 grao1991 commented Jan 14, 2025

Description

How Has This Been Tested?

Key Areas to Review

Type of Change

  • New feature
  • Bug fix
  • Breaking change
  • Performance improvement
  • Refactoring
  • Dependency update
  • Documentation update
  • Tests

Which Components or Systems Does This Change Impact?

  • Validator Node
  • Full Node (API, Indexer, etc.)
  • Move/Aptos Virtual Machine
  • Aptos Framework
  • Aptos CLI/SDK
  • Developer Infrastructure
  • Move Compiler
  • Other (specify)

Checklist

  • I have read and followed the CONTRIBUTING doc
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I identified and added all stakeholders and component owners affected by this change as reviewers
  • I tested both happy and unhappy path of the functionality
  • I have made corresponding changes to the documentation

Copy link

trunk-io bot commented Jan 14, 2025

⏱️ 11m total CI duration on this PR
Job Cumulative Duration Recent Runs
check-dynamic-deps 5m 🟩🟩
rust-cargo-deny 3m 🟩🟩
general-lints 56s 🟩🟩
semgrep/ci 43s 🟩🟩
file_change_determinator 20s 🟩🟩
permission-check 8s 🟩🟩
permission-check 4s 🟩🟩
check-branch-prefix 1s 🟩

settingsfeedbackdocs ⋅ learn more about trunk.io

Comment on lines +106 to +151
pub(crate) async fn start(&mut self, data_manager: Arc<DataManager>) -> Result<()> {
let (version, batch_metadata) = self.recover().await?;

let mut file_store_operator = FileStoreOperatorV2::new(
MAX_SIZE_PER_FILE,
NUM_TXNS_PER_FOLDER,
version,
batch_metadata,
)
.await;
tokio_scoped::scope(|s| {
let (tx, mut rx) = channel(5);
s.spawn(async move {
while let Some((transactions, batch_metadata, end_batch)) = rx.recv().await {
self.do_upload(transactions, batch_metadata, end_batch)
.await
.unwrap();
}
});
s.spawn(async move {
loop {
let transactions = data_manager
.get_transactions_from_cache(
file_store_operator.version(),
MAX_SIZE_PER_FILE,
/*update_file_store_version=*/ true,
)
.await;
let len = transactions.len();
for transaction in transactions {
file_store_operator
.buffer_and_maybe_dump_transactions_to_file(transaction, tx.clone())
.await
.unwrap();
}
if len == 0 {
tokio::time::sleep(Duration::from_millis(100)).await;
}
}
});
});

Ok(())
}
Copy link

Choose a reason for hiding this comment

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

The start() method spawns infinite tasks within tokio_scoped::scope but returns immediately, which causes the tasks to be terminated prematurely. Since these tasks need to run continuously, they should either:

  1. Use tokio::spawn instead of scoped tasks, or
  2. Have the method wait for a shutdown signal before returning

This will ensure the background processing continues running as intended rather than being cleaned up when the scope exits.

Spotted by Graphite Reviewer

Is this helpful? React 👍 or 👎 to let us know.

@grao1991 grao1991 force-pushed the grao_file_store branch 6 times, most recently from 302d973 to d9eb878 Compare January 22, 2025 09:01
@grao1991 grao1991 changed the title [Indexer-Grpc-V2] FileStoreUploader. [Indexer-Grpc-V2] Add FileStoreUploader. Jan 22, 2025
@grao1991 grao1991 marked this pull request as ready for review January 22, 2025 09:02
@grao1991 grao1991 enabled auto-merge (squash) January 22, 2025 09:02

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

})
}

async fn recover(&self) -> Result<(u64, BatchMetadata)> {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: add some comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

.await;
}

if update_batch_metadata {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: write in the other way and flatten the nested logic.

if !update_batch_metadata {
// no update can be performed.
return Ok(()):
}

// the rest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

batch_metadata,
)
.await;
tokio_scoped::scope(|s| {
Copy link
Contributor

Choose a reason for hiding this comment

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

it looks like tokio_scoped is no longer maintained; maybe async_scoped?

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

✅ Forge suite compat success on 9e7cf4a27cc20504cee5ffefc35bd8e7792dde36 ==> beb5cd842196c30f37adafdb8306607fd89cd76a

Compatibility test results for 9e7cf4a27cc20504cee5ffefc35bd8e7792dde36 ==> beb5cd842196c30f37adafdb8306607fd89cd76a (PR)
1. Check liveness of validators at old version: 9e7cf4a27cc20504cee5ffefc35bd8e7792dde36
compatibility::simple-validator-upgrade::liveness-check : committed: 12164.72 txn/s, latency: 2583.00 ms, (p50: 2600 ms, p70: 2700, p90: 3200 ms, p99: 4700 ms), latency samples: 396700
2. Upgrading first Validator to new version: beb5cd842196c30f37adafdb8306607fd89cd76a
compatibility::simple-validator-upgrade::single-validator-upgrading : committed: 2952.28 txn/s, latency: 8984.55 ms, (p50: 9300 ms, p70: 10600, p90: 12200 ms, p99: 13600 ms), latency samples: 66400
compatibility::simple-validator-upgrade::single-validator-upgrade : committed: 2967.01 txn/s, latency: 11189.31 ms, (p50: 12200 ms, p70: 12700, p90: 13400 ms, p99: 13700 ms), latency samples: 115220
3. Upgrading rest of first batch to new version: beb5cd842196c30f37adafdb8306607fd89cd76a
compatibility::simple-validator-upgrade::half-validator-upgrading : committed: 4391.77 txn/s, latency: 7069.86 ms, (p50: 7900 ms, p70: 8500, p90: 8700 ms, p99: 8900 ms), latency samples: 93580
compatibility::simple-validator-upgrade::half-validator-upgrade : committed: 4376.49 txn/s, latency: 7744.29 ms, (p50: 8800 ms, p70: 8900, p90: 9100 ms, p99: 9300 ms), latency samples: 153960
4. upgrading second batch to new version: beb5cd842196c30f37adafdb8306607fd89cd76a
compatibility::simple-validator-upgrade::rest-validator-upgrading : committed: 8053.43 txn/s, latency: 3743.20 ms, (p50: 4100 ms, p70: 4500, p90: 4500 ms, p99: 4700 ms), latency samples: 148000
compatibility::simple-validator-upgrade::rest-validator-upgrade : committed: 7928.23 txn/s, latency: 4235.46 ms, (p50: 4600 ms, p70: 4600, p90: 4700 ms, p99: 4800 ms), latency samples: 270760
5. check swarm health
Compatibility test for 9e7cf4a27cc20504cee5ffefc35bd8e7792dde36 ==> beb5cd842196c30f37adafdb8306607fd89cd76a passed
Test Ok

Copy link
Contributor

✅ Forge suite realistic_env_max_load success on beb5cd842196c30f37adafdb8306607fd89cd76a

two traffics test: inner traffic : committed: 14798.41 txn/s, latency: 2679.89 ms, (p50: 2700 ms, p70: 2700, p90: 3000 ms, p99: 3700 ms), latency samples: 5626660
two traffics test : committed: 99.97 txn/s, latency: 1642.63 ms, (p50: 1400 ms, p70: 1500, p90: 2300 ms, p99: 3400 ms), latency samples: 1700
Latency breakdown for phase 0: ["MempoolToBlockCreation: max: 1.420, avg: 1.326", "ConsensusProposalToOrdered: max: 0.291, avg: 0.288", "ConsensusOrderedToCommit: max: 0.409, avg: 0.399", "ConsensusProposalToCommit: max: 0.699, avg: 0.687"]
Max non-epoch-change gap was: 0 rounds at version 0 (avg 0.00) [limit 4], 0.56s no progress at version 1260 (avg 0.19s) [limit 15].
Max epoch-change gap was: 0 rounds at version 0 (avg 0.00) [limit 4], 0.63s no progress at version 5405164 (avg 0.62s) [limit 16].
Test Ok

@grao1991 grao1991 merged commit 3ddcf7f into main Jan 23, 2025
46 checks passed
@grao1991 grao1991 deleted the grao_file_store branch January 23, 2025 20:03
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.

3 participants