Skip to content

20231101

Compare
Choose a tag to compare
@cglogic cglogic released this 01 Nov 07:03
· 51 commits to main since this release
Optimize base::EscapeJSONString for ASCII inputs.

Most of the strings passed to this function are ASCII-only and
don't even need escaping. This CL provides fast-paths for these
cases.

This speeds up the generation of many JSON files written by GN.
For example, on a large Fuchsia build plan, this saves about 4
seconds while generating identical JSON outputs:

```
$ hyperfine --runs=5 '/tmp/gn1 gen --ide=json out/default --export-rust-project --export-compile-commands' '/tmp/gn3 gen --ide=json out/default --export-rust-project --export-compile-commands'
Benchmark 1: /tmp/gn1 gen --ide=json out/default --export-rust-project --export-compile-commands
  Time (mean ± σ):     28.883 s ±  0.836 s    [User: 117.852 s, System: 42.476 s]
  Range (min … max):   27.694 s … 29.916 s    5 runs

Benchmark 2: /tmp/gn2 gen --ide=json out/default --export-rust-project --export-compile-commands
  Time (mean ± σ):     24.829 s ±  0.590 s    [User: 112.068 s, System: 42.400 s]
  Range (min … max):   23.879 s … 25.296 s    5 runs

Summary
  '/tmp/gn3 gen --ide=json out/default --export-rust-project --export-compile-commands' ran
    1.16 ± 0.04 times faster than '/tmp/gn1 gen --ide=json out/default --export-rust-project --export-compile-commands'
```

Change-Id: I7f678f898a9e7f1d271ef8cb47ea77bb6d22800c
Reviewed-on: https://gn-review.googlesource.com/c/gn/+/16040
Commit-Queue: David Turner <[email protected]>
Reviewed-by: Takuto Ikuta <[email protected]>