Skip to content

Conversation

egorzhdan
Copy link
Contributor

@egorzhdan egorzhdan commented Oct 13, 2025

When conforming a C++ iterator type to the UnsafeCxxInputIterator protocol, we try to instantiate operator== for the given type, which is one of the requirements of the protocol.

The logic that did name lookup was unintentionally running a global lookup for == across all of the visible Clang modules, which became a performance issue. This happened because ClangImporter was doing a name lookup in the fake __ObjC module instead of the actual owning Clang module for the iterator type.

rdar://162125326 / resolves #84733

@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan egorzhdan force-pushed the egorzhdan/iterator-equalequal branch from 2affa19 to f6a989d Compare October 13, 2025 14:53
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@nkcsgexi
Copy link
Contributor

Nice finding, Egor!

Copy link
Member

@etcwilde etcwilde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to fix the out-of-memory issue in the bootstrap jobs. There is still a separate failure in the SIL verifier.

When conforming a C++ iterator type to the `UnsafeCxxInputIterator` protocol, we try to instantiate `operator==` for the given type, which is one of the requirements of the protocol.

The logic that did name lookup was unintentionally running a global lookup for `==` across all of the visible Clang modules, which became a performance issue. This happened because ClangImporter was doing a name lookup in the fake `__ObjC` module instead of the actual owning Clang module for the iterator type.

rdar://162125326 / resolves swiftlang#84733
@egorzhdan egorzhdan force-pushed the egorzhdan/iterator-equalequal branch from f6a989d to 4f0bd8b Compare October 14, 2025 15:45
@egorzhdan
Copy link
Contributor Author

This depends on #84877

@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan
Copy link
Contributor Author

@swift-ci please benchmark macOS

@egorzhdan
Copy link
Contributor Author

@swift-ci please benchmark

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ interop Feature: Interoperability with C++

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Amazon Linux 2023 - LLVM out of memory after merging stable/21.x

5 participants