Augmenting Mina O1JS with Performance Recording and Function-Level Profiling

This topic is to discuss the proposal submitted by @jmikedupont2 .Please see below for the details of the proposal and discussion.

15th October, 2024
Current status: Funded.
Funding Note: This proposal is approved for funding. We are happy to see the expansion of tooling to enable developers to build better, more efficient products on Mina. The funding is in line with the work proposed and risk is low.

5th October, 2024
Current status: Under Consideration.
Opened for community discussion on : 5th September,2024

2 Likes

First posted here mina-snarky-o1js-zkapp-introspector/proposals/grant1/monitoring/clinic-js.md at 285799dd527b343928097b1523e587b74e2c839b · meta-introspector/mina-snarky-o1js-zkapp-introspector · GitHub and then here Navigators Season 2: Growth Grants Proposal Template - HackMD

Title

Proposal Title: Augmenting O1JS TypeScript npm Test Job with Performance Recording and Function-Level Profiling

Project Background

The project aims to enhance the testing infrastructure of the o1js mina TypeScript application by integrating performance recording and function-level profiling within a Docker container started by Docker Compose in github actions. This will enable developers to identify performance bottlenecks and optimize their code more effectively with no setup costs. The current setup involves running tests using npm, but lacks detailed performance insights and is not reproducible in different contexts. This proposal seeks to address this gap by leveraging profiling tools like clinic for javascript level profiling and perf for os level profiling. Work on Reporting is being done to browse the resulting data. We have already worked on this project for a while and have reports we can show, currently working on optimizing the reporting and presentation of the many results.

Proposal Overview

Problem: Mina suffers from memory leaks, performance issues and lack of instrumentation and reporting on performance and testing of the codebase on multiple platforms. The current testing setup lacks detailed performance insights, making it difficult to identify and address performance bottlenecks. The performance insights also helps the developer understand the process better in terms of cause and effect. Currently the github actions that run tests are specific to github and difficult to reproduce. The running of performance tests is not currently not really reproducible out of the box or standardized. We want to allow for developers to easily integrate these reports into thier forks and branches and share results with other developers and to reason about performance metrics together.

Solution: Integrate performance recording and function-level profiling using clinic. For reproducibility we do this within the Docker container started by Docker Compose in a github action.

Impact: This proposal will significantly enhance the Mina ecosystem by providing developers with improved tools for performance analysis, encouraging adoption, and attracting more users and developers. It will enable novel applications by facilitating better performance optimization.

Audience: The target audience for this project includes developers and teams working on TypeScript osi1 zkapps applications within the Mina ecosystem. The techniques of using perf can be extended to server side rust and ocaml code as well.

Architecture & Design

Detailed Design/Architecture:
The proposed solution involves updating the Dockerfile to install necessary profiling tools, modifying the Docker Compose configuration to include profiling commands, and updating test scripts to run with profiling.

  1. Dockerfile and compose update:
    We have already created a dockerfile for o1js and demonstrated that we can collect strace.
    The docker compose runs in a github action.

  2. Test Script Update:

We will use the GitHub - dfloresc/clinicjs-pipeline: ClinicJS pipeline for Github actions to augument the mina o1js code in the first step.
The following steps can expand with more detailed performance monitoring.

Vision: The long-term vision for this project is to create a robust testing framework that provides detailed performance insights, enabling developers to build highly optimized applications within the Mina ecosystem.
It also will help extract knowledge from the o1js codebase for the following step, providing valuable intermediates.

Existing Work:
There has been work in benchmarking parts of the system but this proposal aims to target holistic improvement.
now strace written to /tmp · meta-introspector/o1js@def00a1 · GitHub This run demonstrates
the running of part of the o1js test framework in github and collecting performance traces with strace as a simple
example.

Production Timeline:

The project is expected to be in production within 1 week.

Budget & Milestones

Deliverables:

  • Updated Dockerfile with profiling tools installed.
  • Modified Docker Compose configuration to include profiling commands.
  • Updated test scripts to run with profiling.
  • Documentation on how to use the profiling tools.

Mid-Point Milestones:

  • Completion of Dockerfile and Docker Compose updates.
  • Initial testing of profiling setup.
  • Preliminary documentation.

Project Timeline: 1M

  • Budget Requested : 20,000 MINA
  • Budget Breakdown:
    • Development: 10,000 MINA
    • Testing and QA: 4,000 MINA
    • Documentation: 2,000 MINA
    • Contingency: 4,000 MINA

Wallet Address:
Coinbase Wallet B62qqFdiPRuMuQQYYo131saW1fp4f72rKXLVy2KTQEtnJzg5Hz3SqEY

Team Info

Proposer Github: jmikedupont2 (Mike DuPont) · GitHub

Proposer Experience: The proposer has experience building github pipelines and performance tuning.

Team Members:

Achievements:

  • Successfully developed and deployed docker build already.
  • Studied the ocaml of mina, the parts of the rust of pasta
  • Studied the o1js of mina

Risks & Mitigations

Risks:

  • Integration issues with profiling tools.
  • Performance overhead introduced by profiling.
  • Delivery of the results

Mitigations:

  • Thorough testing and validation of profiling tools.
  • Optimization of profiling setup to minimize performance impact.
  • Regular communication with the community for feedback and support.
  • Usage of accepted and standard tools for profiling nodejs

Related proposals:

Core-Grants/RFCs/rfc-0010-meta-introspector.md at eb2379d95f6aee3c5ee71b85699316dca37d6834 · meta-introspector/Core-Grants · GitHub is the larger idea.

1 Like

This proposal is approved for funding. We are happy to see the expansion of tooling to enable developers to build better, more efficient products on Mina. The funding is in line with the work proposed and risk is low.

1 Like

Thank you very much. I will work with the team on making mina faster, better and more observable!

3 Likes

Status update:

Created test reporting system for o1js to record prof,cpu-prof,heap-prof perf results in git artifacts with minimal changes.
Build o1js · jmikedupont2/o1js@1a6adaa · GitHub you need to be logged into github see currently, we will be pushing results to hugging face later for easier reporting. Also have been working on zkcloudworker tests to test with many different versions of o1js from the last 30 days all forks of o1js.

2 Likes