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: support hardlink in --import-mode #4757

Merged
merged 5 commits into from
Sep 11, 2024
Merged

Conversation

hanabi1224
Copy link
Contributor

@hanabi1224 hanabi1224 commented Sep 10, 2024

Summary of changes

As follow up of #4620

Changes introduced in this pull request:

  • add --import-mode=hardlink to hard link snapshots instead of copying them to save time and disk space
  • add --import-mode=auto as default to hard link snapshots and fallback to copying them.
  • add some info logs that print modes during snapshot import

Reference issue to close (if applicable)

Closes

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

@hanabi1224 hanabi1224 force-pushed the hm/import-mode-hardlink branch 3 times, most recently from b52ad25 to 5fefd29 Compare September 10, 2024 09:07
[network]
bootstrap_peers = ["/dns/forest-bootstrapper/tcp/$FOREST_P2P_PORT/p2p/$${PEER_ID}"]
EOF

forest --chain ${CHAIN} --encrypt-keystore false --no-gc \
--config config.toml \
--rpc-address 0.0.0.0:${FOREST_RPC_PORT} \
--import-snapshot $(ls /data/*.car.zst | tail -n 1) \
--import-mode=move
Copy link
Contributor Author

@hanabi1224 hanabi1224 Sep 10, 2024

Choose a reason for hiding this comment

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

It was previously copy & delete instead of rename (which takes 13s in https://github.com/ChainSafe/forest/actions/runs/10783688527/job/29906201147#step:5:121)

Copy link
Contributor Author

@hanabi1224 hanabi1224 Sep 11, 2024

Choose a reason for hiding this comment

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

Now hardlink works which takes 0s
https://github.com/ChainSafe/forest/actions/runs/10791399010/job/29928980199#step:5:126

  2024-09-10T11:27:58.753945Z  INFO forest_filecoin::daemon::db_util: Hardlinking /data/forest_snapshot_calibnet_2024-09-10_height_1954656.forest.car.zst to /data/forest/calibnet/0.19.2/car_db/1725967678753.forest.car.zst
  2024-09-10T11:27:58.754386Z  INFO forest_filecoin::rpc: Ready for RPC connections
  2024-09-10T11:27:58.755683Z  INFO forest_filecoin::daemon::db_util: Imported snapshot in: 0s, heaviest tipset epoch: 1954656

@hanabi1224 hanabi1224 force-pushed the hm/import-mode-hardlink branch 6 times, most recently from 9b882f4 to 00c6035 Compare September 10, 2024 09:35
@hanabi1224 hanabi1224 force-pushed the hm/import-mode-hardlink branch from 00c6035 to 3dcd5c8 Compare September 10, 2024 09:40
@hanabi1224 hanabi1224 marked this pull request as ready for review September 10, 2024 11:23
@hanabi1224 hanabi1224 requested a review from a team as a code owner September 10, 2024 11:23
@hanabi1224 hanabi1224 requested review from ruseinov and LesnyRumcajs and removed request for a team September 10, 2024 11:23
CHANGELOG.md Outdated
Comment on lines 105 to 107
- [#4757](https://github.com/ChainSafe/forest/pull/4757) Added an option to
hardlink snapshots and fallback to copying them if not applicable. This can be
invoked with `--import-snapshot <path> --import-mode=auto`.
Copy link
Member

Choose a reason for hiding this comment

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

This is a breaking change, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. (Although user experience wise this change should be transparent to users)

std::os::unix::fs::symlink(from_path, &forest_car_db_path)
.context("Error creating symlink")?;
} else {
bail!("Snapshot file must be a valid forest.car.zst file");
}
}
ImportMode::Hardlink => {
Copy link
Member

Choose a reason for hiding this comment

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

Can we add tests to different snapshot import modes in src/test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unit tests updated to cover auto and hardlink cases

Copy link
Member

Choose a reason for hiding this comment

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

Lovely! I knew I created them somewhere but couldn't find them. 🤣

@lemmih lemmih self-requested a review September 11, 2024 10:16
@lemmih lemmih added this pull request to the merge queue Sep 11, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 11, 2024
@hanabi1224 hanabi1224 added this pull request to the merge queue Sep 11, 2024
Merged via the queue into main with commit f09543d Sep 11, 2024
30 checks passed
@hanabi1224 hanabi1224 deleted the hm/import-mode-hardlink branch September 11, 2024 11:39
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