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

Pure Macros #55

Open
rzvxa opened this issue Jun 26, 2024 · 0 comments
Open

Pure Macros #55

rzvxa opened this issue Jun 26, 2024 · 0 comments

Comments

@rzvxa
Copy link

rzvxa commented Jun 26, 2024

Hello,

I hope you having a wonderful day, First off let me thank you for your awesome projects; I'm a fan of your work.

I was wondering have you ever tried to cache the TokenStream based on the input? So maybe we can mark a procedural macro as #[pure] and get the results cached based on the input?

I have recently forked proc-macro2 and serde (to remove its dependency on proc-macro2) and bootstrapped a simple serializable TokenStream, But It means that I would still spend a lot of time compiling and running a noop macro that just reads the cache and returns it.

Then I came around to this article a few days ago https://www.coderemote.dev/blog/faster-rust-compiler-macro-expansion-caching/

It sounded promising to me, So that's when I started thinking about using Watt as both the runtime and cache server to prevent the redundant time spent on the macro execution by short-circuiting from the cache auto-magically.

So what I want to ask you is, Have you ever tried this? What are your thoughts? Do you think Watt can be a good place to do this kind of caching? Or do you prefer me to not submit such a PR and instead work on a standalone solution?

I also would like to know about the current situation with the Compiler and Fallback variants of the token stream and whether are they going to both be kept in or one is a temporary transition period solution. But I think that's another question for another repo.

Note: while this text is written with @dtolnay as the recipient the question remains open for everyone to discuss. Sorry if it felt more like an email than an issue, I just noticed the tone as I'm about to submit😅

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

No branches or pull requests

1 participant