Conversation
| // Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #![cfg_attr(not(feature = "std"), no_std)] |
There was a problem hiding this comment.
You should define features in Cargo.toml. Even though it will work like that, it is not easily discoverable.
There was a problem hiding this comment.
It's a conscious choice. There is no reason to make it discoverable. If user attempts to compile on a bare-metal platform it's simply engaged in the build script.
There was a problem hiding this comment.
But why should blst be unlike any other ordinary Rust crate? There is an established pattern in the ecosystem how this things are done, what is the point of deviating from it?
There was a problem hiding this comment.
Without having this feature defined in Cargo.toml and set by default you essentially compile no_std version for ALL PLATFORMS. Users will have to set std feature to avoid this, but due to "conscious choice" they will have a hard time knowing it exists in the first place.
You can probably define it from within build.rs but you've literally fighting the best practices in the ecosystem for the sake of confusing users.
There was a problem hiding this comment.
you essentially compile
no_stdversion for ALL PLATFORMS.
No. build.rs enables std feature on ALL PLATFORMS but bare-metal ones.
Users will have to set std feature to avoid this,
No. Users won't have to do anything. Nor would they have to do anything special when using blst as dependency on a bare-metal platform.
There was a problem hiding this comment.
They may want to have no threads either because for their use case threading makes more sense on higher level
And they can do that. Nobody actually did to my knowledge, defaulting to multi-threading appears to be generally appreciated.
and
blstwould just cause quadratic number of threads only making things worse.
This is not true. blst uses a private fixed-sized threadpool.
There was a problem hiding this comment.
blst is about what actually works, not what might work.
What I'm trying to say is blst can't possibly know and doesn't really need to know what works and what doesn't. I have given a few examples like support for threads where you think there isn't such support and forcing std on users that can, but don't want to depend on it. Both of those are not possible to achieve with current design of the library.
Simply offering two features enabled by default (std and threads) allows any imaginable supported platform will work under full control of the developer using the library.
There was a problem hiding this comment.
And what I'm saying is that if we don't know something, we make no assumptions and don't really want users to make such assumptions either. [As effectively reflected in README.md.] But as already said, it's not right spot to discuss this. Why-not-this-way is off-topic in this specific context. Open an issue or choose another channel to communicate with supranational.
There was a problem hiding this comment.
They may want to have no threads either because for their use case threading makes more sense on higher level
And they can do that. Nobody actually did to my knowledge, defaulting to multi-threading appears to be generally appreciated.
For the record (just to volunteer relevant info, I don’t have a horse in this race), MystenLabs/fastcrypto#176
There was a problem hiding this comment.
I was thinking to replace manual thread pool management with rayon, which inherits thread pool from outer context and that way you can change number of threads from the outside (or not bother and use global default thread pool), but didn't have time to do the change and bench it.
.github/workflows/ci.yml
Outdated
| fi | ||
| cargo test --release | ||
| cargo test --release --features=no-threads | ||
| env BLST_TEST_NO_STD= cargo test --release |
There was a problem hiding this comment.
This is not how Rust ecosystem does it. It should be controlled by features (there is --no-default-features for instance). See #150 on how to do it in idiomatic way.
There was a problem hiding this comment.
This is not how Rust ecosystem does it.
I don't really care. I want to exercise the no_std build on an std platform without offering an idiomatic way.
There was a problem hiding this comment.
What is the point? It just confuses the heck out of people.
I get that in other languages that might be a norm, but in Rust there are conventions that make like so much easier, I don't quite understand the rationale behind deliberately making it harder instead 😕
IMHO Rust API should look like idiomatic Rust, Golang API should look like idiomatic Golang and so on for every language to the degree possible.
There was a problem hiding this comment.
What is the point?
??? It says just one line above, "exercise the no_std build on an std platform." It's not for users, but for us as a way to ensure that no_std doesn't go under the CI radar unchecked.
There was a problem hiding this comment.
My question was about your comment. What is the point of intentionally doing non-idiomatic way with environment variables and other trickery if you can just use idiomatic --no-default-features like most other projects do.
We plan to use this package in Subspace and I care about the quality of Rust binding and willing to help, so seeing deliberately non-idiomatic code is confusing to me and doesn't make sense.
There was a problem hiding this comment.
you can just use idiomatic
--no-default-features
To do what? To run the test. But what do I tell no_std, a.k.a. bare-metal platform users who want to use blst as dependency? Or let me rephrase. Provided that I don't actually have to tell them anything special, why would I want to?
We plan to use this package in Subspace
Just in case, quoting README.md, "Problem reports for these [non-x86_64 and ARM64 hardware platforms] will be considered and are likely to be addressed."
There was a problem hiding this comment.
To do what? To run the test. But what do I tell no_std, a.k.a. bare-metal platform users who want to use blst as dependency? Or let me rephrase. Provided that I don't actually have to tell them anything special, why would I want to?
Because it is up to the user whether they want to use std or not (it is not free, they might run on a platform where they don't want to pull std even if they technically could from CPU architecture point of view). This might include use cases like building a static library. By forcing decisions that you don't want to tell and don't want to expose you're locking them out of ability to use the library like they use any other idiomatic Rust library.
Just in case, quoting README.md, "Problem reports for these [non-x86_64 and ARM64 hardware platforms] will be considered and are likely to be addressed."
It is certainly appreciated, but my point is that if you create a typical idiomatic Rust crate you don't even need to have that in the readme. The beauty of Rust ecosystem is that most of the packages follow the same versioning, naming and features conventions and everyone knows what it is and how to use it. By default. No extra docs necessary.
| pippenger_mult_impl!( | ||
| p1_affines, | ||
| blst_p1, | ||
| blst_p1_affine, | ||
| blst_p1s_to_affine, | ||
| blst_p1s_mult_pippenger_scratch_sizeof, | ||
| blst_p1s_mult_pippenger, | ||
| blst_p1s_tile_pippenger, | ||
| blst_p1_add_or_double, | ||
| blst_p1_double, | ||
| p1_multi_scalar, | ||
| blst_p1_generator, | ||
| blst_p1_mult, | ||
| ); |
There was a problem hiding this comment.
These should really be generics and type aliases for convenience rather than macros. Macros destroy IDE support and make it hard to debug things when something goes wrong both for maintainers and users. This crate seems to go to extreme by having almost all code under macros, which is a big usability issue.
|
Just in case. Questions/rants that go beyond the specific subject matter will remain unanswered. The subject is that the suggested method is deemed to work reliably. Without disrupting current users and providing a straightforward path for potential no_std users. |
#150 is also fully backwords compatible and supports |
6cf5c27 to
4516f94
Compare
|
Hello are there any plans to merge this soon? |
7ed2b4d to
734c562
Compare
be64c71 to
d3dbaab
Compare
|
Merged. |
No description provided.