-
Notifications
You must be signed in to change notification settings - Fork 212
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
fix: fix mining chunk cache #636
Conversation
8127733
to
a2defe1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No major problems with the code (didn't test it though)
|
||
case NewCacheLimit == State#state.chunk_cache_limit of | ||
case PartitionCacheLimit == State#state.chunk_cache_limit of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These parts of the code are easily extracted into sharp functions like
maybe_update_cache_limit(PartitionCacheLimit, #state{chunk_cache_limit = PartitionCacheLimit} = S0) -> S0;
maybe_update_cache_limit(PartitionCacheLimit, S0) ->
...
This will greatly reduce the nesting within a function and reduce function scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! 1a8a2ce
false -> ok | ||
end, | ||
GarbageCollectionFrequency = 4 * VDFQueueLimit * 1000, | ||
|
||
GCRef = | ||
case State#state.gc_frequency_ms == undefined of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic is not clear here.
We're checking if the gc_frequency_ms
is defined in the process state, but not checking if the gc_process_ref
is set (the actual marker that the timer is set here). So there are a possible scenario where we will have two timers set at the same time.
I would recommend saving the actual timer reference in the state and extract the timer initialization into a separate function. The example may be found in the P3 ledger implementation (handle_continue(?msg_continue_start_shutdown_timer, ...)
@ ar_p3_ledger.erl
line 431):
- ensure you cancel the existing timer if the timer exists and still running;
- ensure to put the unique marker into timer message (this is already done here);
When hitting the timer message handler, just do the related work and ensure to call the extracted timer initialization function once again, that will do all the needed things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it - Done! cb46fb0
f5b4358
to
1a8a2ce
Compare
mining cache now tracks sub-chunks stored and assumes difficulty 0 sub-chunks are the size of a full chunk. Also allow user to specify mining cache size in MiB rather than chunks
cb46fb0
to
167faa8
Compare
https://github.com/ArweaveTeam/arweave-dev/issues/666