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
1171285
to
c126d49
Compare
let bitcoind = match std::env::var_os("BITCOIND_EXE") { | ||
let bitcoind = match std::env::var_os("BITCOIND_EXEC") { | ||
Some(bitcoind_path) => electrsd::bitcoind::BitcoinD::new(bitcoind_path), | ||
None => { | ||
let bitcoind_exe = electrsd::bitcoind::downloaded_exe_path() | ||
.expect( | ||
"you need to provide an env var BITCOIND_EXE or specify a bitcoind version feature", | ||
"you need to provide an env var BITCOIND_EXEC or specify a bitcoind version feature", |
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.
These were driving me crazy. It was not trivial to find.
These were wrong according to the bitcoind
/electrsd
docs.
Glad that I was able to fix it.
Cc @LagginTimes.
This rebasing is turning out to be not trivial. |
You can see the error
Hi @storopoli Line 26 in 80e190b
But now your feature branch is https://github.com/storopoli/bdk/blob/488cdc3b8004b0c9b77ce160675dfcddbfcf7c70/crates/esplora/Cargo.toml#L26 electrsd = { version = "0.26.0", features = ["legacy"] } And this possibly needs 1.68 as MSRV, or make an optional feature in electrsd and avoid that. (base on Currently, time msrv is Hi @ValuedMammal @evanlinjin This is what I did a similar task before storopoli#3 for the PR. If this is still in a not merged PR, then a similar thing will keep happening. So that is why the nix needs to be introduced in the early stage of a project. |
6f567d3
to
864f78c
Compare
@yanganto this is the exact change that we we're proposing with the Nix CI. See the electrsd = { version = "0.26.0", features = ["legacy"] } If we include I 0368051 and 864f78c fixes that in the I tried to fix the clippy warnings in 9373abb but now I am getting this error: error[E0786]: found invalid metadata files for crate `bitcoin`
--> crates/chain/src/spk_iter.rs:202:20
|
202 | let secp = bitcoin::secp256k1::Secp256k1::signing_only();
| ^^^^^^^
|
= note: invalid metadata version found: /home/runner/work/bdk/bdk/target/debug/deps/libbitcoin-9e061ce2009267ea.rmeta I cannot reproduce this locally with |
The error is
The bdk crate can not be built when using clippy. Forgot the crate bug, I will just do clippy after the build, leave the hidden bug still in the crate, and focus on the ci itself here. Also, I found the pre-commit-check does not use msrv. |
@yanganto Thank you for the insightful comments, and especially for the work you put into this. True I haven't given this the review time it deserves, though I'm willing to be open minded when it comes to improving the build system. |
b0ac809
to
72a8e02
Compare
Alright, this is now once again ready to merge to Again, thanks @yanganto for the amazing work. |
c35426e
to
b9aec8b
Compare
677cac9
to
103bf17
Compare
f48c1b7
to
5ee7644
Compare
You can switch flawlessly from Rust stable, MSRV, and nightly using either: - `nix develop .`: latest stable - `nix develop ".#msrv"`: Rust MRSV - `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.
Another painful rebase 😓. |
Open questions
electrs
/bitcoind
local binaries. This can be fixed with-- --test-threads=2
. Shall we add?bitcoind
to0.25.1
.0.26.0
I am getting build errors indarwin
systems (Apple stuff). Do we need0.26.0
now? Or can we wait fornixpkgs
24.5?TODO
nixpkgs
to24.5
.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 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.25.1 innixpkgs
.electrs
: pinned toBlockstream's esplora
using the Fedimint deployment, check jkitman/nixpkgs@61ccef8 and https://github.com/fedimint/fedimint/blob/master/flake.nix#L5Changelog notice
Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingNew Features:
Bugfixes: