Skip to content

Conversation

@heifner
Copy link
Contributor

@heifner heifner commented Apr 25, 2025

Use an unbounded queue for _result_queue to avoid results getting dropped because the queue is full.
Also call free_code when code is no longer used instead of waiting for LIB to reduce memory growth.

Resolves #1441

…ting dropped because the queue is full. Also call free_code when code is no longer used instead of waiting for LIB.
@heifner heifner changed the base branch from main to release/1.1 April 25, 2025 14:37
@heifner heifner requested review from greg7mdp and spoonincode April 25, 2025 14:37
@heifner heifner added the OCI Work exclusive to OCI team label Apr 25, 2025
write_message(nextup->code_id(), nextup->msg, nextup->fds_to_pass);
std::vector<wrapped_fd> fds_to_pass;
fds_to_pass.emplace_back(memfd_for_bytearray(nextup->code));
write_message(nextup->code_id(), nextup->msg, fds_to_pass);
Copy link
Contributor

Choose a reason for hiding this comment

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

Not related to this change, but I feel write_message should take a std::span<wrapped_fd instead of a std::vector, so we could pass one without emplacing to a vector with a heap alloc.

_queued_compiles.emplace_front(std::move(msg), std::move(code));
else
_queued_compiles.emplace_back(std::move(msg), std::move(fds_to_pass));
_queued_compiles.emplace_back(std::move(msg), std::move(code));
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we fix the typo in the type queued_compilies_t?

#ifdef EOSIO_EOS_VM_OC_RUNTIME_ENABLED
if(eosvmoc) for(auto it = first_it; it != last_it; it++)
eosvmoc->cc.free_code(it->code_hash, it->vm_version);
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

The changes aren't what we discussed. afaict the way we discussed would be 1) for this code to remain here, and 2) for the added lines above (where this here was moved to) would exist but would check that the code was set in the same block prior to doing the removal. That first_block_used is currently inaccessible from there but it would be trivial to plumb it through starting from here

if( existing_code ) {
const code_object& old_code_entry = db.get<code_object, by_code_hash>(boost::make_tuple(account.code_hash, account.vm_type, account.vm_version));
EOS_ASSERT( old_code_entry.code_hash != code_hash, set_exact_code,
"contract is already running this version of code" );
old_size = (int64_t)old_code_entry.code.size() * config::setcode_ram_bytes_multiplier;
if( old_code_entry.code_ref_count == 1 ) {
db.remove(old_code_entry);
context.control.code_block_num_last_used(account.code_hash, account.vm_type, account.vm_version, context.control.head().block_num() + 1);

Also, I realize now the discussion might have been ambiguous w.r.t. to us making this change strictly for OC or more universally. I believe the problem we are trying to solve applies for any runtime not just OC so I suspect we should be doing this universally. Maybe this aspect needs to be discussed idk

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's discuss in standup. @arhag

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@heifner heifner merged commit 37edf92 into release/1.1 Apr 29, 2025
41 checks passed
@heifner heifner deleted the GH-1441-oc-compile-queue-1.1 branch April 29, 2025 11:44
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.

OC compile scheduling

4 participants