sablier-labs / v2-periphery

🎛 Peripheral smart contracts for interacting with Sablier V2
https://docs.sablier.com
GNU General Public License v3.0
21 stars 7 forks source link

Add benchmark dir in tests #334

Closed smol-ninja closed 1 week ago

smol-ninja commented 2 months ago

Same as https://github.com/sablier-labs/v2-core/pull/908

PaulRBerg commented 2 weeks ago

it would be helpful to provide this, a user just asked about it

SCR-20240621-joyc
smol-ninja commented 2 weeks ago

Alright. Marked it as a higher priority

smol-ninja commented 1 week ago

Any suggestions on the benchmark table? I assumed that users might be more interested into understanding gas usage based on batch size rather than number of segments/tranches. The latter is already documented in the v2-core repo.

| Function                 | Lockup Type     | Segments/Tranches | Batch Size | Gas Usage |
| ------------------------ | --------------- | ----------------- | ---------- | --------- |
| `createWithDurationsLL`  | Lockup Linear   |                   | 2          | 361844    |
| `createWithTimestampsLL` | Lockup Linear   |                   | 2          | 324523    |
| `createWithDurationsLD`  | Lockup Dynamic  | 5                 | 2          | 608910    |
| `createWithTimestampsLD` | Lockup Dynamic  | 5                 | 2          | 578586    |
| `createWithDurationsLT`  | Lockup Tranched | 5                 | 2          | 601881    |
| `createWithTimestampsLT` | Lockup Tranched | 5                 | 2          | 572680    |
| `createWithDurationsLL`  | Lockup Linear   |                   | 5          | 734485    |
| `createWithTimestampsLL` | Lockup Linear   |                   | 5          | 732963    |
| `createWithDurationsLD`  | Lockup Dynamic  | 5                 | 5          | 1391832   |
| `createWithTimestampsLD` | Lockup Dynamic  | 5                 | 5          | 1368315   |
| `createWithDurationsLT`  | Lockup Tranched | 5                 | 5          | 1374272   |
| `createWithTimestampsLT` | Lockup Tranched | 5                 | 5          | 1353582   |
| `createWithDurationsLL`  | Lockup Linear   |                   | 10         | 1417161   |
| `createWithTimestampsLL` | Lockup Linear   |                   | 10         | 1414212   |
| `createWithDurationsLD`  | Lockup Dynamic  | 5                 | 10         | 2732969   |
| `createWithTimestampsLD` | Lockup Dynamic  | 5                 | 10         | 2686132   |
| `createWithDurationsLT`  | Lockup Tranched | 5                 | 10         | 2697702   |
| `createWithTimestampsLT` | Lockup Tranched | 5                 | 10         | 2656477   |
| `createWithDurationsLL`  | Lockup Linear   |                   | 20         | 2783678   |
| `createWithTimestampsLL` | Lockup Linear   |                   | 20         | 2778224   |
| `createWithDurationsLD`  | Lockup Dynamic  | 5                 | 20         | 5419557   |
| `createWithTimestampsLD` | Lockup Dynamic  | 5                 | 20         | 5326631   |
| `createWithDurationsLT`  | Lockup Tranched | 5                 | 20         | 5348503   |
| `createWithTimestampsLT` | Lockup Tranched | 5                 | 20         | 5266764   |
| `createWithDurationsLL`  | Lockup Linear   |                   | 50         | 6889015   |
| `createWithTimestampsLL` | Lockup Linear   |                   | 50         | 6877961   |
| `createWithDurationsLD`  | Lockup Dynamic  | 5                 | 50         | 13503395  |
| `createWithTimestampsLD` | Lockup Dynamic  | 5                 | 50         | 13276192  |
| `createWithDurationsLT`  | Lockup Tranched | 5                 | 50         | 13318736  |
| `createWithTimestampsLT` | Lockup Tranched | 5                 | 50         | 13124266  |

cc @sablier-labs/engineers.


