Conversation
There are a number of performance constraints that can be lifted in the source-available build mode. Many of these are ultimately about specialization, but we should resolve all of these with a judicious sprinkling of @inlinables.
| /* fileprivate but */ @usableFromInline let rawValue: UInt8 | ||
|
|
||
| private static let maxRawValue: UInt8 = 3 | ||
| /* private but */ @usableFromInline static let maxRawValue: UInt8 = 3 | ||
|
|
||
| private init(uncheckedValue: UInt8) { | ||
| /* private but */ @inlinable init(uncheckedValue: UInt8) { | ||
| assert(uncheckedValue <= Self.maxRawValue) | ||
| self.rawValue = uncheckedValue | ||
| } | ||
|
|
||
| fileprivate init?(rawValue: UInt8) { | ||
| /* fileprivate but */ @inlinable init?(rawValue: UInt8) { |
There was a problem hiding this comment.
Is it worth renaming these (and elsewhere in this PR where we had to relax the access modifier) by prepending a _ (in the case of the inits, maybe append to the argument name)?
There was a problem hiding this comment.
We could, but that makes the blast radius of the change a lot larger, diff-wise. I'll take guidance from everyone else on that, but I aimed to keep the diff small.
| public static var disallow: Self { .init(uncheckedValue: 3) } | ||
|
|
||
| fileprivate let rawValue: UInt8 | ||
| /* fileprivate but */ @usableFromInline let rawValue: UInt8 |
There was a problem hiding this comment.
These are also going to run afoul of the somewhat-debated "no block comments" rule in our standard formatter configuration.
|
Do This does make it harder for me to import and keep the internal version in sync. Will cross-module optimization eliminate the need for doing this manually? |
|
The compiler only does that automatically within the module. When private functions are called from inlinable functions they need to themselves be marked inlinable to be eligible for optimisation. Cross-module optimisation is already turned on and failing to fire. Generally speaking my experience has been that CMO tends to be pretty limited, and frequently fails to fire. Let’s chat next week about whether we can work together on some automated tooling to add and remove these annotations. We already have some for their removal that you may be able to use. |
There are a number of performance constraints that can be lifted in the source-available build mode. Many of these are ultimately about specialization, but we should resolve all of these with a judicious sprinkling of @inlinables.