-
Notifications
You must be signed in to change notification settings - Fork 41
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
Size of generated code #148
Comments
So just to be clear, your concern about the size is only because you're vendoring, right? Or is there any other reason? What is the mechanism of deduping? Type-alias stuff would be complicated because it's not just a matter of discovering duplicates but also of moving the "common" type into some place unaffected by version features. Eg v1_23::Pod can't just be an alias for v1_22::Pod because v1_22::Pod only exists when the v1_22 feature is enabled, so v1_22::Pod would have to be moved to common::Pod and then both v1_22::Pod and v1_23::Pod would be aliases of that. An easier way would be to just symlink v1_23::Pod's file to v1_22::Pod's file. Also that'll be even more space savings, because the size of the symlink is the length of the file names, which would be smaller than a file that contains a type alias. I know What should be the basis of deduping? Let's say the crate supports five versions 1.21 through 1.25...
I think the answers are:
What do you think? |
Yes, that's the primary concern. (Which isn't really about disk space though that matters a little, but about auditability)
I think we'd need to do some scripting to see just how many types are identical, but I'd just offhand guess it's at least 50%.
There is an alternative approach that would require more work in the code generator, which is basically to use
symlinks have a few suboptimal things; one is that not all search and IDE tools handle them nicely. Another is Windows. Related to all of the above: It'd probably help overall to just use the latest version of the documentation (I suspect there's 0.5% of cases where this might be misleading, but it's probably worth it to default and then add overrides) |
Okay. One more question: Do you use As part of adding v1.28 support there are a bunch of non-trivial changes that need to be made to the code generator. The change to support extra parameters as mentioned there is already done, but there are more changes needed on top of that, and I'm wondering if it's worth it. Basically every user I know disables the |
v0.20 has been released with the API operations-related code removed. Is it small enough now? If not, we can keep this open for working on a deduping solution. |
We currently use And, thanks for looking at this. It looks like v0.20 is better, but still really large:
Versus previously:
|
I'd like to add that this generated code takes a long time to compile. I have a beefy desktop computer and |
Compilation time will not change because of what's being discussed in this issue. That would be #77 |
This crate generates a lot of code. It is by nearly an order of magnitude the largest code size in our app's dependencies.
4.5M doesn't sound that bad, but it actually uncompresses to:
Almost 55MiB uncompressed Rust source! By comparison,
tokio-1.29.1.crate
is 678KiB compressed, ~4MiB uncompressed.Now, one thing that seems like it should work is trimming the versions we don't use; AIUI enabling e.g. the
v1_25
feature means that the other versions are unused. I can pretty easily do that downstream by removing the source when generating our vendor snapshot (we use https://github.com/coreos/cargo-vendor-filterer ).That said...skimming through
diff -u src/v1_2{2,3}/api/core/v1/
for example, 99% of the changes are just to documentation comments; and many of the doc comment changes are entirely spurious. To cherry pick one:That's just whitespace changes (and spurious ones at that!)
Maybe some sort of post-processing that identifies identical APIs and instead rewrites the generate code to just be a type alias for the one in the prior version would work. (But as soon as we do that, it breaks the crude hammer of just
rm -rf
)The text was updated successfully, but these errors were encountered: