filecoin-project / filecoin-project/actors-utils
Optimise TokenError performance by boxing StateInvariantError
- Dominant language
- Rust
- Stars
- 17
- Forks
- 17
- PR merge metrics
- No merged PRs in 30d
Description
The `TokenError` enum in the FRC46 library contains a large `StateInvariantError` variant (192+ bytes) that triggers clippy warnings about large error types. I believe this impacts performance because `Result` types are frequently used throughout the FRC46 library so the warning is probably worth paying attention to.
- Currently suppressed with `#[allow(clippy::result_large_err)]` attributes as per PR https://github.com/filecoin-project/actors-utils/pull/254
- 24 functions in the token library return large `Result` types
- Test actors that wrap `TokenError` also inherit this performance penalty
Proposed Solution
Box the `StateInvariant` variant to reduce `TokenError` size:
```rust
#[derive(Error, Debug)]
pub enum TokenError {
// ... other variants unchanged
#[error("error in state invariants {0}")]
StateInvariant(Box), // Box this variant
}
```
I think the public impact should be fairly minimal and won't change the exit code behaviour of FRC46 implementations.
But, I'm not entirely sure yet, which is why I'm not doing this right now!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.