Commit 13c5abf
authored
perf: avoid cloning CPU witness MLEs (#1342)
## Problem
left-over from #923. CPU trace
commit cloned large witness MLEs before proving, adding avoidable memory
traffic on the prover hot path.
## Design Rationale
Keep committed witness MLEs behind `Arc` and drain/transport ownership
where possible, avoiding deep clones without changing proof semantics.
## Change Highlights
- `ceno_zkvm`: return `Arc` witness MLEs from trace commit and consume
structural MLEs during transport.
- `ceno_zkvm`: keep GPU trait shape aligned while preserving existing
GPU behavior.
## Benchmark / Performance Impact
### Operation
| Operation | master (s) | this PR (s) | Improve (master -> this PR) |
|-----------|------------|-------------|-----------------------------|
| CPU proving, keccak e2e shard total | 6.942 | 6.596 | 4.98% faster |
| GPU proving, keccak e2e shard total | 1.191 | 1.186 | 0.44% faster |
### Layer
| Layer | master (s) | this PR (s) | Improve (master -> this PR) |
|-------|------------|-------------|-----------------------------|
| N/A: shard-level proving total measured | N/A | N/A | no regression
observed |
Benchmark command(s):
```sh
cargo run --config net.git-fetch-with-cli=true --release --package ceno_zkvm --bin e2e -- --platform=ceno --max-cycle-per-shard=1600 examples/target/riscv32im-ceno-zkvm-elf/release/examples/keccak_syscall
cargo run --config net.git-fetch-with-cli=true --features gpu --release --package ceno_zkvm --bin e2e -- --platform=ceno --max-cycle-per-shard=1600 examples/target/riscv32im-ceno-zkvm-elf/release/examples/keccak_syscall
```
Environment: local x86_64 Linux, release build, local
`../ceno-gpu/cuda_hal` patch for GPU validation.
raw data:
- master: CPU shards `3.272s + 3.670s`; GPU shards `0.624s + 0.568s`
- this PR: CPU shards `3.336s + 3.260s`; GPU shards `0.593s + 0.593s`
## Testing
```sh
cargo check --config net.git-fetch-with-cli=true --package ceno_zkvm --bin e2e
cargo run --config net.git-fetch-with-cli=true --release --package ceno_zkvm --bin e2e -- --platform=ceno --max-cycle-per-shard=1600 examples/target/riscv32im-ceno-zkvm-elf/release/examples/keccak_syscall
cargo run --config net.git-fetch-with-cli=true --features gpu --release --package ceno_zkvm --bin e2e -- --platform=ceno --max-cycle-per-shard=1600 examples/target/riscv32im-ceno-zkvm-elf/release/examples/keccak_syscall
```
## Risks and Rollout
Low risk: prover-side ownership change only. Rollback is reverting the
`Arc` witness-MLE plumbing.
## Follow-ups (optional)
None.
## Copilot Reviewer Directive (keep this section)
When Copilot reviews this PR, apply `.github/copilot-instructions.md`
strictly.1 parent a19018a commit 13c5abf
4 files changed
Lines changed: 19 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
558 | 558 | | |
559 | 559 | | |
560 | 560 | | |
561 | | - | |
| 561 | + | |
562 | 562 | | |
563 | 563 | | |
564 | 564 | | |
| |||
576 | 576 | | |
577 | 577 | | |
578 | 578 | | |
579 | | - | |
580 | | - | |
581 | | - | |
582 | | - | |
| 579 | + | |
583 | 580 | | |
584 | 581 | | |
585 | 582 | | |
586 | 583 | | |
587 | 584 | | |
588 | 585 | | |
589 | | - | |
| 586 | + | |
590 | 587 | | |
591 | 588 | | |
592 | 589 | | |
593 | 590 | | |
594 | | - | |
| 591 | + | |
595 | 592 | | |
596 | 593 | | |
597 | 594 | | |
| |||
1524 | 1521 | | |
1525 | 1522 | | |
1526 | 1523 | | |
1527 | | - | |
| 1524 | + | |
1528 | 1525 | | |
1529 | | - | |
| 1526 | + | |
1530 | 1527 | | |
1531 | 1528 | | |
1532 | 1529 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1670 | 1670 | | |
1671 | 1671 | | |
1672 | 1672 | | |
1673 | | - | |
| 1673 | + | |
1674 | 1674 | | |
1675 | 1675 | | |
1676 | 1676 | | |
| |||
1811 | 1811 | | |
1812 | 1812 | | |
1813 | 1813 | | |
1814 | | - | |
| 1814 | + | |
1815 | 1815 | | |
1816 | 1816 | | |
1817 | 1817 | | |
| |||
3625 | 3625 | | |
3626 | 3626 | | |
3627 | 3627 | | |
3628 | | - | |
| 3628 | + | |
3629 | 3629 | | |
3630 | 3630 | | |
3631 | | - | |
3632 | | - | |
| 3631 | + | |
| 3632 | + | |
3633 | 3633 | | |
3634 | 3634 | | |
3635 | 3635 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
| 120 | + | |
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
| 128 | + | |
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| |||
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
283 | | - | |
| 283 | + | |
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
476 | 476 | | |
477 | 477 | | |
478 | 478 | | |
479 | | - | |
| 479 | + | |
480 | 480 | | |
481 | 481 | | |
482 | 482 | | |
| |||
490 | 490 | | |
491 | 491 | | |
492 | 492 | | |
493 | | - | |
| 493 | + | |
| 494 | + | |
494 | 495 | | |
495 | 496 | | |
496 | 497 | | |
| |||
894 | 895 | | |
895 | 896 | | |
896 | 897 | | |
897 | | - | |
| 898 | + | |
898 | 899 | | |
899 | 900 | | |
900 | 901 | | |
| |||
967 | 968 | | |
968 | 969 | | |
969 | 970 | | |
970 | | - | |
| 971 | + | |
971 | 972 | | |
972 | 973 | | |
973 | 974 | | |
| |||
0 commit comments