I've heard (and correct me if not) @inlinable is just taken as "hello compiler, ensure everyone can inline this if they want" (by e.g. ensuring the definition is visible to everybody) and is not a direct command to inline the function.
Then the compiler decides if it wants to do it at all or not.
If someone wants to make the compiler more inclined to inline a function, they can use @inline(always), or perhaps there can be a @inline(preferred).
So essentially I'd think this is compiler's issue. It should be able to tell when to inline what, and not need explicit @inlinables. I can understand if it'll take time and effort to implement and it's not "free", but yeah.
Also with @inlinable, the only thing that I care about is not actual function inlining.
There are other important stuff as well such as ARC, exclusivity checks, bounds checks etc....
So essentially the compiler, theoretically, should be able to optimize the calling function based on the info it has about another function from another module that is going to be called in it.
In most cases it'll require inlining, or maybe creating a second version of the called function that doesn't have ARC/exclusivity/bounds overheard that e.g. 10 different callers can then use since it can be common to not need to e.g. go through bounds preconditions since correct user code needs to already ensure the index is within bounds and then the compiler/LLVM can see that.
Right I'm aware of possible issues with larger binary sizes and CPUs having to fetch instructions from DRAM too often. However I meant that we should not need to nudge the compiler for that many functions so the compiler starts thinking about inlining them.
Perhaps what I'm asking for is for "cross-module optimizations" to just be more aggressive I guess? I think CMO does inlining already, but that hasn't managed to satisfy the needs of e.g. swift-nio folks?
I mean it hasn't been able to satisfy my needs either, in e.g. GitHub - swift-dns/swift-endpoint: A highly-optimized library containing types representing an endpoint, such as DomainName and IPv4/v6Address · GitHub, but let's talk about swift-nio since we can all trust swift-nio more.
FWIW, I suspect the reason NIO is so keen on @inlinable is that it will allow the ...
Off-hand I know there are multiple reasons that swift-nio does that.
Specializations are the most important one perhaps. But there are other concerns as well like I've mentioned, for example eliminating exclusivity checks that can cost a lot.
Of course sometimes the function is so small that not inlining it would not really be helpful to anything. I'm not sure if CMO already eliminates those well, and if swift-nio has gone for manually eliminating those (via more attributes) or not.