Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: store seed command in stress test CLI #657

Merged
merged 69 commits into from
Mar 25, 2025

Conversation

SantiagoPittella
Copy link
Collaborator

@SantiagoPittella SantiagoPittella commented Jan 29, 2025

@bobbinth i'm applying your suggestion of a new structure (your comment here). The only thing I changed is that I create all the accounts before hand.

I added some queries to check the size of each table, and the avg size of each entry in every table. This is the current output of the binary:

For example, this is the current output for 100k accounts:

Creating new faucet account...
Generated 100000 accounts in 19.377 seconds
Creating notes...
Created notes: inserted 393 blocks with avg insertion time 641 ms
Store file size every 50 blocks:
Block 0: 4096 bytes
Block 50: 2645048 bytes
Block 100: 72965512 bytes
Block 150: 137780152 bytes
Block 200: 201362360 bytes
Block 250: 264911800 bytes
Block 300: 328420280 bytes
Block 350: 392027064 bytes
Block 400: 455551928 bytes
Average growth rate: 1159154.7888040713 bytes per blocks
Total time: 274.344 seconds
DB Stats for account_deltas: 4096 bytes, 4096.0 bytes/entry
DB Stats for block_headers: 122880 bytes, 311.088607594937 bytes/entry
DB Stats for account_fungible_asset_deltas: 4096 bytes,  bytes/entry
DB Stats for notes: 460816384 bytes, 4608.16384 bytes/entry
DB Stats for account_non_fungible_asset_updates: 4096 bytes,  bytes/entry
DB Stats for nullifiers: 4370432 bytes, 43.7218087234894 bytes/entry
DB Stats for account_storage_map_updates: 4096 bytes,  bytes/entry
DB Stats for settings: 4096 bytes, 2048.0 bytes/entry
DB Stats for account_storage_slot_updates: 4096 bytes, 1365.33333333333 bytes/entry
DB Stats for transactions: 5644288 bytes, 56.244337488665 bytes/entry
DB Stats for accounts: 6062080 bytes, 60.6438446609712 bytes/entry

This PR was built on top of #621 .

@TomasArrachea TomasArrachea force-pushed the santiagopittella-stress-testing-copy branch from c749355 to ba71858 Compare March 18, 2025 17:50
Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you! I left some more comments inline - but they are pretty minor.

Also, would be great to see how the latest output looks like.

note::create_p2id_note,
utils::Serializable,
};
use miden_node_block_producer::store::StoreClient;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to get the store client w/o going through the block producer? I wonder if #723 changes this. cc @Mirko-von-Leipzig.

Copy link
Contributor

@Mirko-von-Leipzig Mirko-von-Leipzig Mar 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The block producer's StoreClient is a somewhat thin wrapper around the generated store client from miden-node-proto. Notably it does some additional domain type translations.

At present #723 doesn't change this - its primarily just about changing how we distribute the raw proto files at the moment.

In the short term exposing this StoreClient is the simplest route unfortunately, or alternatively just using the generated store client - which would essentially duplicate the code I imagine.

Perhaps in the medium term we should focus on moving all client/store wrappers into the crate with the domain types. So one crate for accessing the raw proto definitions, and another for internal use with nicer domain types.

The issue with the latter is how do we allow for extensions, e.g. enabling open-telemetry, TLS etc. Its possible I'm sure, but I find the tonic docs and naming to be confusing so its not immediately obvious to me how this works.

Another issue with moving the wrappers is that all domain types would need to live in this proto crate i.e. we cannot use types from miden-node-store, miden-node-block-producer etc, so those all have to move across. Which may or may not be fine. A lot of them are already there so perhaps its not such an issue.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, as for now this is the simplest way to interact with the Store. I agree it would make sense to, at some point, have the StoreClient declared as a domain type, but it's probably better to do that it in a separate PR.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another issue with moving the wrappers is that all domain types would need to live in this proto crate i.e. we cannot use types from miden-node-store, miden-node-block-producer etc, so those all have to move across. Which may or may not be fine. A lot of them are already there so perhaps its not such an issue.

At least for the store, this would require moving the StoreErrors. Besides that, I think most of these types are shared from miden-objects and it wouldn't be a problem.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd love to make to so that stress-test does not depend on the block producer, but we can do this in the future. Let's create an issue for this.

@TomasArrachea
Copy link
Collaborator

This is how the latest output looks:

Total time: 224.065 seconds
Inserted 393 blocks with avg insertion time 186 ms
Initial DB size: 100.6 KB
Average DB growth rate: 550.4 KB per block

Block metrics:
Block #    Insert Time (ms)     Get Block Inputs Time (ms)     Get Batch Inputs Time (ms)     Block Size (B)       DB Size (KB)
---------------------------------------------------------------------------------------------------------------------------------------
0          23                   1                              1                              331726               655.8
50         161                  15                             6                              360558               36633.7
100        169                  19                             11                             360558               67867.1
150        177                  24                             16                             360558               97527.1
200        190                  29                             22                             360558               127275.1
250        194                  38                             28                             360558               156923.1
300        203                  37                             33                             360558               186671.1
350        211                  41                             38                             360558               216427.1

Database stats:
Table                               Size (KB)       KB/Entry
----------------------------------------------------------------------
account_deltas                      4.0             -
block_headers                       120.0           0.3
account_fungible_asset_deltas       4.0             -
notes                               200932.0        2.0
account_non_fungible_asset_updates  4.0             -
nullifiers                          4268.0          0.0
account_storage_map_updates         4.0             -
settings                            4.0             2.0
account_storage_slot_updates        4.0             -
transactions                        5512.0          0.1
accounts                            5920.0          0.1

@TomasArrachea TomasArrachea requested a review from bobbinth March 19, 2025 19:37
Copy link
Collaborator Author

@SantiagoPittella SantiagoPittella left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found some .unwraps throughout the CLI, those might be replaced with .expect.

Can not give an approve because I opened up this PR, but in general looks good 👌🏼 .

Comment on lines 70 to 73
/// Creates and stores blocks into the store. Creates a given number of accounts, where each account
/// consumes a note created from a faucet. The cli accepts the following parameters:
/// - `data_directory`: Directory in which to store the database and raw block data.
/// - `num_accounts`: Number of accounts to create.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doc looks unnecessary, it is from the command defined above.

let start = Instant::now();

let genesis_filepath = data_directory.join(GENESIS_STATE_FILENAME);
let database_filepath = data_directory.join("miden-store.sqlite3");
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be extracted into a constant.

Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you! I left a couple of small comments inline.

Before merging, we should rebase it from the latest next and make sure things still work. Also, could we run account generation for 1M accounts? Should take a bit less then an hour, right?

note::create_p2id_note,
utils::Serializable,
};
use miden_node_block_producer::store::StoreClient;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd love to make to so that stress-test does not depend on the block producer, but we can do this in the future. Let's create an issue for this.

@igamigo
Copy link
Collaborator

igamigo commented Mar 24, 2025

I tested this while I did a bunch of things (I even went into the DB a bunch of times to check progress, so probably not very representative results), and I got ~2.5 hours:

cargo run --release -- seed-store --data-directory ./data --num-accounts 1000000

Total time: 9388.023 seconds
Inserted 3922 blocks with avg insertion time 1400 ms
Initial DB size: 136.8 KB
Average DB growth rate: 648.8 KB per block

Block metrics:
Block #    Insert Time (ms)     Get Block Inputs Time (ms)     Get Batch Inputs Time (ms)     Block Size (B)       DB Size (KB)
---------------------------------------------------------------------------------------------------------------------------------------
0          26                   1                              1                              331726               736.3
50         182                  12                             1                              360558               40818.9
100        196                  13                             1                              360558               72946.9
150        212                  19                             1                              360558               105565.3
200        210                  14                             1                              360558               138601.4
250        226                  18                             1                              360558               171476.8
300        241                  16                             1                              360558               204150.5
350        232                  25                             1                              360558               236788.5
400        247                  19                             1                              360558               269112.9
450        260                  25                             1                              360558               301694.4
500        247                  20                             1                              360558               333963.0
550        282                  61                             1                              360558               366640.2
600        327                  26                             3                              360558               398888.4
650        390                  69                             4                              360558               431577.9
700        367                  58                             2                              360558               463869.9
750        321                  83                             2                              360558               495969.9
800        358                  148                            2                              360558               528587.3
850        408                  68                             5                              360558               561151.3
900        306                  76                             2                              360558               593479.3
950        389                  77                             3                              360558               625611.7
1000       391                  104                            2                              360558               658067.7
1050       537                  246                            4                              360558               690191.8
1100       862                  87                             13                             360558               722636.1
1150       399                  142                            2                              360558               754956.4
1200       3572                 610                            26                             360558               787328.6
1250       425                  64                             2                              360558               819772.6
1300       552                  37                             5                              360558               852409.0
1350       704                  160                            17                             360558               884429.0
1400       693                  180                            3                              360558               916637.1
1450       1195                 141                            3                              360558               949362.4
1500       713                  357                            3                              360558               981558.4
1550       1054                 262                            3                              360558               1014234.9
1600       1001                 265                            7                              360558               1046402.9
1650       779                  136                            3                              360558               1078842.9
1700       1621                 303                            4                              360558               1111078.9
1750       635                  185                            3                              360558               1143454.9
1800       1032                 311                            2                              360558               1186669.9
1850       1850                 234                            7                              360558               1218749.9
1900       751                  553                            3                              360558               1251109.9
1950       1031                 225                            4                              360558               1284057.8
2000       4169                 571                            96                             360558               1316557.8
2050       2421                 7993                           7                              360558               1348785.8
2100       1138                 474                            4                              360558               1381137.8
2150       2897                 2288                           26                             360558               1413249.8
2200       1568                 315                            5                              360558               1445657.8
2250       3536                 1854                           26                             360558               1477837.8
2300       2877                 661                            14                             360558               1510201.8
2350       1772                 292                            3                              360558               1542533.8
2400       2573                 1282                           3                              360558               1574725.8
2450       791                  423                            5                              360558               1606921.8
2500       1464                 519                            3                              360558               1639453.8
2550       1793                 413                            9                              360558               1671921.8
2600       1140                 240                            11                             360558               1704269.8
2650       1242                 1703                           4                              360558               1736517.8
2700       961                  267                            6                              360558               1769033.8
2750       700                  278                            4                              360558               1801333.8
2800       1421                 416                            4                              360558               1833517.8
2850       1500                 332                            4                              360558               1865749.8
2900       2161                 633                            5                              360558               1898270.9
2950       2352                 896                            31                             360558               1930650.9
3000       1159                 886                            11                             360558               1963162.9
3050       1374                 775                            3                              360558               1995362.9
3100       1245                 571                            2                              360558               2027706.9
3150       4165                 1145                           5                              360558               2060118.9
3200       1314                 584                            4                              360558               2092322.9
3250       1059                 338                            4                              360558               2124538.9
3300       1065                 436                            3                              360558               2156938.9
3350       1022                 269                            3                              360558               2189070.9
3400       1073                 302                            3                              360558               2221126.9
3450       3353                 1024                           4                              360558               2253486.9
3500       1084                 292                            2                              360558               2286010.9
3550       924                  551                            5                              360558               2318558.9
3600       1240                 1196                           5                              360558               2350758.9
3650       2413                 713                            3                              360558               2382966.9
3700       2367                 377                            12                             360558               2415382.9
3750       1066                 283                            5                              360558               2447758.9
3800       1161                 849                            3                              360558               2480006.9
3850       2081                 710                            7                              360558               2512418.9
3900       2258                 1234                           5                              360558               2544758.9



Database stats:
Table                               Size (KB)       KB/Entry
----------------------------------------------------------------------
account_deltas                      4.0             -
block_headers                       1128.0          0.3
account_fungible_asset_deltas       4.0             -
notes                               2005264.0       2.0
account_non_fungible_asset_updates  4.0             -
nullifiers                          43040.0         0.0
account_storage_map_updates         4.0             -
settings                            4.0             2.0
account_storage_slot_updates        4.0             -
transactions                        55832.0         0.1
accounts                            56400.0         0.1

Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good! Thank you! I'm going to merge as is, but let's do the following thing:

  • Create an issue for investigating how to make the stress test not depend on block-producer for the store API.
  • Run the account generation again first for 100K accounts (to compare with prior results) and then for 1M accounts to see if the results @igamigo got were representative.

Regarding the results, if these were in fact representative, we should create an issue to investigate what exactly is driving the performance. The database is not that huge (i.e., 2.5GB) and so, it shouldn't be taking ~800ms to retrieve block inputs or 1 - 2 seconds to insert a block.

@bobbinth bobbinth merged commit 8062818 into next Mar 25, 2025
11 checks passed
@bobbinth bobbinth deleted the santiagopittella-stress-testing-copy branch March 25, 2025 00:48
@Mirko-von-Leipzig
Copy link
Contributor

I've created #763 and #762.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants