GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Notices by John McCall (rjmccall@hachyderm.io), page 2

  1. Embed this notice
    John McCall (rjmccall@hachyderm.io)'s status on Friday, 14-Jun-2024 10:33:31 JST John McCall John McCall
    in reply to

    26:45 - I actually prefer the cute term "funclet" for these, but it was observed during rehearsals (quite correctly) that the code I wrote in the demangler calls them "partial functions", and since presumably people have been seeing that term in stack traces for the last four years, perhaps we ought to take this opportunity to explain to people what it actually means.

    In conversation about a year ago from hachyderm.io permalink
  2. Embed this notice
    John McCall (rjmccall@hachyderm.io)'s status on Friday, 14-Jun-2024 10:33:31 JST John McCall John McCall
    in reply to

    34:00 - The initial slab of a task tends to be a bit smaller than this because the task object is colocated with it. And subsequent slabs can be larger if the task needs to allocate more than the default slab size at once. The current task allocator does not hand memory back to the system until the task is complete, so reaching a high-water mark and then suspending is somewhat punished; probably we ought to at least allow unused slabs to be reclaimed if memory is running low.

    In conversation about a year ago from hachyderm.io permalink
  3. Embed this notice
    John McCall (rjmccall@hachyderm.io)'s status on Friday, 14-Jun-2024 10:33:30 JST John McCall John McCall
    in reply to

    30:00 - Swift does a lot of extra optimizations and analysis with local vars to try to make this little bit of semantics zero-cost when you don't need it. For example, I don't talk about dynamic exclusivity enforcement in this talk, but we potentially have to use it with local vars if they escape, and yet we really don't want to pay for it if they don't. We also recognize when a reference capture can be a value capture because the value isn't modified after the capture point.

    In conversation about a year ago from hachyderm.io permalink
  4. Embed this notice
    John McCall (rjmccall@hachyderm.io)'s status on Friday, 14-Jun-2024 10:33:30 JST John McCall John McCall
    in reply to

    29:30 - You can actually write the correct function signature for this in C if you use clang's Swift CC extensions:

    ```
    __attribute__((swiftcall))
    Int puzzle_closure(__attribute__((swift_context)) void *ctx);
    ```

    The attributes would be super-distracting on a slide, though. The important point is the information flow.

    In conversation about a year ago from hachyderm.io permalink
  5. Embed this notice
    John McCall (rjmccall@hachyderm.io)'s status on Friday, 14-Jun-2024 10:33:29 JST John McCall John McCall
    in reply to

    32:00 - Protocol types benefit from the same class-bound optimization as generic layout does; if we have `protocol DataModel : AnyObject`, then the struct would be more like:

    ```
    struct AnyDataModel {
    void *value;
    DataModelWitnessTable *value_is_DataModel;
    };
    ```

    That is, we know that the representation is a single class reference, and we know that we can recover its dynamic type from that class reference and don't need to store it separately.

    In conversation about a year ago from hachyderm.io permalink
  6. Embed this notice
    John McCall (rjmccall@hachyderm.io)'s status on Friday, 14-Jun-2024 10:33:29 JST John McCall John McCall
    in reply to

    31:15 - The witness functions are also passed a pointer to the witness table, which enables default implementations to be placed directly in the witness table without being specialized. (This is required in some cases with library evolution.) But that ended up being too busy for such a minor detail on a slide.

    Of course, in actual C code, they also require calling-convention attributes like the closure example above.

    In conversation about a year ago from hachyderm.io permalink
  7. Embed this notice
    John McCall (rjmccall@hachyderm.io)'s status on Friday, 14-Jun-2024 10:33:28 JST John McCall John McCall
    in reply to

    Overall, I'm quite happy with the talk, and I think I did a good job covering some fairly advanced topics in a fairly approachable way. I had a couple different audiences in mind here: both experienced Swift programmers and longtime C programmers who were relatively new to Swift. I hope it's useful to folks.

    In conversation about a year ago from hachyderm.io permalink
  8. Embed this notice
    John McCall (rjmccall@hachyderm.io)'s status on Friday, 14-Jun-2024 10:33:28 JST John McCall John McCall
    in reply to

    Note that, if the protocol type only has ObjC protocol conformances (which all imply a class bound), there are no witness table pointers, and so this devolves to simply the class reference. We rely on this in bridging to ObjC, but it also just falls out of the layout rules.

    In conversation about a year ago from hachyderm.io permalink
  9. Embed this notice
    John McCall (rjmccall@hachyderm.io)'s status on Friday, 14-Jun-2024 03:52:13 JST John McCall John McCall
    in reply to

    The annotated talk:

    0:30 - The C blocks extension is probably the most significant exception to this — __block variables can get allocated on the heap. But even that is largely only triggered by function calls in C and non-ARC ObjC, although we're currently reviewing a patch to fix a self-reference-during-initialization bug that will require eager heap allocation.

    In conversation about a year ago from hachyderm.io permalink
  10. Embed this notice
    John McCall (rjmccall@hachyderm.io)'s status on Friday, 14-Jun-2024 03:52:13 JST John McCall John McCall

    Hey everybody get a load of this guy with crazy eyebrows talking about the implementation of a bunch of Swift language features: https://developer.apple.com/wwdc24/10217

    In conversation about a year ago from hachyderm.io permalink

    Attachments

    1. Domain not in remote thumbnail source whitelist: devimages-cdn.apple.com
      Explore Swift performance - WWDC24 - Videos - Apple Developer
      from Apple Inc.
      Discover how Swift balances abstraction and performance. Learn what elements of performance to consider and how the Swift optimizer...
  11. Embed this notice
    John McCall (rjmccall@hachyderm.io)'s status on Friday, 14-Jun-2024 03:52:12 JST John McCall John McCall
    in reply to

    3:45 - I wish I'd had more time to talk about optimization throughout this talk, but it would've made it even drier and denser. I'll try to elaborate on this stuff in these annotations.

    In conversation about a year ago from hachyderm.io permalink
  12. Embed this notice
    John McCall (rjmccall@hachyderm.io)'s status on Friday, 14-Jun-2024 03:52:12 JST John McCall John McCall
    in reply to

    2:30 - I really do want to emphasize that you should always start looking at performance with a top-down, high-level investigation. A lot of people think microbenchmarks are meaningful! They often really aren't! Even when they mean something, it's usually not what the author was trying to evaluate.

    In conversation about a year ago from hachyderm.io permalink
  13. Embed this notice
    John McCall (rjmccall@hachyderm.io)'s status on Friday, 14-Jun-2024 03:52:11 JST John McCall John McCall
    in reply to

    6:10 - I technically do say this right in the talk, but I feel a little guilty about how I'm conflating two slightly different points here. Typically, static dispatch is necessary in order to do interprocedural optimization (although it is possible to do speculative compile-time IPO). Static dispatch is not *sufficient*, though — if the compiler can't see the definition of the function it's calling, IPO is sill impossible.

    In conversation about a year ago from hachyderm.io permalink
  14. Embed this notice
    John McCall (rjmccall@hachyderm.io)'s status on Friday, 14-Jun-2024 03:52:11 JST John McCall John McCall
    in reply to

    5:25 - This applies to a certain extent even when the argument has to be passed on the stack — processors have to retire memory accesses in their correct order for the memory model, but they often can still do out-of-order forwarding through memory, especially for stack-based patterns. Modern processors really are incredible; I could talk about this stuff for hours

    In conversation about a year ago from hachyderm.io permalink
  15. Embed this notice
    John McCall (rjmccall@hachyderm.io)'s status on Friday, 14-Jun-2024 03:52:10 JST John McCall John McCall
    in reply to

    7:40 - In this assembly snippet, you can also see the code that sets up the frame header by saving and restoring the caller's frame pointer (x29) and the return address (x30). These are 8-byte registers; 208 - 2*8 == 192, so you can see that these go at the very top of the frame.

    In conversation about a year ago from hachyderm.io permalink
  16. Embed this notice
    John McCall (rjmccall@hachyderm.io)'s status on Friday, 14-Jun-2024 03:52:10 JST John McCall John McCall
    in reply to

    The most important and obvious form of IPO is inlining, which exists in some form in basically every programming language. Swift also does generic specialization (either implicitly as part of inlining or as a separate operation, as shown later in the talk) and ownership-convention optimization, as well as a few other things like specializing the callee for constant arguments (including constant function arguments for higher-order functions).

    In conversation about a year ago from hachyderm.io permalink
  17. Embed this notice
    John McCall (rjmccall@hachyderm.io)'s status on Friday, 14-Jun-2024 03:52:09 JST John McCall John McCall
    in reply to

    The compiler doesn't have to pop the frame with an add — if the function allocates dynamic amounts of memory, the compiler will generally save SP and store it back. But I believe the sub/add pattern is micro-architecturally favored for things like the OOO forwarding I mention above, so the compiler emits it when it can

    In conversation about a year ago from hachyderm.io permalink
  18. Embed this notice
    John McCall (rjmccall@hachyderm.io)'s status on Friday, 14-Jun-2024 03:52:08 JST John McCall John McCall
    in reply to

    All of this stuff about call frames is non-Swift-specific.

    In conversation about a year ago from hachyderm.io permalink
  19. Embed this notice
    John McCall (rjmccall@hachyderm.io)'s status on Friday, 14-Jun-2024 03:52:08 JST John McCall John McCall
    in reply to

    8:00 - This is slightly a lie in that the compiler doesn't always put separate variables in non-overlapping locations within the frame, the way a Swift or C struct would. Compilers do stack-slot coloring to reuse stack positions for variables whose lifetimes don't overlap. Values can also move within the stack if the compiler thinks that's a good idea. But understanding it as a C struct is a reasonable first approximation.

    In conversation about a year ago from hachyderm.io permalink
  20. Embed this notice
    John McCall (rjmccall@hachyderm.io)'s status on Friday, 14-Jun-2024 03:52:07 JST John McCall John McCall
    in reply to

    11:55 - Apple hardware is quite ARM64-dominant, so that's what I'm using as a base assumption throughout this talk, but of course the size and alignment of this type are target-depedent.

    In conversation about a year ago from hachyderm.io permalink
  • After
  • Before

User actions

    John McCall

    John McCall

    Language designer and implementer at Apple: Swift, Objective-C, C++, C. Erstwhile editor of the Itanium C++ ABI. Focus on security mitigations and low-level language implementation.

    Tags
    • (None)

    Following 0

      Followers 0

        Groups 0

          Statistics

          User ID
          111515
          Member since
          7 Apr 2023
          Notices
          51
          Daily average
          0

          Feeds

          • Atom
          • Help
          • About
          • FAQ
          • TOS
          • Privacy
          • Source
          • Version
          • Contact

          GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

          Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.