Skip to content

Commit

Permalink
docs: add benchmarks page (#889)
Browse files Browse the repository at this point in the history
* docs(docs): add benchmarks page to the docs

re #815

* chore(docs): update the docusaurus version
  • Loading branch information
vplasencia authored Oct 30, 2024
1 parent c67b888 commit 9b419f0
Show file tree
Hide file tree
Showing 19 changed files with 2,116 additions and 654 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"format:write": "remark ./**/*.mdx --output"
},
"dependencies": {
"@docusaurus/core": "3.1.1",
"@docusaurus/preset-classic": "3.1.1",
"@docusaurus/core": "3.5.2",
"@docusaurus/preset-classic": "3.5.2",
"@mdx-js/react": "^3.0.0",
"@semaphore-protocol/utils": "4.5.0",
"@svgr/webpack": "^5.5.0",
Expand All @@ -31,8 +31,8 @@
"url-loader": "^4.1.1"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "3.1.1",
"@docusaurus/tsconfig": "3.1.1",
"@docusaurus/module-type-aliases": "3.5.2",
"@docusaurus/tsconfig": "3.5.2",
"@types/react": "^18.2.29",
"remark-cli": "^12.0.0",
"remark-frontmatter": "^5.0.0",
Expand Down
131 changes: 131 additions & 0 deletions apps/docs/versioned_docs/version-V4/benchmarks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
---
sidebar_position: 8
---

# Benchmarks

Semaphore v4 introduces new features and performance improvements. Detailed changes are available in the [release changelog](https://github.com/semaphore-protocol/semaphore/releases/tag/v4.0.0).

The primary changes in benchmark values are driven by the two major protocol updates:

- New [Identity schema](https://github.com/semaphore-protocol/semaphore/tree/main/packages/identity).

- [LeanIMT](https://github.com/privacy-scaling-explorations/zk-kit/tree/main/packages/lean-imt): New optimized IMT.

## New Identity schema

Semaphore v4 includes a new schema for the identities allowing the creation and verification of signatures.

Although the new Identity package is slightly slower than the one in Semaphore v3 (by just a few milliseconds), the trade-off is minimal considering the included functionality.

The new identity schema adds additional constraints to the Semaphore v4 circuit; however, this does not negatively impact overall performance of the protocol.

## LeanIMT

Semaphore v4 uses the LeanIMT data structure for group operations, an improvement over the IMT used in v3.

For further details, see the [LeanIMT paper](https://github.com/privacy-scaling-explorations/zk-kit/tree/main/papers/leanimt).

The LeanIMT offers dynamic depth, resulting in faster and more cost-effective group operations, across Node.js, browser and smart contracts.

Semaphore v4 support tree depths from 1 to 32, while v3 supports depths from 16 to 32, both for proof generation and verification.

## System Specifications and Software environment

All the benchmarks were run in an environment with these properties:

**System Specifications**

Computer: MacBook Pro

Chip: Apple M2 Pro

Memory (RAM): 16 GB

Operating System: macOS Sequoia version 15.0.1

**Software environment**

Node.js version: 20.18.0

Browser: Google Chrome Version 130.0.6723.92 (Official Build) (arm64)

## Running the benchmarks

### Javascript and Circom

GitHub repository to the run Node.js, browser and Circom benchmarks: https://github.com/vplasencia/semaphore-benchmarks

### Solidity

GitHub repository to run the Solidity benchmarks: https://github.com/semaphore-protocol/semaphore

## Node.js benchmarks

### Identities

![Identities](../../assets/img-benchmarks/node/identity-node-benchmarks.png)

### Create Group

Create group, either empty or with initial members.

![Create Group](../../assets/img-benchmarks/node/create-group-node-benchmarks.png)

### Add Member

Add a member to groups with different sizes.

![Add Member](../../assets/img-benchmarks/node/add-member-node-benchmarks.png)

### Generate Proof

Generate a proof using groups with different numbers of members.

![Generate Proof](../../assets/img-benchmarks/node/generate-proof-node-benchmarks.png)

### Verify Proof

Verify a proof using groups with different numbers of members.

![Verify Proof](../../assets/img-benchmarks/node/verify-proof-node-benchmarks.png)

## Browser benchmarks

Main functions used in the browser.

![Browser benchmarks](../../assets/img-benchmarks/browser/browser-benchmarks.png)

## Circuit benchmarks

### Semaphore V3

<img
src={require('../../assets/img-benchmarks/circuits/semaphore-v3-circuits-benchmarks.png').default}
alt="Circuit benchmarks Semaphore v3"
style={{ width: '300px', height: 'auto' }}
/>

### Semaphore V4

<img
src={require('../../assets/img-benchmarks/circuits/semaphore-v4-circuits-benchmarks.png').default}
alt="Circuit benchmarks Semaphore v4"
style={{ width: '300px', height: 'auto' }}
/>

## Contracts

<img
src={require('../../assets/img-benchmarks/contracts/contract-benchmarks.png').default}
alt="Contract Benchmarks"
style={{ width: '590px', height: 'auto' }}
/>

### Semaphore V3 gas report

![Contracts benchmarks Semaphore v3](../../assets/img-benchmarks/contracts/semaphore-v3-contracts-benchmarks.png)

### Semaphore V4 gas report

![Contracts benchmarks Semaphore v4](../../assets/img-benchmarks/contracts/semaphore-v4-contracts-benchmarks.png)
2 changes: 1 addition & 1 deletion apps/docs/versioned_docs/version-V4/credits.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 12
sidebar_position: 13
---

# Credits
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/versioned_docs/version-V4/faq.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 11
sidebar_position: 12
---

# FAQ
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/versioned_docs/version-V4/glossary.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 8
sidebar_position: 9
---

# Glossary
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/versioned_docs/version-V4/resources.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 9
sidebar_position: 10
---

import Articles from '@site/src/components/Articles';
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/versioned_docs/version-V4/troubleshooting.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 10
sidebar_position: 11
---

import Tabs from "@theme/Tabs"
Expand Down
Loading

0 comments on commit 9b419f0

Please sign in to comment.