Skip to content

Commit e5de328

Browse files
committed
Add rust-analyzer proc-macro server project
1 parent eab1c6c commit e5de328

File tree

1 file changed

+49
-6
lines changed

1 file changed

+49
-6
lines changed

README.md

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ We use the GSoC project size parameters for estimating the expected time complex
3737
- [Prototype Cargo plumbing commands](#prototype-cargo-plumbing-commands)
3838
- [Move cargo shell completions to Rust](#move-cargo-shell-completions-to-Rust)
3939
- [Build script delegation](#build-script-delegation)
40+
- **rust-analyzer**
41+
- [Implement a new proc-macro server RPC API](#proc-macro-rpc)
4042
- **Crate ecosystem**
4143
- [Modernize the libc crate](#Modernize-the-libc-crate)
4244
- [Add more lints to `cargo-semver-checks`](#add-more-lints-to-cargo-semver-checks)
@@ -257,7 +259,7 @@ Medium.
257259

258260
**Description**
259261

260-
Over the last year, support for automatic differentiation ('autodiff') was added to the Rust compiler. The autodiff tool which we are using ([Enzyme](https://enzyme.mit.edu/)) operates
262+
Over the last year, support for automatic differentiation ('autodiff') was added to the Rust compiler. The autodiff tool which we are using ([Enzyme](https://enzyme.mit.edu/)) operates
261263
on LLVM-IR, which is the intermediate representation of code, used by LLVM. LLVM is the default backend of the Rust compiler. Unfortunately, two layout related problems limit its usability.
262264

263265
A) The Rust compiler has a set of ABI optimizations which can improve performance, but make it harder for autodiff to work. An example is the function `fn foo(a: f32, b: f32) -> f32`,
@@ -267,7 +269,7 @@ If a function has a `#[rustc_autodiff]` attribute, the Rust compiler should simp
267269
Multiple examples of function headers which will get handled incorrectly at the moment are listed [here](https://github.com/EnzymeAD/rust/issues/105).
268270

269271
B) Enzyme requires good information about the memory layout of types, both to be able to differentiate the code, and to do so efficiently. In order to help Enzyme,
270-
we want to lower more Type Information from MIR or even THIR into LLVM-IR metadata, or make better usage of existing debug info. If you are interested in this part and
272+
we want to lower more Type Information from MIR or even THIR into LLVM-IR metadata, or make better usage of existing debug info. If you are interested in this part and
271273
also have some LLVM experience, please have a look at the LLVM website for the related proposal.
272274

273275
For both A) and B), the online compiler explorer [here](https://enzyme.mit.edu/explorer/) can be used to trigger both types of bugs, to get a feeling for existing problems.
@@ -310,11 +312,11 @@ Currently, the backend end (codegen part) of the compiler has been parallelized,
310312
The most important and valuable work in this area are two aspects:
311313

312314
A) Diagnosing and fixing deadlock [issues](https://github.com/rust-lang/rust/issues?q=is%3Aopen+label%3AWG-compiler-parallel+deadlock) caused by the execution order of compiler queries in a multithreaded environment.
313-
[Queries](https://rustc-dev-guide.rust-lang.org/query.html) is a unique design of the Rust compiler, which is used to achieve incremental compilation process. It divides the compiler
314-
process into various parts and caches the execution results of each part. However, queries caching dependencies between multiple threads may cause deadlock.
315+
[Queries](https://rustc-dev-guide.rust-lang.org/query.html) is a unique design of the Rust compiler, which is used to achieve incremental compilation process. It divides the compiler
316+
process into various parts and caches the execution results of each part. However, queries caching dependencies between multiple threads may cause deadlock.
315317
[`Work-stealing`](https://en.wikipedia.org/wiki/Work_stealing), a method used to improve parallelization performance, is the core reason.
316318

317-
To solve these problems, we need to find the part of the compiler process that causes deadlock through diagnosing coredumps in issues, and adjusting the execution order
319+
To solve these problems, we need to find the part of the compiler process that causes deadlock through diagnosing coredumps in issues, and adjusting the execution order
318320
of this part of code so that there will be no circular dependencies on the query caches between multiple threads. This [PR](https://github.com/rust-lang/rust/pull/118488) is a good example of solving a deadlock problem.
319321

320322
B) Improving the performance of the parallel frontend
@@ -611,6 +613,47 @@ Medium.
611613
- [Idea discussion](https://rust-lang.zulipchat.com/#narrow/channel/421156-gsoc/topic/Idea.3A.20Build.20script.20delegation)
612614
- Ed Page ([GitHub](https://github.com/epage), [Zulip](https://rust-lang.zulipchat.com/#narrow/dm/424212-Ed-Page))
613615

616+
## rust-analyzer
617+
618+
### Implement a new proc-macro server RPC API
619+
620+
**Description**
621+
622+
Today, rust-analyzer (and RustRover) is expand proc-macros by spawning a separate proc-macro server
623+
process that loads and executes the proc-macro dynamic libraries. They communicate to this process
624+
via a JSON RPC interface that has not been given much thought when it was implemented, now starting
625+
to show its limitations.
626+
627+
The goal is to replace this current implementation entirely in favor of a more performant format
628+
that also supports the more complicated needs of the proc-macro API.
629+
630+
**Expected result**
631+
632+
1. Replace the JSON format with [postcard](https://docs.rs/postcard/latest/postcard/)
633+
2. Replace the current client to server request-response RPC API with one that allows bidirectional
634+
request-response schemes.
635+
3. Implement multiplexing connections between a client and server (to potentially enable parallel
636+
proc-macro expansion).
637+
638+
**Desirable skills**
639+
640+
Intermediate knowledge of Rust.
641+
642+
**Project size**
643+
644+
Medium.
645+
646+
**Difficulty**
647+
648+
Medium.
649+
650+
**Mentor**
651+
- Lukas Wirth ([GitHub](https://github.com/veykril), [Zulip](https://rust-lang.zulipchat.com/#narrow/dm/300586-Lukas-Wirth))
652+
653+
**Zulip streams**
654+
- [Idea discussion](https://rust-lang.zulipchat.com/#narrow/channel/185405-t-compiler.2Frust-analyzer/topic/proc-macro.20server.20IPC.20format)
655+
- [rust-analyzer team](https://rust-lang.zulipchat.com/#narrow/channel/185405-t-compiler.2Frust-analyzer)
656+
614657
## Crate ecosystem
615658

616659
### Modernize the libc crate
@@ -833,5 +876,5 @@ Some of the work is medium. Diagnosing and / or fixing failures is often pretty
833876

834877
**Further resources**
835878

836-
- [Wild linker](https://github.com/davidlattimore/wild)
879+
- [Wild linker](https://github.com/davidlattimore/wild)
837880
- [Blog posts, most of which are about Wild](https://davidlattimore.github.io/)

0 commit comments

Comments
 (0)