The problem / use case
Currently, processkit::Error is over 100 bytes. This bloats both direct users and types like vcs_core::Error which contain it indirectly. These large types frequently fire the clippy lints result_large_err and large_enum_variant. These clippy lints are both on by default; they aren't pedantic.
Errors are presumably on the cold path, so having large error types reduces the performance of the common case.
Proposed solution
Since the processkit::Error enum is public. It is not possible to fix this without a breaking change.
The largest variants only use stdlib types like String, Vec, and Duration.
We cannot shrink the size of these types even if we wanted to.
One option is to box these individual fields of the enum. This is a breaking change.
A more robust solution is to rename the current processkit::Error enum to something like ErrorReason, ErrorKind, or ErrorInfo. Then processkit::Error could hold a boxed reference to the kind. This is similar to the stdlib std::io::Error and std::io::ErrorKind distinction, although our "kind"/"reason"/"info" enum would hold more data than io::ErrorKind.
struct Error {
reason: Box<ErrorReason>
}
impl Error {
pub fn reason(&self) -> &ErrorReason {
&self.reason
}
}
enum ErrorReason {
// all the same variants we currently have in Error
}
Alternatives considered
Leave as is, hurting performance and requiring clippy suppressions.
The problem / use case
Currently,
processkit::Erroris over 100 bytes. This bloats both direct users and types likevcs_core::Errorwhich contain it indirectly. These large types frequently fire the clippy lintsresult_large_errandlarge_enum_variant. These clippy lints are both on by default; they aren't pedantic.Errors are presumably on the cold path, so having large error types reduces the performance of the common case.
Proposed solution
Since the
processkit::Errorenum is public. It is not possible to fix this without a breaking change.The largest variants only use stdlib types like
String,Vec, andDuration.We cannot shrink the size of these types even if we wanted to.
One option is to box these individual fields of the enum. This is a breaking change.
A more robust solution is to rename the current
processkit::Errorenum to something likeErrorReason,ErrorKind, orErrorInfo. Thenprocesskit::Errorcould hold a boxed reference to the kind. This is similar to the stdlibstd::io::Errorandstd::io::ErrorKinddistinction, although our "kind"/"reason"/"info" enum would hold more data thanio::ErrorKind.Alternatives considered
Leave as is, hurting performance and requiring clippy suppressions.