Skip to content

Commit

Permalink
docs: add note about slow initialization times for ProverClient (#2023)
Browse files Browse the repository at this point in the history
  • Loading branch information
umadayal authored Feb 5, 2025
1 parent 489c56a commit dded41c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions book/docs/developers/common-issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,6 @@ The Rust compiler had breaking changes to its names of available options between
This message indicates that you're trying to use `sp1-build` < `4.0.0` with the 1.82 toolchain,
`sp1-build` versions >= 4.0.0 have support for the 1.82 and 1.81 toolchains.

## Slow `ProverClient` Initialization

You may encounter slow `ProverClient` initialization times as it loads necessary proving parameters and sets up the environment. It is recommended to initialize the `ProverClient` once and reuse it for subsequent proving operations. You can wrap the `ProverClient` in an `Arc` to share it across tasks.
2 changes: 2 additions & 0 deletions book/docs/generating-proofs/recommended-workflow.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Note that printing out the total number of executed cycles and the full executio

**Crate Setup:** We recommend that your program crate that defines the `main` function (around which you wrap the `sp1_zkvm::entrypoint!` macro) should be kept minimal. Most of your business logic should be in a separate crate (in the same repo/workspace) that can be tested independently and that is not tied to the SP1 zkVM. This will allow you to unit test your program logic without having to worry about the `zkvm` compilation target. This will also allow you to efficient reuse types between your program crate and your crate that generates proofs.

**Note:** The `ProverClient` should be initialized once and reused for subsequent proving operations rather than creating new instances. This is because the initial initialization may be slow as it loads necessary proving parameters and sets up the environment. You can wrap the `ProverClient` in an `Arc` to share it across tasks.

## Step 2: Generate proofs

After you have iterated on your program and finalized that it works correctly, you can generate proofs for your program for final end to end testing or production use.
Expand Down
3 changes: 3 additions & 0 deletions crates/sdk/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ use crate::network::builder::NetworkProverBuilder;
use crate::cuda::builder::CudaProverBuilder;

/// An entrypoint for interacting with the prover for the SP1 RISC-V zkVM.
///
/// IMPORTANT: `ProverClient` only needs to be initialized ONCE and can be reused for subsequent proving operations (can be shared across tasks by wrapping in an `Arc`).
/// Note that the initial initialization may be slow as it loads necessary proving parameters and sets up the environment.
pub struct ProverClient;

impl ProverClient {
Expand Down

0 comments on commit dded41c

Please sign in to comment.