You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have some precomputed reciprocals that we use in sieving (see precomputed.rs). We currently use lazy_static to handle lazy evaluation ofthose.
lazy_static has some side effects (spin_no_std feature is enabled for all other instances of lazy_static in the dependency tree - see rust-lang-nursery/lazy-static.rs#204).
Another variant is, of course, creating the Reciprocal objects directly during compilation. It doesn't seem to be very slow, but will take about 400kb.
Ideally, whatever we choose, it should be gated by a feature. Need to also test how slow it actually is (especially relatively to the primality checks) to compute the reciprocals on the fly.
The text was updated successfully, but these errors were encountered:
Removed reciprocal precomputation in 09a8f12 - the performance difference is negligible compared to actual primality checks, so all the brittle lazy evaluation libraries are simply not worth the trouble. This can be reverted when once_cell is a part of Rust proper.
We have some precomputed reciprocals that we use in sieving (see
precomputed.rs
). We currently uselazy_static
to handle lazy evaluation ofthose.lazy_static
has some side effects (spin_no_std
feature is enabled for all other instances oflazy_static
in the dependency tree - see rust-lang-nursery/lazy-static.rs#204).once_cell
is an alternative to it. It will be eventually included in the language (rust-lang/rust#74465). There is a problem though: in order to haveno_std
,once_cell
needs thecritical-section
feature enabled;critical-section
crate is brittle (it requires the user of the final application to be aware of it and follow some rules; see https://docs.rs/critical-section/latest/critical_section/#usage-in-libraries).Another variant is, of course, creating the
Reciprocal
objects directly during compilation. It doesn't seem to be very slow, but will take about 400kb.Ideally, whatever we choose, it should be gated by a feature. Need to also test how slow it actually is (especially relatively to the primality checks) to compute the reciprocals on the fly.
The text was updated successfully, but these errors were encountered: