Live data from Hacker News

Cranelift code generation comes to Rust

lwn.net

111–117 of 117 posts

Re: Cranelift code generation comes to Rust

#111

It sucks that there is no way to use cranelift from outside of rust to create your own toy language. I would have loved to use cranelift in a toy compiler, but I am not ready to pay the Rust price of complexity.

Would using cranelift frontend[1] with PyO3[2] be an option for you?

[1]: https://docs.rs/cranelift-frontend/0.105.3/cranelift_fronten... [2]: https://pyo3.rs/v0.15.1/

Re: Cranelift code generation comes to Rust

#112
post #65
post #22

Earlier quoted context omitted.

Superoptimizers: https://en.wikipedia.org/wiki/Superoptimization Also, program distillation: https://www.researchgate.net/publication/220989887_Distillat...

Isn't it a bit weird that this isn't just the standard? Like imagine if Chrome was optimized with such a superoptimizer; let the optimizer spend a couple hours every month or so when cutting a new release. Surely that has to be worth it?

Do you even understand what super compilation is? If you understood it, you wouldn't be thinking of a "couple hours every month". Supercompilation on Chrome would require more than a million hours of CPU time.

Re: Cranelift code generation comes to Rust

#113
post #106

Earlier quoted context omitted.

Can you memoize across invocations so that the time spent optimizing is cumulative across all builds?

Speaking as an e-graph rookie - I believe so, with caveats. You can certainly store the chosen extractions/optimizations and re-use any that don't change. For example, if a long chain of rewrites yields A ==> B ==> ... ==> Z, you could short-circuit that and assume that Z is still what you want to replace A with. Perhaps each time you compiled, you could only rewrite the 'changed' sections of the program, along with…

I always thought that it'd be nice to build an expository version of eq-sat that just operated on straight-line code, and didn't try to use the complicated e-graph structure (does it still use pi-nodes? I've not looked at the paper in a decade). The major complexity of eq-sat is in the novel extraction heuristics, and the complicated data-structures only mask that.

EDIT: Right. Blech. Theta & Phi nodes.

Re: Cranelift code generation comes to Rust

#114
post #20

Very excited for Cranelift for debug builds to speed up development iteration - in particular for WASM/Frontend Rust where iteration speed is competing with the new era of Rust tooling for JS which lands in the sub 1 second builds sometimes (iteration speed in Frontend is crucial). Sadly, it does not yet support ARM macOS, so us M1-3 users will have to wait a bit :/

As someone who doesn't work in the frontend much, what tools are you talking about?

Re: Cranelift code generation comes to Rust

#116
post #20

Very excited for Cranelift for debug builds to speed up development iteration - in particular for WASM/Frontend Rust where iteration speed is competing with the new era of Rust tooling for JS which lands in the sub 1 second builds sometimes (iteration speed in Frontend is crucial). Sadly, it does not yet support ARM macOS, so us M1-3 users will have to wait a bit :/

As someone who doesn't work in the frontend much, what tools are you talking about?

There’s been a recent trend of rewriting tools in Rust with insanes speed gains

- Rspack (webpack compatible)

- Rolldown (rollup compatible)

- Turbopack

- Oxc (linter)

- Biome (linter and more)

- Bun (writing in Zig, does crazy fast bundling)

There’s several parts here that are crucial to Frontend development

For production you need:

- Minificion of source code

- Bundling of modules and source code into either one JS file or split into multiple for lazy loading only the parts you need

- Transforming various unsupported high-level constructs into something older target browsers support

- Typechecking/compiling, or stripping TypeScript if that’s in use

Build times could easily go to 10-20 minutes with older tools.

The development loop also gets hurt, here you’d want the loop from saving your change to seeing it in the UI to be almost instant. Anything else means you’ll have to develop crutch methods to workaround this (imagine moving and styling components only to need to sit and wait during each small incremental change).

Re: Cranelift code generation comes to Rust

#117
post #116

Earlier quoted context omitted.

As someone who doesn't work in the frontend much, what tools are you talking about?

There’s been a recent trend of rewriting tools in Rust with insanes speed gains - Rspack (webpack compatible) - Rolldown (rollup compatible) - Turbopack - Oxc (linter) - Biome (linter and more) - Bun (writing in Zig, does crazy fast bundling) There’s several parts here that are crucial to Frontend development For production you need: - Minificion of source code - Bundling of modules and source code into either one JS…

Thanks for your informative post!
Post reply on HN