445718084f
syntax: Optimize some literal parsing Currently in the `wasm-bindgen` project we have a very very large crate that's procedurally generated, `web-sys`. To generate this crate we parse all of a browser's WebIDL and we then generate bindings for all of the APIs contained within. The resulting Rust file is 18MB large (wow!) and currently takes a very long time to compile in debug mode. On the nightly compiler a *debug* build takes 90s for the crate to finish. I was curious what was taking so long and upon investigating a *massive* portion of the time was spent in the `lit_token` method of the compiler, primarily formatting strings via `format!`. Upon some more investigation it looks like the `byte_str_lit` was allocating an error message once per byte, causing a very large number of allocations to happen for large literals, of which wasm-bindgen generates quite a few (some are MB large). This commit fixes the issue by lazily allocating the error message, only doing so if the error message is actually needed (which should be never). As a result, the debug mode compilation time for our `web-sys` crate decreased from 90s to 20s, a very nice improvement! (although we've still got some work to do). |
||
---|---|---|
.. | ||
bootstrap | ||
build_helper | ||
ci | ||
dlmalloc@c99638dc2e | ||
doc | ||
etc | ||
grammar | ||
jemalloc@1f5a28755e | ||
liballoc | ||
liballoc_jemalloc | ||
liballoc_system | ||
libarena | ||
libbacktrace@f4d02bbdbf | ||
libcompiler_builtins@d549d85b17 | ||
libcore | ||
libfmt_macros | ||
libgraphviz | ||
liblibc@6bdbf5dc93 | ||
libpanic_abort | ||
libpanic_unwind | ||
libproc_macro | ||
libprofiler_builtins | ||
librustc | ||
librustc_allocator | ||
librustc_apfloat | ||
librustc_asan | ||
librustc_borrowck | ||
librustc_codegen_llvm | ||
librustc_codegen_utils | ||
librustc_cratesio_shim | ||
librustc_data_structures | ||
librustc_driver | ||
librustc_errors | ||
librustc_fs_util | ||
librustc_incremental | ||
librustc_lint | ||
librustc_llvm | ||
librustc_lsan | ||
librustc_metadata | ||
librustc_metadata_utils | ||
librustc_mir | ||
librustc_msan | ||
librustc_passes | ||
librustc_platform_intrinsics | ||
librustc_plugin | ||
librustc_privacy | ||
librustc_resolve | ||
librustc_save_analysis | ||
librustc_target | ||
librustc_traits | ||
librustc_tsan | ||
librustc_typeck | ||
librustdoc | ||
libserialize | ||
libstd | ||
libsyntax | ||
libsyntax_ext | ||
libsyntax_pos | ||
libterm | ||
libtest | ||
libunwind | ||
llvm@e19f07f5a6 | ||
llvm-emscripten@2717444753 | ||
rtstartup | ||
rustc | ||
rustllvm | ||
stdsimd@05c2f61c38 | ||
test | ||
tools | ||
Cargo.lock | ||
Cargo.toml | ||
README.md | ||
stage0.txt |
This directory contains the source code of the rust project, including:
rustc
and its testslibstd
- Various submodules for tools, like rustdoc, rls, etc.
For more information on how various parts of the compiler work, see the rustc guide.
Their is also useful content in the following READMEs, which are gradually being moved over to the guide:
- https://github.com/rust-lang/rust/tree/master/src/librustc/ty/query
- https://github.com/rust-lang/rust/tree/master/src/librustc/dep_graph
- https://github.com/rust-lang/rust/blob/master/src/librustc/infer/region_constraints
- https://github.com/rust-lang/rust/tree/master/src/librustc/infer/higher_ranked
- https://github.com/rust-lang/rust/tree/master/src/librustc/infer/lexical_region_resolve