-
Notifications
You must be signed in to change notification settings - Fork 78
ARM64 NUDUPL VDF path + cross-platform build/CI fixes #298
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
Open
hoffmang9
wants to merge
4
commits into
main
Choose a base branch
from
nudupl-arm64-ci
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+558
−81
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e51baa4
Enable ARM64 NUDUPL path and improve cross-platform builds
hoffmang9 8e682d6
Prefer x86 asm only on x86_64
hoffmang9 25778bc
have the brew check for gmp actually work
hoffmang9 41fbbed
Fuzzing prove() with unbounded iters can explode memory usage, especi…
hoffmang9 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,32 @@ | ||
| #![no_main] | ||
|
|
||
| use chiavdf::prove; | ||
| use libfuzzer_sys::fuzz_target; | ||
| use libfuzzer_sys::{fuzz_target, Corpus}; | ||
|
|
||
| fuzz_target!(|data: ([u8; 32], [u8; 100], u16)| { | ||
| // Fuzzing `prove()` with unbounded `iters` can explode memory usage and runtime. | ||
| // The cost of the underlying VDF prover is at least linear in `iters`, and in | ||
| // practice can become superlinear due to internal allocation patterns. We have | ||
| // observed OOM (exit 137) in CI when `iters` is allowed to reach the full `u16` | ||
| // range, so we cap it to keep fuzzing stable and high-throughput. | ||
| // | ||
| // Why 4096: | ||
| // - Large enough to exercise multiple loop iterations and proof paths beyond | ||
| // "toy" counts, preserving meaningful coverage. | ||
| // - Small enough to keep inputs fast and avoid pathological allocations across | ||
| // typical CI memory limits. | ||
| // - Selected empirically as a conservative upper bound given prior OOMs; it can | ||
| // be raised later if measurements show steady memory and acceptable exec/s. | ||
| // | ||
| // If you want deeper iteration coverage, consider a separate stress target or | ||
| // a time/iteration-budgeted harness rather than unbounded fuzz inputs. | ||
| const MAX_ITERS: u64 = 4096; | ||
|
|
||
| fuzz_target!(|data: ([u8; 32], [u8; 100], u16)| -> Corpus { | ||
| let (genesis_challenge, element, iters) = data; | ||
| prove(&genesis_challenge, &element, 1024, iters as u64); | ||
| let iters = iters as u64; | ||
| if iters > MAX_ITERS { | ||
| return Corpus::Reject; | ||
| } | ||
| prove(&genesis_challenge, &element, 1024, iters); | ||
| Corpus::Keep | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| #ifndef CHIAVDF_PROFILE_H | ||
| #define CHIAVDF_PROFILE_H | ||
|
|
||
| #include <cstdint> | ||
|
|
||
| // This header centralizes optional profiling hooks used by `vdf.h` (driver) and | ||
| // hot-loop primitives like NUDUPL (`nucomp.h`). Everything is no-op unless: | ||
| // - `VDF_TEST` is enabled (VDF_MODE=1), and | ||
| // - the caller sets `chiavdf_nudupl_profile_sink` (and optionally enables timing). | ||
|
|
||
| struct chiavdf_nudupl_profile_stats { | ||
| // Outer-loop counts (from `repeated_square_nudupl`). | ||
| uint64_t iters = 0; | ||
| uint64_t reduce_calls = 0; | ||
| uint64_t reduce_skipped = 0; | ||
| uint64_t max_a_limbs = 0; | ||
|
|
||
| // Outer-loop timing (from `repeated_square_nudupl`). | ||
| uint64_t nudupl_form_time_ns = 0; | ||
| uint64_t reduce_time_ns = 0; | ||
|
|
||
| // Inner-loop breakdown (from `qfb_nudupl`). | ||
| uint64_t qfb_nudupl_calls = 0; | ||
| uint64_t b_negative = 0; | ||
| uint64_t branch_a_lt_L = 0; | ||
| uint64_t branch_a_ge_L = 0; | ||
|
|
||
| uint64_t gcdext_time_ns = 0; | ||
| uint64_t gcdext_s_eq_1 = 0; | ||
| uint64_t gcdext_s_ne_1 = 0; | ||
| uint64_t xgcd_partial_time_ns = 0; | ||
| uint64_t else_branch_time_ns = 0; // time spent in the a>=L branch overall | ||
| }; | ||
|
|
||
| #if defined(VDF_TEST) | ||
| inline thread_local chiavdf_nudupl_profile_stats* chiavdf_nudupl_profile_sink = nullptr; | ||
| inline thread_local bool chiavdf_nudupl_profile_timing_enabled = false; | ||
| #endif | ||
|
|
||
| #endif // CHIAVDF_PROFILE_H |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.