Skip to content

Comments

refactor(core): Put Backtrace in a box to reduce error size#6193

Merged
Xuanwo merged 2 commits intomainfrom
make-error-smaller
May 16, 2025
Merged

refactor(core): Put Backtrace in a box to reduce error size#6193
Xuanwo merged 2 commits intomainfrom
make-error-smaller

Conversation

@Xuanwo
Copy link
Member

@Xuanwo Xuanwo commented May 16, 2025

Which issue does this PR close?

None

Rationale for this change

This PR will address clippy issues around:

error: the `Err`-variant returned from this function is very large
   --> src/services/oss/core.rs:176:10
    |
176 |     ) -> Result<http::request::Builder> {
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 128 bytes
    |
    = help: try reducing the size of `types::error::Error`, for example by boxing large elements or replacing it with `Box<types::error::Error>`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err

What changes are included in this PR?

This PR also fixed other clippy issues at the same time to make CI happy.

Are there any user-facing changes?

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. releases-note/refactor The PR does a refactor on code or has a title that begins with "refactor" labels May 16, 2025
@Xuanwo Xuanwo requested review from dqhl76 and xxchan May 16, 2025 08:23
Signed-off-by: Xuanwo <[email protected]>

source: Option<anyhow::Error>,
backtrace: Backtrace,
backtrace: Option<Box<Backtrace>>,
Copy link
Member

@xxchan xxchan May 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about put everything except kind into a boxed inner struct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a tradeoff between "reducing the size from 88 to even smaller" and "always having a box allocation." I prefer to avoid the box allocation.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label May 16, 2025
@Xuanwo Xuanwo merged commit 38ebddc into main May 16, 2025
321 checks passed
@Xuanwo Xuanwo deleted the make-error-smaller branch May 16, 2025 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer releases-note/refactor The PR does a refactor on code or has a title that begins with "refactor" size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants