-
Notifications
You must be signed in to change notification settings - Fork 310
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
ci: move to Nix (simpler, easy to maintain version) #1320
base: master
Are you sure you want to change the base?
Conversation
ab132c9
to
d139091
Compare
Why not increase bitcoind's rpc threads and work queue from the potato-like defaults instead? |
So just the dev shells, no crane etc.? Seems reasonable. Dev shells are like 80% of benefits for very little Nix involvment. |
d139091
to
710919e
Compare
Good call I did this in a1997cf bitcoind_conf.args.push("-rpcworkqueue=1024");
bitcoind_conf.args.push("-rpcthreads=64"); |
a1997cf
to
a5cce86
Compare
64 threads is way too much. I think the ideal is to have 1 thread per CPU core. I think a good compromise is 4 (between desktop and CI). |
a5cce86
to
f141cd1
Compare
4 is the default. So no change then? I can easily delete a1997cf (that's why I did it in a separate commit 😄) |
Its a io bound workload. Absent async capabilities default 4 is laughable even for one core and I don't even know why bitcoind is doing it. |
I didn't realize it was io-bounded. However, in our test environment, I doubt there will be 64 concurrent calls. How about we meet in the middle and say 16? |
I was on my phone before, so let me elaborate.
From a perspective of most workloads e.g. asking for blockchain data, Even for that heavy model, the recommendations will be to limit it around around 500. It takes many threads to saturate modern IO device. Just an example from a yt video I had on hand benchamarking filesystems. Each bar is number of workers. And these are dedicated IO-generating workers, generating heavy load in a tight loop. So in this benchmark, it will take like 4 workers. Possibly one worker is even more threads. But an rpc thread in bitcoind by necessity will be spending lots of time reading things and writing stuff to a tcp connection, doing some checks, re-encodings and what not. To actually get a maximum IO performance there will need to be a lot of them. I'd say 64 per core. On my mostly idle laptop at this very moment there are 2k threads running: On a modern Linux a thread is just a stack, which due to CoW optimizations will really amount to 1 or 2 pages (4K page size) of physically used memory plus a tiny (1K?) amount to track it all in the kernel. There's really not much to save on thread counts in a grand scheme of things. Personally, I like to run as lots and lots of tests in parallel, especially any sort of integration and e2e tests, which tend to have lots of dead time - waiting for stuff (like disk and network IO - latency-bound things). The usual limit to this is the available memory. Additional benefit is also that it tends to expose problems more often, as all operations tend to have more ... timing jitter. So I'm really surprised that the default in |
f141cd1
to
0ceb17a
Compare
Can you have it print at the beginning, "First time takes a good long while..." or something like that. Some parts seem so slow that you'd think the shell crashed or something like that. Would be good for the user to know this. Also I am having 8 tests fail, is that just me?
|
This comment was marked as resolved.
This comment was marked as resolved.
0ceb17a
to
dd1754c
Compare
Also, if you are using single bitcoind instance for all tests, you might want to increase the queue size and rpc thread count on it. Otherwise bitcoind randomly rejects connections, even when there isn't all that many of them yet. Though to that I'd add that the production code should probably do some retries as well. Anyway, I'm guessing. Unfortunately non trivial tests that involve lots of different software pieces etc. often require some debugging and refactoring/tweaking to work reliably. |
8bf8c7d chore: fix clippy lints (Jose Storopoli) Pull request description: ### Description Fix some clippy CI lints ### Notes to the reviewers More caught by the Nix CI in bitcoindevkit#1320. ### Changelog notice chore: clippy lints ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing #### New Features: * [ ] I've added tests for the new feature * [ ] I've added docs for the new feature #### Bugfixes: * [ ] This pull request breaks the existing API * [ ] I've added tests to reproduce the issue which are now passing * [ ] I'm linking the issue being fixed by this PR ACKs for top commit: notmandatory: ACK 8bf8c7d Tree-SHA512: 6b53cb739e506d79106a2f42aa2b8fa28ef226543fbbf100225f10ed82257f6fd0218f09c0f1291803fbc9c1c88e32ba1c7e02fe3f601ccc9dc5be8a6efea6e1
I tested with
I did a little bit of it and further testing, the main problem occurs in the It's really weird, because I checked it and it's running the bitcoind on different ports, datadirs, and such 🤔. I think we should give it a try. |
FWIW, I'm not sure if I did something wrong, but it still didn't solve the issue 🤔 |
b1ca648
to
f4f3fd3
Compare
f4f3fd3
to
5f41abf
Compare
5f41abf
to
3507055
Compare
bc83e41 fix: typos (Jose Storopoli) Pull request description: <!-- You can erase any parts of this template not applicable to your Pull Request. --> ### Description more typos caught up during rebasing of #1320. ### Notes to the reviewers ### Changelog notice <!-- Notice the release manager should include in the release tag message changelog --> <!-- See https://keepachangelog.com/en/1.0.0/ for examples --> ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing #### New Features: * [ ] I've added tests for the new feature * [ ] I've added docs for the new feature #### Bugfixes: * [ ] This pull request breaks the existing API * [ ] I've added tests to reproduce the issue which are now passing * [ ] I'm linking the issue being fixed by this PR ACKs for top commit: LagginTimes: ACK bc83e41 oleonardolima: ACK bc83e41 thunderbiscuit: ACK bc83e41. Tree-SHA512: 1dc76d64ddb0273c60899a6617dcbc63fab75057447080260b7050bb5d178ef56c6f79f2c7f1ca5b7b4eb09e2b1e67d782be91598ab58e6a3b3179d6b5edf5c5
3507055
to
8c8c1e4
Compare
rebased to |
I stole this for cdk just fyi been working well. https://github.com/cashubtc/cdk/blob/main/flake.nix |
8c8c1e4
to
9d56e82
Compare
rebased |
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.
Overall this looks like a great use of Nix to setup a local dev env use the pre-checks to prevent common commit problems.
I would like to figure out the macos test threads issue, but that can be done in a follow-up PR. I also have a few other comments below.
Thanks all the hard work getting this to work.
9d56e82
to
0267841
Compare
My pleasure. Ok the trick that @thesimplekid has that does not need a PS: Since we are changing the GitHub CI workflow names, we might need to update the branch protection rules for |
bf151a9
to
f2e839c
Compare
I just ran into an error with the pre-push hook that it didn't think 2cf46a2 is signed because (I think) it was signed with an ssh key instead of pgp. Can you repro this @storopoli ? I found it when pushing latest master to my github fork repo. |
You can switch flawlessly from Rust stable, MSRV, and nightly using either: - `nix develop .`: Rust MRSV - `nix develop .#msrv`: Rust MRSV - `nix develop .#stable`: Rust latest stable - `nix develop .#nightly`: Rust Nightly Also you don't need to worry about installing binaries from `bitcoind` or `electrs` crates, since we fetch these from `nixpkgs` (with pinned versions) and add them to your local environment. Additionally, all the extra dependencies that you need for WASM are handled as well. Finally, no need to set ENV vars: they are also set all by default to you. If you are committing typos, or failing to adhere to our guidelines in [CONTRIBUTING.md](CONTRIBUTING.md); we won't let you commit or push. This is handled by Nix's automated `pre-commit` hooks which gives helpful error messages. Please check the [Nix.md](Nix.md) file to learn more about Nix and what we are aiming to do with the Nix integration into BDK.
f2e839c
to
4e37eb2
Compare
You are hitting this: https://blog.dbrgn.ch/2021/11/16/git-ssh-signatures/ You need to whitelist @ValuedMammal's ssh key in |
@storopoli sorry to have to bump this one from 1.0 but I think we need to have some more discussions about how nix helps the project and where/how it should be introduced. Also there are multiple new things being introduced here and probably better to put ci, hooks, justfile changes in new prs. But when you're free let's schedule a time for a live that. Thanks! |
Sure, I'll move this to a draft for now. |
Description
This is a simpler version of #1257.
Although not fully reproducible (we are fetching Cargo dependencies instead of declaring all of them).
It is WAY easier to maintain and provides most of the benefits and Dev-Experience from Nix.
You can switch flawlessly from Rust stable, MSRV, and nightly using either:
nix develop .
: latest Rust stablenix develop .#stable
: latest Rust stablenix develop .#msrv
: Rust MRSVnix develop .#nightly
: Rust NightlyIt handles all the annoyances of
Cargo.lock
s andcargo update
s.Also you don't need to worry about installing binaries from
bitcoind
orelectrs
crates,since we fetch these from
nixpkgs
(with pinned versions) and add them to your local environment.Additionally, all the extra dependencies that you need for WASM are handled as well.
Finally, no need to set ENV vars: they are also set all by default to you.
If you are committing typos, or failing to adhere to our guidelines in CONTRIBUTING.md;
we won't let you commit or push.
This is handled by Nix's automated
pre-commit
hooks which gives helpful error messages.Please check the Nix.md file to learn more about Nix and what we are aiming to do with the Nix integration into BDK.
I am taking the liberty of tagging certain people that are Nix enthusiast to help the discussion and review.
Cc @notmandatory, @dpc, @casey-bowman, @plebhash, @matthiasdebernardini, @gudnuf, @oleonardolima.
Notes to the reviewers
(again, please check CONTRIBUTING.md)
cargo clippy
in all workspace.cargo fmt
in all workspace.nixpgs-fmt
in all workspace (for.nix
files)Nix.md
Closes #1162. Superseds #1122, #1156, #1165, #1257.
Pinneds Dependencies:
bitcoind
: pinned to 0.27.0 innixpkgs
version24.05
.electrs
: pinned toBlockstream's esplora
.Changelog notice
Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingNew Features:
Bugfixes: