chore(build): document faster rebuilds with `cargo plonk` (#21823)

This commit is contained in:
Divy Srivastava 2024-01-06 16:27:04 +05:30 committed by GitHub
parent 7fbdc15f22
commit 1d46ee5129
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 71 additions and 0 deletions

71
tools/faster-rebuilds.md Normal file
View File

@ -0,0 +1,71 @@
# Faster rebuilds with [`cargo-plonk`](https://crates.io/crates/cargo-plonk)
This document describes how to use `cargo plonk` to speed up Deno rebuilds for
faster dev cycles.
```
cargo install cargo-plonk
```
## How it works
Plonk works by hot swapping symbols using a fresh dynamic library of the local
crates.
## Usage
First, compile Deno normally.
```
cargo build -p deno [--release]
```
Run the following command to start watching for changes in `ext/webgpu` crate
and hot swap `init_ops_and_esm` function into the previously built `deno` bin.
```
cargo plonk run \
--package deno_webgpu \
--symbol init_ops_and_esm \
--bin deno \
--watch
```
> Important:
>
> Currently, this will only works for symbols that have been "materialized" in
> their crates. Cross-crate generics will not work.
You can use `cargo plonk run` to re-run commands on changes.
```
cargo plonk run -v \
-p deno_webgpu \
-s init_ops_and_esm \
-b deno \
--watch \
-- eval "await navigator.gpu.requestAdapter()" --unstable
```
Comparing incremental compile times for `ext/webgpu` on Mac M1:
| profile | `cargo build` | `cargo plonk build` |
| --------- | ------------- | ------------------- |
| `debug` | 42 s | 0.5s |
| `release` | 5 mins 12 s | 2s |
## Debugging
Use the `-v`/`--verbose` flag to turn on debug info.
```
Finished dev [unoptimized + debuginfo] target(s) in 8.86s
[*] Running: DYLD_INSERT_LIBRARIES="/Users/divy/gh/plonk/target/release/build/cargo-plonk-dd0f08c90ca82109/out/inject.dylib" DYLD_LIBRARY_PATH="/Users/divy/.rustup/toolchains/1.75.0-aarch64-apple-darwin/lib" NEW_SYMBOL="_ZN11deno_webgpu11deno_webgpu16init_ops_and_esm17h683ed96f45027bc1E" PLONK_BINARY="/Users/divy/gh/deno/target/debug/deno" PLONK_LIBRARY="/Users/divy/gh/deno/target/debug/libdeno_webgpu.dylib" SYMBOL="_ZN11deno_webgpu11deno_webgpu16init_ops_and_esm17h6907fcd8be7e215eE" VERBOSE="y" "/Users/divy/gh/deno/target/debug/deno" "eval" "await navigator.gpu.requestAdapter()" "--unstable"
[*] Plonking _ZN11deno_webgpu11deno_webgpu16init_ops_and_esm17h6907fcd8be7e215eE in /Users/divy/gh/deno/target/debug/libdeno_webgpu.dylib
[*] Old address: 0x105fcff2c
[*] New address: 0x128511424
===
```
Report any bugs and feature requests in the `cargo-plonk` issue tracker:
https://github.com/littledivy/plonk/issues/new