Skip to content
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

Boxed errors #569

Merged
merged 5 commits into from
Sep 24, 2024
Merged

Boxed errors #569

merged 5 commits into from
Sep 24, 2024

Conversation

rben01
Copy link
Contributor

@rben01 rben01 commented Sep 18, 2024

clippy warned that some Result types were quite large due to their massive error variant. For instance, interpreter::RuntimeError is 304 bytes, which means the following function returns a whopping 304 bytes (I'm assuming there's a niche somewhere; if not, then 305) despite its Ok variant having no payload!

fn compile_statement(
&mut self,
stmt: &Statement,
dimension_registry: &DimensionRegistry,
) -> Result<()> {

The same goes for TypeCheckError (264 bytes) and NumbatError (also 304 as it wraps RuntimeError). This seemed like a lot of data to allocate space to the error case.

I took clippy’s advice and boxed the errors so that they'd take 8 bytes at most. This obviously adds an indirection to the error path but uses much less stack space for the Ok path.

@sharkdp
Copy link
Owner

sharkdp commented Sep 24, 2024

Thank you very much! It would be great if you could resolve the conflict (or let me know if you need help).

@rben01
Copy link
Contributor Author

rben01 commented Sep 24, 2024

Thank you very much! It would be great if you could resolve the conflict (or let me know if you need help).

Done!

@sharkdp
Copy link
Owner

sharkdp commented Sep 24, 2024

The wasm build is currently failing. There was an issue on master which I fixed, but now the failure seems to be related to this branch.

@rben01
Copy link
Contributor Author

rben01 commented Sep 24, 2024

Should be good to go now. I was ignoring WASM build errors before but yeah, this one was legit. For whatever reason rust-analyzer can't analyze the numbat-wasm crate, maybe because it can't see through #[wasm_bindgen] (?), so I wasn't getting any error messages.

@sharkdp
Copy link
Owner

sharkdp commented Sep 24, 2024

For whatever reason rust-analyzer can't analyze the numbat-wasm crate

The wasm package is not part of the workspace (there was a technical reason why this didn't work, but maybe it's worth revisiting). That's why rust analyzer doesn't see it. It works if you open the numbat-wasm project / folder.

@sharkdp sharkdp merged commit 4361530 into sharkdp:master Sep 24, 2024
15 checks passed
@rben01 rben01 deleted the boxed-errors branch October 1, 2024 03:59
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