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

OC tierup compile in order #1342

Merged
merged 5 commits into from
Jun 29, 2023
Merged

OC tierup compile in order #1342

merged 5 commits into from
Jun 29, 2023

Conversation

heifner
Copy link
Member

@heifner heifner commented Jun 26, 2023

Compile contracts in order executed except for eosio.* contracts. Prioritize eosio.* accounts to be executed next.

@heifner heifner requested review from linh2931 and spoonincode June 26, 2023 13:08
@heifner heifner added the OCI Work exclusive to OCI team label Jun 26, 2023
@@ -80,7 +80,7 @@ class code_cache_base {

//these are really only useful to the async code cache, but keep them here so
//free_code can be shared
std::unordered_set<code_tuple> _queued_compiles;
deque<code_tuple> _queued_compiles;
Copy link
Member

@spoonincode spoonincode Jun 26, 2023

Choose a reason for hiding this comment

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

I'm worried about the performance ramification of switching this from constant logn time look up to linear time lookup. The lookup occurs every time an action is executed and when someone starts fresh there could be hundreds or thousands of entries that need to be searched through for every action (until compilation settles down).

I think maybe instead we should have a second

std::unordered_set<code_tuple> _high_priority_queued_compiles;

Copy link
Member Author

Choose a reason for hiding this comment

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

One issue I saw was that compiling was according to code_hash sort order instead of order they came in. This preserves the order. If worried about performance, maybe we should use a multindex instead for this which would allow for keeping track of order, last used, prioritize eosio.*, and provide fast lookup.

Copy link
Member

Choose a reason for hiding this comment

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

yeah if you want to maintain compilation order, a multi_index sounds good

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@heifner heifner requested a review from spoonincode June 26, 2023 17:39
@@ -156,13 +157,17 @@ const code_descriptor* const code_cache_async::get_descriptor_for_code(const dig
it->second = false;
return nullptr;
}
if(_queued_compiles.find(ct) != _queued_compiles.end()) {
if(auto it = _queued_compiles.get<by_hash>().find(boost::make_tuple(std::ref(code_id), vm_version)); it != _queued_compiles.get<by_hash>().end()) {
_queued_compiles.relocate(_queued_compiles.begin(), _queued_compiles.project<0>(it));
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this eliminate the strict prioritization of system contracts? imo that's a more important behavior to uphold than trying to prioritize based on MRU. Maybe just remove this relocate() which will then make it FIFO, with the exception that system contracts get push_front()ed to the front of the line.

Being FIFO is still better than it was previously.

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed

@@ -106,7 +107,7 @@ std::tuple<size_t, size_t> code_cache_async::consume_compile_thread_queue() {
}


const code_descriptor* const code_cache_async::get_descriptor_for_code(const digest_type& code_id, const uint8_t& vm_version, bool is_write_window, get_cd_failure& failure) {
const code_descriptor* const code_cache_async::get_descriptor_for_code(const account_name& receiver, const digest_type& code_id, const uint8_t& vm_version, bool is_write_window, get_cd_failure& failure) {
Copy link
Member

Choose a reason for hiding this comment

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

I think it's fine to leave as is, but for increased abstraction maybe this just takes bool high_priority instead, and the receiver.prefix() == chain::config::system_account_name check is then left outside of any eos-vm-oc code

Copy link
Member Author

Choose a reason for hiding this comment

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

I like that. Didn't feel right including chain::config here.

Base automatically changed from GH-1251-auto-oc to main June 29, 2023 18:18
@heifner heifner merged commit aed53c0 into main Jun 29, 2023
@heifner heifner deleted the GH-1251-auto-oc-opt branch June 29, 2023 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCI Work exclusive to OCI team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants