feat(bls): add benchmarks for napi bls batching apis#8979
feat(bls): add benchmarks for napi bls batching apis#8979spiral-ladder wants to merge 3 commits intocayman/bls-verifierfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces new performance benchmarks for the BLS batching NAPI bindings. The primary goal is to measure and evaluate the efficiency of batch BLS signature verification operations, providing crucial data for performance optimization and understanding the overheads associated with different verification strategies. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces benchmarks for the BLS batching NAPI APIs, which is a valuable addition for performance monitoring. The new benchmarks cover various scenarios including indexed, single, and same-message verifications, both synchronously and asynchronously. The changes are well-structured and integrate smoothly with the existing benchmark suite.
|
|
||
| describe("BLS napi batching bindings", () => { | ||
| const maxKeys = 256; | ||
| blsBatch.init(40_000); |
There was a problem hiding this comment.
The number 40_000 used in blsBatch.init appears to be a magic number. It would improve readability and maintainability to define this value as a named constant, clearly indicating its purpose (e.g., MAX_BATCH_SIZE or INITIAL_CAPACITY).
| blsBatch.init(40_000); | |
| const maxKeys = 256; | |
| const BLS_BATCH_INITIAL_CAPACITY = 40_000; | |
| blsBatch.init(BLS_BATCH_INITIAL_CAPACITY); |
| beforeEach: () => linspace(0, count - 1).map((i) => getIndexedSet(i)), | ||
| fn: (sets) => { | ||
| const isValid = blsBatch.verify(blsBatch.indexed, sets); | ||
| if (!isValid) throw Error("Invalid"); |
There was a problem hiding this comment.
The error message "Invalid" is very generic. If a verification fails in a benchmark, a more descriptive error message would be beneficial for debugging. Consider including details like the id of the benchmark or the count of items being verified.
const isValid = blsBatch.verify(blsBatch.indexed, sets);
if (!isValid) throw Error(`Invalid verification for blsBatch.verify(indexed) with count ${count}`);| beforeEach: () => linspace(0, count - 1).map((i) => getSingleSet(i)), | ||
| fn: (sets) => { | ||
| const isValid = blsBatch.verify(blsBatch.single, sets); | ||
| if (!isValid) throw Error("Invalid"); |
There was a problem hiding this comment.
The error message "Invalid" is very generic. If a verification fails in a benchmark, a more descriptive error message would be beneficial for debugging. Consider including details like the id of the benchmark or the count of items being verified.
const isValid = blsBatch.verify(blsBatch.single, sets);
if (!isValid) throw Error(`Invalid verification for blsBatch.verify(single) with count ${count}`);| beforeEach: () => linspace(0, count - 1).map((i) => getIndexedSet(i)), | ||
| fn: async (sets) => { | ||
| const isValid = await blsBatch.asyncVerify(blsBatch.indexed, sets); | ||
| if (!isValid) throw Error("Invalid"); |
There was a problem hiding this comment.
The error message "Invalid" is very generic. If a verification fails in a benchmark, a more descriptive error message would be beneficial for debugging. Consider including details like the id of the benchmark or the count of items being verified.
const isValid = await blsBatch.asyncVerify(blsBatch.indexed, sets);
if (!isValid) throw Error(`Invalid verification for blsBatch.asyncVerify(indexed) with count ${count}`);| beforeEach: () => linspace(0, count - 1).map((i) => getSingleSet(i)), | ||
| fn: (sets) => { | ||
| const isValid = blsBatch.asyncVerify(blsBatch.single, sets); | ||
| if (!isValid) throw Error("Invalid"); |
There was a problem hiding this comment.
The error message "Invalid" is very generic. If a verification fails in a benchmark, a more descriptive error message would be beneficial for debugging. Consider including details like the id of the benchmark or the count of items being verified.
const isValid = blsBatch.asyncVerify(blsBatch.single, sets);
if (!isValid) throw Error(`Invalid verification for blsBatch.asyncVerify(single) with count ${count}`);| beforeEach: () => linspace(0, count - 1).map((i) => getSameMessageSet(i)), | ||
| fn: async (sets) => { | ||
| const isValid = await blsBatch.asyncVerifySameMessage(sets, seedMessage); | ||
| if (!isValid) throw Error("Invalid"); |
There was a problem hiding this comment.
The error message "Invalid" is very generic. If a verification fails in a benchmark, a more descriptive error message would be beneficial for debugging. Consider including details like the id of the benchmark or the count of items being verified.
const isValid = await blsBatch.asyncVerifySameMessage(sets, seedMessage);
if (!isValid) throw Error(`Invalid verification for blsBatch.asyncVerifySameMessage with count ${count}`);459fcf2 to
b0204dc
Compare
1ca773f to
928f48d
Compare
Add benchmarks for bls batching API.
Local run: