hirosystems / clarinet

Write, test and deploy high-quality smart contracts to the Stacks blockchain and Bitcoin.
https://hiro.so/clarinet
GNU General Public License v3.0
290 stars 129 forks source link

fix: improved sdk deployment plan handling and perf improvements #1437

Closed hugocaillard closed 2 months ago

hugocaillard commented 2 months ago

Description

Fix #1435

This PR started as a bug fix, but as I worked on it, I found that I could get massive perf improvements.

In the SDK init_session, some data is cached. Before this PR, just de deployment was cached. But the whole session can actually be cached. It reduces file system access by a lot (in a Vitest context, we now only need to read the manifest and contract once) and reduce the time spent parsing contracts.

On my machine (M1), the cached init_session go from more than 100ms to a few ms (the time taken for cache.clone()). And knowing that init_session is called before each test, it takes the time to run tests in a project like pox-4 testing down from 32sec to 6secs

It also reworks a bit the session and the SDK structs