-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Measure accounts loading and storing cost #31411
Comments
Regarding the way CU per tx could be computed, I'm thinking about using empirical approach.
The observable function of choice is time per tx, call it This function is different from cost per transaction, lets denote by We can do simulations and find triples
So all we need is to find estimations for UPD: |
Assuming there are 4 parallel processes during replay, currently the CU per nano-sec is defined as
so equation can be simplified to |
Few points I am not entirely clear:
ig I'm thinking alone the line of: |
To be honest, I didn't dig much into this thing. What I observe is that loading time reported here is quite high (1/2 of execute time). Didn't consider that there is a cache for loaded accounts. Need to check the size of the cache to say if my accounts are hot or not.
I though about artificial scenario with minimized number of lock contention, so just acquiring the lock. |
In regard to this, I'm not sure that my mental model for the accounts load is accurate. I have in mind something like:
So from (3), if we compare program that only reads accounts and one that writes, the load phase of both should be the same but the execution will be longer for write program because, I think, the time to copy modified accounts data is part of execution. @alessandrod could you tell me if it fits the reality? |
Well, if we say that lock time is negligible, |
I played a bit on timing on storing accounts. Somewhat surprised to notice that same transaction took very different time to store accounts between ledger replays. The first replay took about 14ms to store accounts for a transaction, the second (re)run took only 1ms. Not sure why, @brooksprumo do you have a pointer to where should I look? Also, I thought you did accounts loading/storing performance measure, are there something we can use here? |
Let me take a look. The first transaction of a slot does some extra stuff to initialize various data structures. For example, the accounts write cache has a map from slot to accounts. So the first store to a new slot will add a new entry to the map for that new slot with an initially-empty set of accounts. But I don't think this alone would account for over 10 milliseconds of difference...
I did some histograms for loading accounts, but not on storing accounts. So I don't think that'll apply here (based on this and other threads, seems that writes/stores are the issue). |
Nothing jumps out in the code. I'll look at metrics to see if that elucidates anything. |
Data on loading is helpful too. The overarching idea is loading/storing/locking accounts, as part of execution, are underpriced, so it leads to either few transactions are packing into block, or elevate replay time. @KirillLykov correct me if i'm wrong. This issue aims to identify following:
|
Gotcha. Maybe this PR can be helpful to start with: #33220 |
@KirillLykov to follow up on our call, my understanding of "loading account", which could be wrong, consists two steps:
As for cost of "storing account", I assume is a reverse process: deserialize and memcpy from VM to accounts' write-cache, then store to accounts-db here. metrics |
¡
Yep this is correct, the serialize* and deserialize* execution metrics track the time to write accounts into the vm and then parse them back respectively. |
@taozhu-chicago my understanding of the metrics is the following: Cost of load:
NOTE: |
Amazing! perhaps you can also add |
Some preliminary results for the run when I create blocks of transactions such that each transaction modifies 1 10MB account. There are 256 accounts in total modified in round-robing manner. The unit is
Preliminary because I just picked time for 2s when the invalidator was a leader, it is not averaged over long enough period of time (because for that I need to develop some tools). What is weird with it:
|
Because the scheduler will estimate CU costs, see high costs, and pack a block with enough transactions as not to exceed the max block CU cost. (EDIT: I'm assuming that the CU cost for these txs is high) |
Mmm, possible but not likely. Scheduler uses actual consumed CU when packing, not the amount TX requests. Given only 25 TXs/block, each tx need to have total actual CU = 48,000,000/35 = 1.4M CU/tx, which is the up limit. I'll look into ledger once it's available. |
Problem
Need to measure accounts loading and storing performance in
us
, and inCU
.Motivation is to set transaction accounts read/write lock cost, which can be used as input for base fee calculation.
Few parameters for measuring: type of accounts (eg program account, data account and PDA), size of accounts,
Proposed Solution
using ledger-tool to replay mainnet-beta ledger, collect
measure_us
for accounts load and store at different circumstances.Note: loading program accounts should be more expensive than loading normal data and PDA accounts.
The text was updated successfully, but these errors were encountered: