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

introduce all the necessary features for reusing contract data memories #11144

Closed
wants to merge 2 commits into from

Conversation

Ekleog-NEAR
Copy link
Collaborator

@Ekleog-NEAR Ekleog-NEAR commented Apr 24, 2024

With this, all that’s missing should be the contract data memory queue, and checking that the Arc::into_inner actually works properly at least most of the time. I’m… not that hopeful about this second precondition, but let’s see what happens with a bit of testing.

Part of #11033

@Ekleog-NEAR Ekleog-NEAR requested a review from nagisa April 24, 2024 10:21
@Ekleog-NEAR Ekleog-NEAR requested a review from a team as a code owner April 24, 2024 10:21
Copy link

codecov bot commented Apr 24, 2024

Codecov Report

Attention: Patch coverage is 65.57377% with 21 lines in your changes are missing coverage. Please review.

Project coverage is 71.11%. Comparing base (a9ddf9c) to head (c3ad36f).
Report is 3 commits behind head on master.

Files Patch % Lines
runtime/near-vm/vm/src/memory/linear_memory.rs 42.85% 9 Missing and 3 partials ⚠️
runtime/near-vm/vm/src/mmap.rs 80.55% 4 Missing and 3 partials ⚠️
...untime/near-vm-runner/src/near_vm_runner/memory.rs 50.00% 0 Missing and 1 partial ⚠️
runtime/near-vm/test-api/src/sys/tunables.rs 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11144      +/-   ##
==========================================
+ Coverage   71.10%   71.11%   +0.01%     
==========================================
  Files         773      773              
  Lines      154176   154214      +38     
  Branches   154176   154214      +38     
==========================================
+ Hits       109625   109671      +46     
+ Misses      40100    40093       -7     
+ Partials     4451     4450       -1     
Flag Coverage Δ
backward-compatibility 0.24% <0.00%> (-0.01%) ⬇️
db-migration 0.24% <0.00%> (-0.01%) ⬇️
genesis-check 1.43% <0.00%> (-0.01%) ⬇️
integration-tests 36.88% <36.06%> (ø)
linux 69.54% <65.57%> (+<0.01%) ⬆️
linux-nightly 70.56% <65.57%> (-0.01%) ⬇️
macos 54.34% <50.87%> (+0.04%) ⬆️
pytests 1.65% <0.00%> (-0.01%) ⬇️
sanity-checks 1.44% <0.00%> (-0.01%) ⬇️
unittests 66.77% <65.57%> (+0.01%) ⬆️
upgradability 0.29% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Ekleog-NEAR
Copy link
Collaborator Author

The untested code lines should become tested once the actual implementation using these new helper functions will land :)

Copy link
Collaborator

@nagisa nagisa left a comment

Choose a reason for hiding this comment

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

My bad, had this reviewed last week but forgot to submit the review T_T

pub fn into_preallocated(self) -> Result<PreallocatedMemory, String> {
Ok(PreallocatedMemory(
Arc::into_inner(self.0)
.ok_or("Multiple references to NearVmMemory prevent its reuse")?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Might be worthwhile to tracing::debug this too, given that we're unlikely to act on this error.

)?)))
}

#[cfg(unused)] // TODO: this will be used once we reuse the memories
pub fn into_preallocated(self) -> Result<PreallocatedMemory, String> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
pub fn into_preallocated(self) -> Result<PreallocatedMemory, String> {
pub fn into_preallocated(self) -> Result<PreallocatedMemory, &'static str> {

@Ekleog-NEAR
Copy link
Collaborator Author

No worries and thanks for the review! I haven't managed to finish the subsequent PR anyway. Once the next one is closer to completion, I'll handle your comments and land this one :)

@Ekleog-NEAR
Copy link
Collaborator Author

Closing, as per the results written down in #11033: it turns out the "optimization" is actually slower than the baseline, so there’s no longer any reason to land this code

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.

None yet

2 participants