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

[mono][jit] Use an mrgctx for all gshared methods on WASM. #82981

Merged
merged 1 commit into from Apr 26, 2023

Conversation

vargaz
Copy link
Contributor

@vargaz vargaz commented Mar 4, 2023

No description provided.

@vargaz vargaz added NO-REVIEW Experimental/testing PR, do NOT review it and removed area-Codegen-JIT-mono labels Mar 4, 2023
@ghost ghost assigned vargaz Mar 4, 2023
@vargaz
Copy link
Contributor Author

vargaz commented Mar 4, 2023

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vargaz
Copy link
Contributor Author

vargaz commented Mar 4, 2023

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vargaz
Copy link
Contributor Author

vargaz commented Mar 4, 2023

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vargaz
Copy link
Contributor Author

vargaz commented Mar 4, 2023

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vargaz vargaz force-pushed the gshared-new branch 2 times, most recently from 4b26b61 to fe193bd Compare March 8, 2023 19:48
@vargaz
Copy link
Contributor Author

vargaz commented Mar 8, 2023

/azp run runtime-wasm

@vargaz
Copy link
Contributor Author

vargaz commented Mar 8, 2023

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vargaz
Copy link
Contributor Author

vargaz commented Mar 11, 2023

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vargaz
Copy link
Contributor Author

vargaz commented Mar 25, 2023

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vargaz vargaz changed the title [mono][jit] Use an mrgctx for all gshared methods. [mono][jit] Use an mrgctx for all gshared methods on WASM. Mar 28, 2023
@vargaz vargaz marked this pull request as ready for review March 28, 2023 14:49
@vargaz vargaz force-pushed the gshared-new branch 2 times, most recently from 40f1f7e to 13b04b0 Compare March 28, 2023 15:06
@kotlarmilos
Copy link
Member

kotlarmilos commented Mar 29, 2023

/azp run runtime-ioslike

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@@ -142,6 +142,12 @@ DEFINE_INT(jiterpreter_interp_entry_queue_flush_threshold, "jiterpreter-interp-e
DEFINE_INT(jiterpreter_wasm_bytes_limit, "jiterpreter-wasm-bytes-limit", 6 * 1024 * 1024, "Disable jiterpreter code generation once this many bytes of WASM have been generated")
#endif // HOST_BROWSER

#ifdef HOST_WASM
Copy link
Member

Choose a reason for hiding this comment

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

Should it include HOST_IOS as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its better to start with one platform to see how it goes.

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@kotlarmilos
Copy link
Member

As it might have performance disadvantages, is there a way to test it locally before merging?

@vargaz
Copy link
Contributor Author

vargaz commented Mar 29, 2023

The benchmarking suite can be run on wasm locally, not sure about ios.

@vargaz
Copy link
Contributor Author

vargaz commented Mar 29, 2023

Also, it could be merged and later reverted if the perf impact is significant.

Enable it by default on WASM.

In this mode, all gshared methods get an mrgctx, which means they can access
their data using a simple load from the mrgctx instead of having to call
a rgctx fetch trampoline.

Upsides:
- much simpler.
- faster access to gshared data
- smaller code and data size in the AOT case
- if enabled by default on all platforms, large amount of gshared
  code can be removed

Downsides:
- the methods have to initialize their mrgctx in their prolog
- on non-wasm platforms, indirect calls to gshared methods
  (like virtual calls) will need to use rgctx trampolines more often
  to pass the mrgctx.
@kotlarmilos
Copy link
Member

@vargaz is it ready to be merged after the Preview 4 snap? Is there anything else missing?

@vargaz
Copy link
Contributor Author

vargaz commented Apr 24, 2023

It could be merged.

@kotlarmilos
Copy link
Member

It could be merged.

Good. I will approve it after the Preview 4 snap.

@kotlarmilos kotlarmilos self-requested a review April 26, 2023 08:24
Copy link
Member

@kotlarmilos kotlarmilos left a comment

Choose a reason for hiding this comment

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

LGTM, thank you! Hopefully, we can reduce the size with reasonable speed tradeoff.

P.S. I would leave this to @lambdageek for final approval.

/cc: @SamMonoRT

@vargaz vargaz merged commit 184d17d into dotnet:main Apr 26, 2023
96 of 101 checks passed
@vargaz vargaz deleted the gshared-new branch April 26, 2023 15:01
@vargaz
Copy link
Contributor Author

vargaz commented Apr 26, 2023

Will see what changes this will do to benchmarks.

@ghost ghost locked as resolved and limited conversation to collaborators May 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants