Skip to content

Conversation

jonathanpwang
Copy link
Contributor

Cherry-picked from #1891 without the twisted Edwards macros.

The complex_init! and sw_init! macros are updated so that instead of parsing a Path, it parses a LitStr. This makes it so that the _init! macros do not require any path imports in the file where it is called, which greatly improves the developer experience.

The main files changed aside from test files and auto-generates openvm_init.rs files are:

  • extensions/algebra/complex-macros/src/lib.rs
  • extensions/ecc/sw-macros/src/lib.rs

In both macros, the change essentially boils down to changing:
(before)

        let items = input.parse_terminated(<Expr as Parse>::parse, Token![,])?;

to (after)

        let items = input.parse_terminated(<LitStr as Parse>::parse, Token![,])?;

and then associated type changes (mostly simplifications) in converting tokens to strings.

There is one additional change needed only for the sw_init! macro case. Previously the linked function

extern "C" fn #setup_extern_func()

defined by the sw_init! macro did use the path of the struct within the function implementation. After this PR, we avoid this import by moving that part of the logic into the fn set_up_once() function defined for the struct itself. This changed the function signature of the extern function to:

            extern "C" fn #setup_extern_func(uninit: *mut core::ffi::c_void, p1: *const u8, p2: *const u8)

Here is the diff of the code that was moved from the #setup_extern_func() into the set_up_once() function.

This comment has been minimized.

Copy link

codspeed-hq bot commented Aug 7, 2025

CodSpeed WallTime Performance Report

Merging #1945 will not alter performance

Comparing chore/init-macro-no-import (6342abf) with feat/new-execution (e67deab)

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

Summary

✅ 27 untouched benchmarks

@jonathanpwang jonathanpwang force-pushed the chore/init-macro-no-import branch from 0027d96 to 6342abf Compare August 7, 2025 19:41
Copy link

github-actions bot commented Aug 7, 2025

group app.proof_time_ms app.cycles app.cells_used leaf.proof_time_ms leaf.cycles leaf.cells_used
verify_fibair (-28 [-2.6%]) 1,067 322,660 18,749,844 - - -
fibonacci (+16 [+0.8%]) 2,090 3,000,420 51,504,507 - - -
regex (-39 [-0.6%]) 6,780 8,217,194 164,734,992 - - -
ecrecover (+8 [+0.7%]) 1,136 (-324 [-0.1%]) 280,974 (-9031 [-0.1%]) 8,866,654 - - -
pairing (+52 [+1.5%]) 3,560 (+39948 [+1.1%]) 3,765,878 (+707074 [+0.7%]) 98,834,293 - - -

Commit: 6342abf

Benchmark Workflow

@jonathanpwang jonathanpwang requested a review from luffykai August 7, 2025 19:56
@jonathanpwang jonathanpwang merged commit 9629ac1 into feat/new-execution Aug 7, 2025
29 checks passed
@jonathanpwang jonathanpwang deleted the chore/init-macro-no-import branch August 7, 2025 20:14
jonathanpwang added a commit that referenced this pull request Aug 7, 2025
…1945)

Cherry-picked from #1891
without the twisted Edwards macros.

The `complex_init!` and `sw_init!` macros are updated so that instead of
parsing a `Path`, it parses a `LitStr`. This makes it so that the
`_init!` macros do not require any path imports in the file where it is
called, which greatly improves the developer experience.

The main files changed aside from test files and auto-generates
`openvm_init.rs` files are:
- extensions/algebra/complex-macros/src/lib.rs
- extensions/ecc/sw-macros/src/lib.rs

In both macros, the change essentially boils down to changing:
(before)
```rust
        let items = input.parse_terminated(<Expr as Parse>::parse, Token![,])?;
```
to (after)
```rust
        let items = input.parse_terminated(<LitStr as Parse>::parse, Token![,])?;
```
and then associated type changes (mostly simplifications) in converting
tokens to strings.

There is one additional change needed only for the `sw_init!` macro
case. Previously the linked function
```rust
extern "C" fn #setup_extern_func()
```
defined by the `sw_init!` macro did use the path of the struct within
the function implementation. After this PR, we avoid this import by
moving that part of the logic into the `fn set_up_once()` function
defined for the struct itself. This changed the function signature of
the extern function to:
```rust
            extern "C" fn #setup_extern_func(uninit: *mut core::ffi::c_void, p1: *const u8, p2: *const u8)
```
[Here](https://www.diffchecker.com/0ncTMwe2/) is the diff of the code
that was moved from the `#setup_extern_func()` into the `set_up_once()`
function.

---------

Co-authored-by: Avaneesh Kulkarni <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants