Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce RPC overhead for common proc_macro operations #86822

Closed
wants to merge 11 commits into from

Commits on Jun 15, 2022

  1. Configuration menu
    Copy the full SHA
    7678e6a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    1793ee0 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    cc698dc View commit details
    Browse the repository at this point in the history
  4. proc_macro: cache static spans in client's thread-local state

    This greatly improves the performance of the very frequently called
    `call_site()` macro when running in a cross-thread configuration.
    mystor committed Jun 15, 2022
    Configuration menu
    Copy the full SHA
    8315ce9 View commit details
    Browse the repository at this point in the history
  5. proc_macro: reduce the number of messages required to create, extend,…

    … and iterate TokenStreams
    
    This significantly reduces the cost of common interactions with TokenStream
    when running with the CrossThread execution strategy, by reducing the number of
    RPC calls required.
    mystor committed Jun 15, 2022
    Configuration menu
    Copy the full SHA
    29d8b9c View commit details
    Browse the repository at this point in the history
  6. proc_macro: stop using a remote object handle for Punct

    This greatly reduces round-trips to fetch relevant extra information about the
    token in proc macro code, and avoids RPC messages to create Punct tokens.
    mystor committed Jun 15, 2022
    Configuration menu
    Copy the full SHA
    801c77b View commit details
    Browse the repository at this point in the history
  7. proc_macro: stop using a remote object handle for Group

    This greatly reduces round-trips to fetch relevant extra information about the
    token in proc macro code, and avoids RPC messages to create Group tokens.
    mystor committed Jun 15, 2022
    Configuration menu
    Copy the full SHA
    ff17109 View commit details
    Browse the repository at this point in the history
  8. proc_macro: stop using a remote object handle for Ident

    This requires a dependency on `unicode-normalization` and `rustc_lexer`, which
    is currently not possible for `proc_macro`. Instead, a second `extern "C" fn`
    is provided by the compiler server to perform these steps from any thread.
    
    String values are interned in both the server and client, meaning that
    identifiers can be stringified without any RPC roundtrips without substantially
    inflating their size.
    
    RPC messages passing symbols include the full un-interned value, and are
    re-interned on the receiving side. This could potentially be optimized in the
    future.
    
    The symbol infrastructure will alwo be used for literals in a following part.
    mystor committed Jun 15, 2022
    Configuration menu
    Copy the full SHA
    67bd424 View commit details
    Browse the repository at this point in the history
  9. proc_macro: stop using a remote object handle for Literal

    This builds on the symbol infrastructure built for ident to replicate the
    `LitKind` and `Lit` structures in rustc within the `proc_macro` client,
    allowing literals to be fully created and interacted with from the client
    thread. Only parsing and subspan operations still require sync RPC.
    mystor committed Jun 15, 2022
    Configuration menu
    Copy the full SHA
    dd916c7 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    6a0962f View commit details
    Browse the repository at this point in the history
  11. Try to reduce codegen complexity of TokenStream's FromIterator and Ex…

    …tend impls
    
    This is an experimental patch to try to reduce the codegen complexity of
    TokenStream's FromIterator and Extend implementations for downstream
    crates, by moving the core logic into a helper type. This might help
    improve build performance of crates which depend on proc_macro as
    iterators are used less, and the compiler may take less time to do
    things like attempt specializations or other iterator optimizations.
    
    The change intentionally sacrifices some optimization opportunities,
    such as using the specializations for collecting iterators derived from
    Vec::into_iter() into Vec.
    
    This is one of the simpler potential approaches to reducing the amount
    of code generated in crates depending on proc_macro, so it seems worth
    trying before other more-involved changes.
    mystor committed Jun 15, 2022
    Configuration menu
    Copy the full SHA
    fea1d01 View commit details
    Browse the repository at this point in the history