about summary refs log tree commit diff
path: root/src/test/incremental/thinlto
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2018-08-19 21:25:08 -0700
committerAlex Crichton <alex@alexcrichton.com>2018-08-20 11:28:37 -0700
commit5bf2ad3018de1f5a94bed2685211f3694f94249c (patch)
treec9ca53fb9b49d99775cbe6e39a5319fd2ed6716a /src/test/incremental/thinlto
parent3ac79c718475fd29b8be34dde667b683390c2aee (diff)
downloadrust-5bf2ad3018de1f5a94bed2685211f3694f94249c.tar.gz
rust-5bf2ad3018de1f5a94bed2685211f3694f94249c.zip
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).
Diffstat (limited to 'src/test/incremental/thinlto')
0 files changed, 0 insertions, 0 deletions