-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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(badger): add support for Badger version 4. The default remains Badger version 2 to ensure backward compatibility. #12316
base: feat/faster-datastore-with-badger
Are you sure you want to change the base?
Conversation
…otus into mikers/BadgerVersions
thanks @ZenGround0 I think this is in a good place to be merged. I don't have merge access but please use the squash option to bring this PR in as a single commit when it is merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm no Lotus veteran so apology in advance for any newbie questions or mistakes.
A few things:
User communication
- I think we need to expand the changelog entry. I put down some potential text.
- Is there a stronger way to communicate this is experimental? I'm wondering if the config key and env variable can be prefixed with "Experimental". That gives a clear signal and then also gives maintainers liberty to change config keys/semantics for when it's not experimental.
- I think it would be good to have a "Add badger v4 support" tracking issue. A first task can be adding experimental support (which this PR does) but it can also list any followup tasks we need to do to fully add Badger v4 support. It also serves as a good place to store the rationale for this work, benchmarks, etc. rather than having it embedded in PR comments.
- I think it would be good have @rjan90 review/approve, at least from the user communication/rollout perspective.
KV store improvements
- I understand the suggestion to not overload this PR - sounds good. Do we have a backlog item tracking the space improvements suggestions?
- No pressure, but is this something you're planning to do a fast-followup with?
- My understanding of @ribasushi 's point is that if we're already going to be asking users at some point to do a migration when they update to badger v4, we should bundle in other things that also require a migration (e.g., key changes). I'm wondering: how is this going to play out in time? I'm assuming the user message will be: anytime you change the value of one of these flags (LOTUS_CHAINSTORE_BADGERVERSION or LOTUS_CHAINSTORE_KEY_OPTIMIZATION) one needs to setup a new datastore. If we ever want to change the default values then we'll need to provide a migraiton path (ideally automated while keeping a backup). I just want to make sure we're thinking ahead for how we minimize user impact and account for the total work to fully complete this so we can remove old code paths. (I think this is the kind of discussion/planning that would be good in an overarching issue.)
CHANGELOG.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs expansion. Maybe badger v4 should should be its own section? Maybe something like:
Experimental Badger v4 Support
With filecoin-project/lotus#12316, users can now opt-in to using Badger v4 instead of v2 for the datastore.
Why upgrade?
- Performance improvement - Initial benchmarks showed 40% faster time to import a snapshot. (I'm making stuff up here...) I/O and CPU utiliation anecdotally reduced by 10% on the same workload (link to Grafana).
- Active development - Badger v2 was released ~4 years ago, but v4 is where all the active development is by the community to improve disk read/write times and memory efficiency.
How to upgrade?
The v2 and v4 datastores are incompatible. Badger directories are directories, it's advised to first copy your v2 datastore. Then enable v4 with LOTUS_CHAINSTORE_BADGERVERSION=4
. Download a recent mainnet snapshot (link to snapshot directory) to import using lotus command
.
If you run into any problems please report them by opening an issue and you can also rollback with LOTUS_CHAINSTORE_BADGERVERSION=2
and copying back v2 directory.
# versions can only be done when the blockstore is empty and will be repopulated from a snapshot | ||
# or chain sync. It cannot be upgraded or downgraded with existing data and there is currently | ||
# no automatic migration tooling. | ||
# This is an experimental feature and should not be used in production. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to link to the tracking issue where someone can go for finding updates on what is remaining for moving this out of experimental.
@BigLep Thank you for your feedback and suggestions! I appreciate your guidance as I navigate these areas—I'm still learning, so your input is invaluable. User Communication
But I’m always open to refining this if needed!
KV Store Improvements
|
I'm also concerned about the key efficiency improvements coming on top of this as a separate PR after this is merged. It puts two separate hard-breaking changes in master. If we're doing both then we should do them both pretty closely together, and ideally at the same time. At a minimum I'd like this not to go into a release without the key efficiency improvements also going with it. Unless we come to an agreement that we're not going to try and achieve that any time soon. Reading sentiment and adding my own to it suggests we would like to get it done asap since we have this opportunity with the breakage here. I agree that tying that functionality to this PR makes it too large and less focused, and it's unfair to lump that burden on @snissn here, but maybe this is a case for a feature branch where we can review and land multiple pieces before they make it into master and accidentally into separate releases. |
Thanks @snissn . Responding to a few things: User Communication
By the time we get to doing a release, certain newly-added features have text added in. https://github.com/filecoin-project/lotus/blob/master/CHANGELOG.md#v1281--2024-07-24 is an example with F3. I accept that F3 is bigger than a Badger update, but we want to avoid having to do documentation editorializing in the crunch of trying to get a release out. I think it's something that needs to be thought about and done as part of the code writing process.
I agree that the config.toml docs have good disclaimers, but someone doesn't see that when they use environment variables and it also doesn't a clear signal that things may change before we make it non-experimental. If we get this into the name ( (I realize this is a larger discussion about how experimental features are handled in general in Lotus. I don't know the history here, and so this is something that would be good to have Lotus maintainers chime in on. My bias is coming from what I saw be clear for users in projects like Kubo (example).)
I don't think we need/should wait for some on Badger v4’s performance and reliability. This is a big change, and thus ideally I think this PR should have been opened with an issue explaining the work and providing a central place to capture decision points, findings, next steps, etc. KV Store ImprovementsIt sounds like maintainers need to:
If there are Lotus maintainers at the 2024-08-14 maintainer call today, I'll see if I can get answers or input on any of the above and ensure there is clarity on the next steps for landing this PR (and where to land it to). |
Below are some notes I took from Lotus maintainer conversation on 2024-08-14. Others can fill in if I'm misrepresenting:
Thanks again @snissn . |
Re feature branch and how to proceed, here's some additional thoughts on how we can be productive with that:
|
* Update go-f3 to 0.2.0 Includes: - fix for excessive bandwidth usage - significant performance improvements - minor consensus fixes Signed-off-by: Jakub Sztandera <[email protected]> * add changelog Signed-off-by: Jakub Sztandera <[email protected]> * chore(f3): update to final released version --------- Signed-off-by: Jakub Sztandera <[email protected]> Co-authored-by: Steven Allen <[email protected]>
@BigLep @rvagg glad to see you guys thinking about integration wholistically and seriously. However I think we are overthinking it. A very standard development usage of lotus is 1) sync from snapshot 2) run for a while 3) lose sync tear down go back to 1. And SPs are good at spinning lotus up and down. We're really overestimating the utility of database migration from my pov. I think it would be a waste of work to write a migration personally. I don't think we need to block on making v4 even better, this is an experimental feature, why can't we just break v4 badger support in the future by making breaking improvements? The feature is clearly marked experimental. This feature is totally independent of the default so if someone wants to try v4 badger why stop them? I don't think we need to do so much work quantifying this experimental feature until we commit to working on it ourselves. It makes sense to do this investigation before we commit to working on this. We're going to get organic feedback from people in the network only if we make the change available. What about saying "if this causes more than 2 unhappy user reports we revert this" to limit maintenance overhead? And hey maybe I'm underthinking it. To me it just feels like we're indefinitely stopping merging a complete-enough open source contribution without great reason. |
A little added context, @snissn is trying to get more performance testing information from RPC providers and getting an experimental feature on master makes the process of convincing them to test a lot easier. |
Great discussion above. It seems we all agree early user feedback is needed. Can we merge this as an experimental feature so we can start getting early user feedback? We can decide on migration as needed after that early feedback comes in. Concretely, Ankr and Protofire seemed keen to try this when we last spoke a month ago and Mike can share this with them once merged |
Thanks all for the comments here. Some thoughts below synthesized from conversations I've had more recently (meaning I can stand behind anything written here but any utility was likely due to others): It seems like the target user here we're hoping to benefit here is RPC providers. A couple of things on this:
Maintainers are aware of other ways to improve RPC provider experience as well beyond this badger update, including things like:
It is encouraging to see people pick up the torch on the blockstore problem. The concern is that we're poking at the edges which still consumes non-trivial time and bandwidth for marginal improvements to something that’s just structurally bad. The worry is that minor incremental fixes will increase the permutations of how people run lotus, which will make maintainer work harder in the long run. For example, "are you running badger 2 or 4? are you running the version with fsync defaulting to off or have you set it to on? is mmap enabled on your node? do you have eth API enabled? are you running with historical events? are you saving messages to the blockstore? what’s your splitstore mode?” If doing any combination of things can be shown to make a meaningful difference to the life of node operators, then that would be great news and would give weight to schedule more time to take a proper look at this and think holistically on integrating it back into master/main in a non-experimental way. Without better info, there isn't maintainer conviction to see this moving the needle enough on the “lotus sucks” meter, or adjusting the “filecoin is a hard chain to run” sentiment, or dispelling the “forest can do the same work with a fraction of the resources” meme. In knowing that having a holistic strategy to dealing with the blockstore problem is likely what's needed but that there's no one committed in 2024Q3 to make that happen, I still think the dedicated feature branch path is a good compromise. I think the couple of RPC providers like Ankr and Protofire who are keen to experiment should be able. Hopefully we can get some good news from those experiments to help inform priorities later on in the year? Does that work @snissn and keep you sufficiently unblocked? |
…lease) (#12400) * fix: lotus-miner: remove provecommit1 method (#12251) * remove provecommit1 * add changelog * update precommit and commit params * fix lint error * fix commit params * dep: f3: Update go-f3 to 0.0.6, enable it on mainnet (#12295) * Update go-f3 to 0.0.6 Signed-off-by: Jakub Sztandera <[email protected]> * Enable F3 in passive configuration in mainnet config Signed-off-by: Jakub Sztandera <[email protected]> * Add changelog Signed-off-by: Jakub Sztandera <[email protected]> * add new butterfly assets --------- Signed-off-by: Jakub Sztandera <[email protected]> Co-authored-by: Jennifer Wang <[email protected]> * retract v1.28.0 * update v1.28.0 changelog and add v1.28.1 * Update CHANGELOG.md * wip - update f3 * don't convert bigint type We now use the same one in GPBFT. * update docs * fix wrong param name * update butterfy assets * update go-f3 * update changelog * update version * fix typo * Update CHANGELOG.md Co-authored-by: Steven Allen <[email protected]> * Update CHANGELOG.md Co-authored-by: Rod Vagg <[email protected]> * Update CHANGELOG.md Co-authored-by: Rod Vagg <[email protected]> * apply f3 patch * chore: bump versions and make gen/docsgen-cli chore: bump versions and make gen/docsgen-cli * chore: update v1.28.2 changelog chore: update v1.282. changelog * feat: f3: update go-f3 to 0.2.0 (#12390) * Update go-f3 to 0.2.0 Includes: - fix for excessive bandwidth usage - significant performance improvements - minor consensus fixes Signed-off-by: Jakub Sztandera <[email protected]> * add changelog Signed-off-by: Jakub Sztandera <[email protected]> * chore(f3): update to final released version --------- Signed-off-by: Jakub Sztandera <[email protected]> Co-authored-by: Steven Allen <[email protected]> * fix!: sealer: handle initialisation error without panic storage/pipeline.NewPreCommitBatcher and storage/pipeline.New now have an additional error return to deal with errors arising from fetching the sealing config. * add breaking API upgrade warning to the ChangeLog * NewCommitBatcher now has an additional error return to deal with errors arising from fetching the sealing config. * fix: miner: Fix DDO pledge math (#12341) * Power is units of Space * Time so multiply by deal duration * fix: miner: Fix DDO pledge math * appease the changelog checker * Fix gen --------- Co-authored-by: zenground0 <[email protected]> * chore: fix lint error - Updated the logging statement in `testOutOfGasError` to correctly reference `build.BlockGasLimit` instead of `buildconstants.BlockGasLimit`. * fix: update changelog to reference bandwidth issue ticket fix: update changelog to reference bandwidth issue ticket * Update CHANGELOG.md Co-authored-by: Steve Loeppky <[email protected]> * Update CHANGELOG.md * chore: make gen and make docsgen-cli Run `make gen` and `make docsgen-cli` --------- Signed-off-by: Jakub Sztandera <[email protected]> Co-authored-by: LexLuthr <[email protected]> Co-authored-by: Jakub Sztandera <[email protected]> Co-authored-by: Jennifer Wang <[email protected]> Co-authored-by: Jiaying Wang <[email protected]> Co-authored-by: Steven Allen <[email protected]> Co-authored-by: Rod Vagg <[email protected]> Co-authored-by: aarshkshah1992 <[email protected]> Co-authored-by: Łukasz Magiera <[email protected]> Co-authored-by: zenground0 <[email protected]> Co-authored-by: Steve Loeppky <[email protected]>
This exposes bandwidth metrics via async callback to avoid allocating/reporting metrics on any hot-paths. I'm using open telemetry as we've already setup a bridge for F3 and opencensus is deprecated in favor of open telemetry (so we're going to slowly move over anyways).
Hi - I have updated the PR to target I hope that helps!! |
* chore: update Node version chore: update Node version * chore: cleanup unreleased changelog section chore: cleanup unreleased changelog section
Circling back to next steps now that I'm back... My understanding is that @snissn is doing this work currently as an extra/side project outside of the context of a particular team's priorities and would like to get feedback of how this change performs in a production setting. It's to this end that the idea of a feature branch was suggested (and has been created). Regardless of the branch though, the more pertinent question is how the branch stays updated. Given Lotus maintainers aren't focused on this more holistic blockstore effort currently (comment above), Lotus maintainers will leave it up to those interested in experimenting here to keep up with (In retrospect it may have been better not to do this as a "feature branch" as that maybe gives the impression that this feature is more official than it is currently. But I guess having a feature branch enables actually merging this PR vs. leaving it open indefinitely. 🤷) Whether in a
@rvagg: if you're good with the above, can you please take on merging? |
Following up here:
|
* docs: updates about branches and where to target PRs CONTRIBUTING.md: calling out the release flow doc earlier and more of why a contributor should read it. LOTUS_RELEASE_FLOW: being more precise and organized about branch strategy. RELEASE_ISSUE_TEMPLATE: added comment on what we expect to see when backporting from release branch to master. * Update LOTUS_RELEASE_FLOW.md Co-authored-by: Rod Vagg <[email protected]> * Update LOTUS_RELEASE_FLOW.md Co-authored-by: Rod Vagg <[email protected]> * Incorporating review feedback. Stripped colors and made clear that we're cherry picking. * Removed one more color reference --------- Co-authored-by: Rod Vagg <[email protected]>
Next steps per 2024-08-28 sync between FilOz and Fil-B teams:
Additional notes:
|
Performance improvement
12m16.290s
vs19m51.546s
to import chainRelated Issues
Proposed Changes
Additional Info
Checklist
Before you mark the PR ready for review, please make sure that:
<PR type>: <area>: <change being made>
fix: mempool: Introduce a cache for valid signatures
PR type
: fix, feat, build, chore, ci, docs, perf, refactor, revert, style, testarea
, e.g. api, chain, state, mempool, multisig, networking, paych, proving, sealing, wallet, deps[skip changelog]
to the PR titleskip/changelog
to the PRTODO at the moment:
DefaultOptions()