Skip to content

[release/9.0-staging] [mono][interp] Disable SSA from default set of optimizations #116250

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

Closed

Conversation

BrzVlad
Copy link
Member

@BrzVlad BrzVlad commented Jun 3, 2025

Key points regarding this issue:

  • this is regression from .NET8, it would lead to crashes if we don't disable
  • on average, this revert should result in about 10% perf regression from previous versions of .NET9, but it shouldn't be a regression from .NET8,
  • .NET8 maui is out of support already (I suspect maybe this is a reason why people started hitting this recently), so having them forced to move to a broken version is not ideal
  • If we go for the revert approach, then with july build users should have this problem mitigated
  • If we start trying to fix the failures, I don't have confidence that we would have addressed all the failures by then. I haven't received repro steps from some customers yet, so the fixes that I've done so far might or not be enough. To me it seems we are taking a high risk of delaying fix for this issue for at least an additional month
  • this backport adds support for users to opt back in to ssa optimizations
  • another acceptable solution, as far as I'm concerned, is to backport all SSA fixes that I've done so far, together with the optimization env var knob, and if for some users this fix is not enough, we can tell them to manually disable SSA until we get it fixed

Customer Impact

  • Customer reported
  • Found internally

This is currently impacting users of Maui on iOS, resulting in application crash. Multiple users reported crashes in #115991

Regression

  • Yes
  • No

SSA optimization for interpreter was introduced in .NET9 so it is a regression from .NET8.

Testing

Tested with a repro sample provided by a customer. Tested the no-ssa configuration on CI to ensure it doesn't cause other regressions.

Risk

Low. This disables the SSA optimization, which is pretty much the same configuration that we had before in .NET8. SSA disabled compilation was also currently used for methods deemed too massive to do SSA transformation from the start, so it is not a bitrotten configuration. The drawback is that SSA optimization would improve quality of compiled code by about 10% so some perf regressions would be expected. For any eventuality, a new env var support is added to the interpreter, allowing for user to select the desired optimizations, reverting to original behavior.

@BrzVlad BrzVlad added this to the 9.0.x milestone Jun 3, 2025
@Copilot Copilot AI review requested due to automatic review settings June 3, 2025 07:02
@BrzVlad BrzVlad requested a review from kotlarmilos as a code owner June 3, 2025 07:02
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR disables the SSA optimization in the interpreter to avoid application crashes on iOS, while still allowing users to re-enable SSA via an environment variable if needed.

  • Removed the SSA flag from the default interpreter optimizations.
  • Added support to override interpreter options using the MONO_INTERPRETER_OPTIONS environment variable.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/mono/mono/mini/interp/interp.h Removed INTERP_OPT_SSA from the default set of optimizations.
src/mono/mono/mini/interp/interp.c Added environment variable support to allow user customization of interpreter options.

@@ -43,7 +43,7 @@ enum {
#endif
INTERP_OPT_SSA = 128,
INTERP_OPT_PRECISE_GC = 256,
INTERP_OPT_DEFAULT = INTERP_OPT_INLINE | INTERP_OPT_CPROP | INTERP_OPT_SUPER_INSTRUCTIONS | INTERP_OPT_BBLOCKS | INTERP_OPT_TIERING | INTERP_OPT_SIMD | INTERP_OPT_SSA | INTERP_OPT_PRECISE_GC
INTERP_OPT_DEFAULT = INTERP_OPT_INLINE | INTERP_OPT_CPROP | INTERP_OPT_SUPER_INSTRUCTIONS | INTERP_OPT_BBLOCKS | INTERP_OPT_TIERING | INTERP_OPT_SIMD | INTERP_OPT_PRECISE_GC
Copy link
Preview

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

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

Consider adding a comment here to explain that the SSA optimization flag was intentionally removed from the default settings due to stability issues on iOS.

Copilot uses AI. Check for mistakes.

@@ -8981,6 +8981,10 @@ mono_ee_interp_init (const char *opts)
set_context (NULL);

interp_parse_options (opts);

const char *env_opts = g_getenv ("MONO_INTERPRETER_OPTIONS");
Copy link
Preview

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

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

[nitpick] It may be beneficial to document the behavior of parsing interpreter options from the environment variable, clarifying that these options override the defaults when provided.

Copilot uses AI. Check for mistakes.

Copy link
Contributor

Tagging subscribers to this area: @BrzVlad, @kotlarmilos
See info in area-owners.md if you want to be subscribed.

@BrzVlad BrzVlad added the Servicing-consider Issue for next servicing release review label Jun 3, 2025
@BrzVlad
Copy link
Member Author

BrzVlad commented Jun 3, 2025

cc @lewing

@Emanuele9xx
Copy link

When will be available?

@BrzVlad
Copy link
Member Author

BrzVlad commented Jun 4, 2025

@SteveMCarroll Key points regarding this issue:

  • this is regression from .NET8, it would lead to crashes if we don't disable
  • on average, this revert should result in about 10% perf regression from previous versions of .NET9, but it shouldn't be a regression from .NET8,
  • .NET8 maui is out of support already (I suspect maybe this is a reason why people started hitting this recently), so having them forced to move to a broken version is not ideal
  • If we go for the revert approach, then with july build users should have this problem mitigated
  • If we start trying to fix the failures, I don't have confidence that we would have addressed all the failures by then. I haven't received repro steps from some customers yet, so the fixes that I've done so far might or not be enough. To me it seems we are taking a high risk of delaying fix for this issue for at least an additional month
  • this backport adds support for users to opt back in to ssa optimizations
  • another acceptable solution, as far as I'm concerned, is to backport all SSA fixes that I've done so far, together with the optimization env var knob, and if for some users this fix is not enough, we can tell them to manually disable SSA until we get it fixed

@BrzVlad BrzVlad force-pushed the backport-disable-ssa branch from c968107 to 61cca41 Compare June 5, 2025 06:38
@BrzVlad
Copy link
Member Author

BrzVlad commented Jun 5, 2025

Tested without changes to the optimization set and the same WASM failures appear, meaning they are not related.

@jozkee
Copy link
Member

jozkee commented Jun 9, 2025

@BrzVlad reminder that servicing code complete for 9.0.7 is today @ 3PM PST.

@BrzVlad
Copy link
Member Author

BrzVlad commented Jun 10, 2025

Closing in favor of #116428

@BrzVlad BrzVlad closed this Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Codegen-Interpreter-mono Servicing-consider Issue for next servicing release review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants