-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Re-organize build-dir by package + hash, rather than artifact type #15010
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
Comments
I am assuming that final binary would still be located at
I think we should check how many of the most popular tools rely on the layout. Depending the impact we can adjust how aggressive we want to be with the migration. Regarding strategies, I have 2 ideas.
I do not have a strong opinion on this. I was thinking perhaps |
This does not touch final artifacts. I'd recommend reading up on the following note
I know there is at least There might be some other tools that do weirder stuff, like inspecting debug files or rlibs.
Writing to both or symlinks won't work for the above two tools. A common approach we take is to have a feature be opt-in and then transition it to opt-out. A question in this is if we'd want to still support the old layout, for which we'd do this through a config, or if we'll only support the new layout, for which we use an env variable and after a sufficient time we remove the opt-out. |
Okay, I finally had some time to read up on #14125 some other related threads. Would it would be better to focus on making progress on separating I am leaning towards doing this re-organization after separating the build/artifact dirs. |
I've wondered about doing the build-dir change first, like you said. It would make the scope of the change clear and it would help to communicate out what has compatibility guarantees. |
### What does this PR try to resolve? While doing some investigation on the theoretical performance implications of #4282 (and #15010 by extension) I was profiling cargo with some experimental changes. (Still a work in progress) But in the mean time, noticed that we do not have spans for rustc invocations. I think these would be useful when profiling `cargo build`. (`cargo build --timing` exists but is more geared towards debugging a slow building project, not cargo itself) For reference below is an example before/after of a profile run of a dummy crate with a few random dependencies. #### Before  #### After 
I did some investigating on this. I created a small (and incomplete) prototype on my fork (6a644ff) where the dep-info files are stored in One notable side effect of doing this is that rustc command starts to get very large for projects with many dependencies. This does not seem like an immediate issue, but I am not sure if there limits on some operating systems that might limit the size of a process command. (I created a synthetic test on my Linux machine and was able to create a rustc process with a 60MB with no issues. I didn't both trying anything larger) |
Further down in the layers of calls to rustc, we automatically roll over from CLI args to an argfile. Some potentially relevant questions
Unsure how much we need to answer this in depth. |
On my Linux machine the limit is around 2.6MiB
Looking at how the thresholds are calculated: https://github.com/rust-lang/rust/blob/d2eadb7a94ef8c9deb5137695df33cd1fc5aee92/compiler/rustc_codegen_ssa/src/back/command.rs#L145-L205. I feel like on Windows it is way easier to hit the limit.
One failed rustc invocation + writing big argfiles + only allow UTF-8 encoding (IIRC). |
Yes, this is what I observed while testing with my changes.
I think it will depend on the system settings. My machine has an With some basic extrapolation I would start hitting the arg max on my machine for a project with ~4,000 dependencies. I think a project of this size is pretty large the overhead of a few argfiles on the last few rustc calls will probably not be noticeable. However, I am not so sure about Windows. I don't have a windows machine handy but this Stack overflow seems to suggest that its much lower at 2^16 chars (~32KB). But this post was 13 years ago so I am not sure if it has increased since then. |
note: I specify
build-dir
to clarify which half of #14125 I'm referring to. The files and layout ofbuild-dir
does not have compatibility guarantees (source).Currently,
build-dir
is laid out liketarget/
<target-platform>/
?<profile>/
incremental/
build/
<package>-<hash>/
build*script-*
deps/
<package>-<hash>*
Currently,
cargo clean -p <package>
will operate on everything for<package>
In the future, we could have
<package>-<hash>
(cargo ./target fills with outdated artifacts as toolchains are updated/changed #5026)<package>-<hash>
that are being built block (More granular locking in cargo_rustc #4282)<package>-<hash>
artifacts across all projects (Per-user compiled artifact cache #5931)These could be aided by re-arranging the
build-dir
to be organized around<package>-<hash>
, liketarget/
<target-platform>/
?<profile>/
incremental/
build/
<package>-<hash>/
build*script-*
*.d
Side effects
deps/
and rustc finds the files it needs. We'll instead need to point to each individual artifact rustc may need.Open questions
build-dir
isn't stable, enough tools rely on the layout that we'd want to setup a transition plan so they can have time to test against the new layout and work to support bothbuild/
as its all encompassingbuild/
anddeps/
content live in the same place?incremental/
?<profile>
at least?<hash>
is the-C extra-filename
hash and doesn't encompass all of fingerprinting, so we'd need to audit if there are cases that don't change the hash that we'd stil need per-profileThe text was updated successfully, but these errors were encountered: