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

refactor: replace some references with owned structures in VMLogic #11615

Merged
merged 1 commit into from
Jun 20, 2024

Conversation

nagisa
Copy link
Collaborator

@nagisa nagisa commented Jun 19, 2024

VMLogic containing a lifetime makes it difficult to have it live for any longer than a short sequence of instantiate-link-run and is one of the reasons why we're forced to have some unsafe code in our linking code.

This refactor replaces some of the reference fields with Arcs, Boxes, etc. This is not a complete refactor, I intend to do the remainder as a follow-up.

Based on #11614
Part of #11319

@nagisa nagisa requested a review from a team as a code owner June 19, 2024 10:39
@nagisa nagisa requested a review from tayfunelmas June 19, 2024 10:39
Copy link

codecov bot commented Jun 19, 2024

Codecov Report

Attention: Patch coverage is 79.09605% with 37 lines in your changes missing coverage. Please review.

Project coverage is 71.45%. Comparing base (8189888) to head (4851fce).

Files Patch % Lines
...ntime/runtime-params-estimator/src/gas_metering.rs 55.55% 16 Missing ⚠️
runtime/near-vm-runner/src/wasmer_runner.rs 27.27% 0 Missing and 8 partials ⚠️
...time/runtime-params-estimator/src/function_call.rs 52.94% 8 Missing ⚠️
...me-params-estimator/src/costs_to_runtime_config.rs 0.00% 4 Missing ⚠️
runtime/runtime/src/lib.rs 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11615      +/-   ##
==========================================
- Coverage   71.48%   71.45%   -0.03%     
==========================================
  Files         788      788              
  Lines      160835   160921      +86     
  Branches   160835   160921      +86     
==========================================
+ Hits       114968   114993      +25     
- Misses      40850    40901      +51     
- Partials     5017     5027      +10     
Flag Coverage Δ
backward-compatibility 0.23% <0.00%> (-0.01%) ⬇️
db-migration 0.23% <0.00%> (-0.01%) ⬇️
genesis-check 1.35% <0.00%> (-0.01%) ⬇️
integration-tests 37.66% <37.85%> (-0.02%) ⬇️
linux 68.89% <78.53%> (+0.01%) ⬆️
linux-nightly 70.94% <79.09%> (-0.04%) ⬇️
macos 52.29% <67.14%> (-0.28%) ⬇️
pytests 1.58% <0.00%> (-0.01%) ⬇️
sanity-checks 1.38% <0.00%> (-0.01%) ⬇️
unittests 66.12% <74.57%> (-0.03%) ⬇️
upgradability 0.28% <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.

Not a refactor that makes things pretty, especially as it pertains to
the tests which willy-nilly mutate fields within these configs. But in
actual production code this makes a lot of sense -- we have a single
store of configurations that get loaded at startup and then proliferated
across the codebase. Having these be `Arc` is a minimal expense and
having the configs be a reference-counted pointers makes it much more
straightforward to keep these configurations wherever they belong
without unnecessary cloning of the underlying data or introducing nasty
lifetimes as was the case with `VMLogic`.

(`VMLogic` still has a lifetime, but it no longer is because of configs)
@nagisa nagisa enabled auto-merge June 20, 2024 09:25
@nagisa nagisa added this pull request to the merge queue Jun 20, 2024
Merged via the queue into near:master with commit 591632a Jun 20, 2024
28 of 29 checks passed
@nagisa nagisa deleted the delifetimes-vmlogic-some branch June 20, 2024 09:48
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.

2 participants