Skip to content

Conversation

jansvoboda11
Copy link

No description provided.

@jansvoboda11
Copy link
Author

@swift-ci please test

@jansvoboda11
Copy link
Author

swiftlang/swift#68503
@swift-ci please test

This function has the same semantics as
`std::shared_ptr<T>::use_count()`, and enables implementing
copy-on-write semantics.
This enables making the whole `CompilerInvocation` more efficient
through copy-on-write.
This PR introduces new copy-on-write `CompilerInvocation` class
(`CowCompilerInvocation`), which will be used by the dependency scanner
to reduce the number of copies performed when generating command lines
for discovered modules.
We create one `CompilerInvocation` for each modular dependency we
discover. This means we create a lot of copies, even though most of the
invocation is the same between modules. This patch makes use of the
copy-on-write flavor of `CompilerInvocation` to share the common parts,
reducing memory usage and speeding up the scan.
This patch makes the generation of command lines for modular
dependencies lazy/on-demand. That operation is somewhat expensive and
prior to this patch used to be performed multiple times for the
identical `ModuleDeps` (i.e. when they were imported from multiple
different TUs).
…lvm#66301)

This avoids making copies at the end of
`makeCommonInvocationForModuleBuild()` (in `ModuleDepCollector.cpp`).
@jansvoboda11 jansvoboda11 force-pushed the jan_svoboda/20230725-cow-ci branch from df238ba to bbdb312 Compare October 5, 2023 21:52
@jansvoboda11 jansvoboda11 merged commit f051029 into stable/20230725 Oct 6, 2023
@jansvoboda11 jansvoboda11 deleted the jan_svoboda/20230725-cow-ci branch October 6, 2023 18:31
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.

1 participant