Commit graph

20 commits

Author SHA1 Message Date
overlookmotel
ff43dff99d perf(sourcemap): speed up VLQ encoding (#4633)
Speed up source map VLQ encoding by removing a couple of operations from `serialize_mappings`'s hot loop.

On a local benchmark of just VLQ encoding, this change produces 5% performance increase (benchmarked on MacBook Pro M1).
2024-08-05 01:34:59 +00:00
overlookmotel
c7f1d48c0e perf(sourcemap): keep local copy of previous token in VLQ encode (#4596)
In source map VLQ encoding, keep local copy of previous `Token`, rather than looking up up from `tokens`.

On a local benchmark of just VLQ encoding, this change produces 6% performance increase (benchmarked on MacBook Pro M1).
2024-08-01 14:58:08 +00:00
overlookmotel
590d79530e perf(sourcemap): shorten main loop encoding VLQ (#4586)
Reduce number of operations in main loop in source map VLQ encoding.

#4583 made pushing a byte to output only 2 instructions, so that makes it workable to repeat `push_byte_unchecked` inside and outside the loop.

On a local benchmark of just VLQ encoding shows this increases performance by 16% (on top of the 11% from #4583).

Probably main gain is it makes a fast path for encoding `0`, which is common.
2024-08-01 12:21:26 +00:00
overlookmotel
d00014e4b5 perf(sourcemap): elide bounds checks in VLQ encoding (#4583)
In `oxc_sourcemap`'s VLQ encoding, avoid bounds checks when pushing bytes to the encoded string in the hot loop.

Those bounds checks are quite expensive as they involve a function call to `alloc::raw_vec::RawVec::grow_one`, and that happens on every single pushed byte.

https://godbolt.org/z/44G8jjss3

Not much difference on benchmarks, as VLQ encoding is only a small part of source map generation, but a local benchmark of just VLQ encoding shows this increases performance by 11%.
2024-08-01 08:34:15 +00:00
overlookmotel
7c42ffcd06
refactor(sourcemap): align Base64 chars lookup table to cache line (#4535)
Align the Base64 chars lookup table in sourcemap generator so it occupies a single cache line.
2024-07-30 04:28:10 +00:00
overlookmotel
27fd0628ef
refactor(sourcemap)!: avoid passing Results (#4541)
Refactor building sourcemap JSON to avoid passing `Result`s. `Serialize::serialize` is infallible here as writing to a `Vec<u8>` is infallible.
2024-07-30 04:23:49 +00:00
Brooooooklyn
1fd9dd0388
perf(sourcemap): use simd to escape JSON string (#4487)
Also optimize the memory allocation in string escape. The default size in `serde_json` is 1024 for String type, we pre allocate `string.len() * 2 + 2` for every string to reduce re-allocate in escaping.

I've tried to hand write SIMD implementation, but it's too complex, so I uses the `v_jsonescape` here. But it doesn't support `aarch64` and `wasm32` simd implementation, we need to contribute to it!
2024-07-29 12:42:21 +00:00
overlookmotel
5db7bed4f5 fix(sourcemap): fix pre-calculation of required segments for building JSON (#4490)
Fix the maths for calculating max number of segments required when building JSON source map.
2024-07-27 10:25:42 +00:00
overlookmotel
705e19f794 perf(sourcemap): reduce memory copies encoding JSON (#4489)
Reduce memory copies when encoding source map as JSON, extending approach taken in #4476 to also avoid memory copies for source texts.

I believe reason this shows no benefit on benchmarks is because our benchmarks only create a source map from a single source file, but it should result in a speed-up when there are multiple sources.
2024-07-27 10:25:40 +00:00
overlookmotel
c958a557fe refactor(sourcemap): push_list method for building JSON (#4486)
Follow up after #4476. Refactor to remove repeated code.
2024-07-27 10:25:38 +00:00
Brooooooklyn
4d10c6c9be
perf(sourcemap): pre allocate String buf while encoding (#4476)
I'm trying llama3.1:70b following [local-ai-copilot](https://developer.ibm.com/tutorials/awb-local-ai-copilot-ibm-granite-code-ollama-continue/) to find some potential performance improvement.

The code was not completed by AI; it only identified potential optimizations, which I am testing for effectiveness.
2024-07-26 13:58:09 +00:00
underfin
4cd5df00ea
fix(sourcemap): avoid negative line if token_chunks has same prev_dst_line (#4348) 2024-07-19 18:14:35 +08:00
underfin
d3cd3ea2de
feat: oxc transform binding (#3896)
closes #3877

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-06-26 21:57:19 +08:00
Boshen
051ceb6539
chore: improve some format by running cargo +nightly fmt 2024-06-19 00:48:30 +08:00
Boshen
899a52bf28
fix: fix some nightly warnings 2024-05-19 00:54:52 +08:00
Boshen
7363e14335
feat(sourcemap): add "rayon" feature (#3198) 2024-05-07 23:47:36 +08:00
underfin
8662f4f613
feat(sourcemap): add x_google_ignoreList (#2928) 2024-04-09 20:55:04 +08:00
underfin
5cb3991b67
feat(sourcemap): add sourceRoot (#2926) 2024-04-09 15:42:23 +08:00
underfin
28fae2e80a
fix(sourcemap): using serde_json::to_string to quote sourcemap string (#2889) 2024-04-03 12:14:45 +08:00
underfin
b199cb89a2
feat: add oxc sourcemap crate (#2825)
The sourcemap implement port from
[rust-sourcemap](https://github.com/getsentry/rust-sourcemap), but has
some different with it.

- Encode sourcemap at parallel, including quote `sourceContent` and
encode token to `vlq` mappings.
- Avoid `Sourcemap` some methods overhead, like `SourceMap::tokens()`
caused extra overhead at common cases. Here using `SourceViewToken` to
instead of it.
2024-03-28 19:36:38 +08:00