Do we also want benchmark tables for MerkleLockupFactory and MerkleLL/LT contracts? IMO that should not be necessary since Airstream campaign creators are usually the companies which have very few incentive to care about transaction cost.

PaulRBerg commented 1 week ago

Yes, batch size should be more important than the number of segments/ tranches. Feedback:

smol-ninja commented 1 week ago
PaulRBerg commented 1 week ago

Let's do [5,10,20,30,50].

smol-ninja commented 1 week ago

I now remember why I avoided large number of segments with higher batch size. Because it exceeds, block gas limit. With 24 segments, its not feasible to have batch size of more than 30 in LD and LT.

| Function                 | Lockup Type     | Segments/Tranches | Batch Size | Gas Usage |
| ------------------------ | --------------- | ----------------- | ---------- | --------- |
| `createWithDurationsLL`  | Lockup Linear   |                   | 5          | 771013    |
| `createWithTimestampsLL` | Lockup Linear   |                   | 5          | 732772    |
| `createWithDurationsLD`  | Lockup Dynamic  | 24                | 5          | 3951599   |
| `createWithTimestampsLD` | Lockup Dynamic  | 24                | 5          | 3815274   |
| `createWithDurationsLT`  | Lockup Tranched | 24                | 5          | 3862661   |
| `createWithTimestampsLT` | Lockup Tranched | 24                | 5          | 3744535   |
| `createWithDurationsLL`  | Lockup Linear   |                   | 10         | 1417180   |
| `createWithTimestampsLL` | Lockup Linear   |                   | 10         | 1414248   |
| `createWithDurationsLD`  | Lockup Dynamic  | 24                | 10         | 7819162   |
| `createWithTimestampsLD` | Lockup Dynamic  | 24                | 10         | 7585613   |
| `createWithDurationsLT`  | Lockup Tranched | 24                | 10         | 7632113   |
| `createWithTimestampsLT` | Lockup Tranched | 24                | 10         | 7444113   |
| `createWithDurationsLL`  | Lockup Linear   |                   | 20         | 2783509   |
| `createWithTimestampsLL` | Lockup Linear   |                   | 20         | 2779081   |
| `createWithDurationsLD`  | Lockup Dynamic  | 24                | 20         | 15617207  |
| `createWithTimestampsLD` | Lockup Dynamic  | 24                | 20         | 15131248  |
| `createWithDurationsLT`  | Lockup Tranched | 24                | 20         | 15211892  |
| `createWithTimestampsLT` | Lockup Tranched | 24                | 20         | 14846363  |
| `createWithDurationsLL`  | Lockup Linear   |                   | 30         | 4143337   |
| `createWithTimestampsLL` | Lockup Linear   |                   | 30         | 4148585   |
| `createWithDurationsLD`  | Lockup Dynamic  | 24                | 30         | 23460912  |
| `createWithTimestampsLD` | Lockup Dynamic  | 24                | 30         | 22697560  |
| `createWithDurationsLT`  | Lockup Tranched | 24                | 30         | 22794686  |
| `createWithTimestampsLT` | Lockup Tranched | 24                | 30         | 22267335  |
| `createWithDurationsLL`  | Lockup Linear   |                   | 50         | 6871104   |
| `createWithTimestampsLL` | Lockup Linear   |                   | 50         | 6893873   |
| `createWithDurationsLD`  | Lockup Dynamic  | 24                | 50         | 39222140  |
| `createWithTimestampsLD` | Lockup Dynamic  | 24                | 50         | 37860731  |
| `createWithDurationsLT`  | Lockup Tranched | 24                | 50         | 37962234  |
| `createWithTimestampsLT` | Lockup Tranched | 24                | 50         | 37136749  |
smol-ninja commented 1 week ago

How about with batch size of 50, I change segments/tranches to 12 i.e. one year's worth of stream?

PaulRBerg commented 1 week ago

I change segments/tranches to 12 i.e. one year's worth of stream?

Sounds good!