Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@lambdageek
Copy link
Member

@lambdageek lambdageek commented Jul 30, 2018

Use hybrid suspend by default on x86 and amd64 OSX, Windows and Linux.

Pass --disable-hybrid-suspend to configure to disable at build time, or set
the enrivonment variable MONO_THREADS_SUSPEND=preemptive when running Mono to use preemptive suspend (the previous default).

Pass --disable-hybrid-suspend --enable-cooperative-suspend to configure
cooperative suspend at build time.

@lambdageek lambdageek force-pushed the hybrid-suspend-desktop-default branch 2 times, most recently from 676ae02 to 598fcbd Compare July 30, 2018 21:38
@lambdageek
Copy link
Member Author

We should add an x64 Linux (and OSX?) preemptive suspend CI lane after this is merged so we can keep testing the previous configuration. (There's already a CI_TAGS keyword for it - CI_TAGS=preemptive-suspend)

@marek-safar marek-safar mentioned this pull request Jul 30, 2018
23 tasks
Copy link
Contributor

@luhenry luhenry left a comment

Choose a reason for hiding this comment

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

You need to disable it for iOS and Android in https://github.com/mono/mono/blob/master/sdks/builds/ios.mk and https://github.com/mono/mono/blob/master/sdks/builds/android.mk respectively. Only disable it on the devices and simulator builds, not the host ones (iOSDeviceTemplate, iOSSimulatorTemplate and AndroidTargetTemplate).

@lambdageek
Copy link
Member Author

@luhenry Updated to explicitly pass --disable flags for the sdks

@lambdageek
Copy link
Member Author

Now I'm second-guessing myself - do I actually want to check the HOST not the TARGET? this isn't an (AOT) compiler related feature so I think checking HOST is more correct.

@lambdageek lambdageek force-pushed the hybrid-suspend-desktop-default branch from be614db to 59c678c Compare July 31, 2018 22:00
@lambdageek
Copy link
Member Author

Could I get another review of this? I switched the configure logic to look at HOST and host_linux and host_win32 (but target_osx - see comment in code).

I don't think it matters (since this isn't an AOT thing), but I'd love some feedback.

@jaykrell
Copy link
Contributor

Good point. Host should be correct. "runtimes" only have a host. I mean, even if the AOT compiler itself used a garbage collector, and configurable suspension, "host" would be correct.

@jaykrell
Copy link
Contributor

Unless the compiler had to inject safe points into the AOT code depending on suspension mechanism, then target could be relevant.

configure.ac Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure processor is relevant..but I guess ok, it disambiguates darwin, and we don't have Windows/arm support. What about Linux/arm?

Copy link
Contributor

Choose a reason for hiding this comment

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

FIXME? add host_macos, host_ios, and either remove host_darwin or make it clear host_darwin is maco | ios? And never say "osx"?

Copy link
Contributor

Choose a reason for hiding this comment

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

Does coop work w/o coop handles finished? We just treat transition from jit=>native differently based on if it is a handles() transition?

Copy link
Member Author

Choose a reason for hiding this comment

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

The processor check is specifically because we only want to turn this on on Intel for now - it feels like there are more deadlocks to chase down on linux on ARM.

The coop handles (plus precise managed stack scanning) would allow us to skip the "copy stackdata" step when a thread self-suspends and to stop scanning the native stack conservatively. So not having them doesn't preclude using hybrid suspend today.

Copy link
Contributor

@jaykrell jaykrell left a comment

Choose a reason for hiding this comment

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

Might want another authority on this but ok by me.

@lambdageek
Copy link
Member Author

@monojenkins build failed

@lambdageek
Copy link
Member Author

The interp failures seem related: we don't have GC Unsafe transitions in interp_entry.

@luhenry @lewurm What do you think: switch interp lane to use preemptive suspend for now and fixup later, or hold this PR until interp is ready?

@luhenry
Copy link
Contributor

luhenry commented Aug 1, 2018

@lambdageek disabling on CI will not fix the Interpreter by default, so either we always disable Hybrid Suspend while running with the interpreter, either we fix the Interpreter. I would go for the latter one, but I don't have a good idea of how long it's going to take.

@lambdageek
Copy link
Member Author

@luhenry The interpreter doesn't have safepoints right now - #7046 (comment). I'm not sure if there's a usecase for interp + hybrid on desktop. So I would prefer to go with a warning and a switch to preemptive if the interpreter and hybrid or coop are specified simultaneously.

@luhenry
Copy link
Contributor

luhenry commented Aug 2, 2018

@lambdageek sounds good to me, let's do that. /cc @lewurm @BrzVlad

@lambdageek lambdageek force-pushed the hybrid-suspend-desktop-default branch from 59c678c to 48b9dd8 Compare August 2, 2018 20:41
@lambdageek lambdageek requested a review from kumpera as a code owner August 2, 2018 20:41
@lambdageek
Copy link
Member Author

Updated to always switch to preemptive suspend if using the interpreter.

Use hybrid suspend by default on x86 and amd64 OSX, Windows and Linux

Pass `--disable-hybrid-suspend` to configure to disable at build time, or set
the enrivonment variable `MONO_THREADS_SUSPEND=preemptive` when running Mono to
use preemptive suspend (the previous default).

Pass `--disable-hybrid-suspend --enable-cooperative-suspend` to configure
cooperative suspend at build time.
Only the devices and simulator builds, not the host ones.
Do not use it.  It provides a last resort method to ignore configure and
environment settings and use a hardcoded threads suspend policy.
Until the interpreter supports safepoints and performs threads suspend states
switches in its trampolines, always use preemptive suspend if the interpreter
is used.
Like other uses of mono_threads_join_lock, enter GC Safe before trying to take
the lock.
@lambdageek lambdageek force-pushed the hybrid-suspend-desktop-default branch from 48b9dd8 to ffb1ca8 Compare August 3, 2018 19:29
@lambdageek lambdageek requested a review from BrzVlad as a code owner August 3, 2018 19:29
@lambdageek
Copy link
Member Author

Pushed a fix for sgen-new-threads-collect failures on OSX - need to take the join lock in GC Safe mode.

lambdageek and others added 2 commits August 3, 2018 21:35
Move safepoint suspend check to mono_runtime_set_execution_mode
…orce preemptive suspend

Force preemptive suspend in fullaotmixedcheck. We must compile the AOT images without safepoints.
@lambdageek lambdageek merged commit a7c699a into mono:master Aug 5, 2018
blattersturm added a commit to citizenfx/fivem that referenced this pull request Jul 31, 2019
… usable with embedding

See mono/mono#9811. Hopefully this doesn't get removed.
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…ono#9811)

* [coop] Turn hybrid suspend on by default on desktop platforms

   Use hybrid suspend by default on x86 and amd64 OSX, Windows and Linux

   Pass `--disable-hybrid-suspend` to configure to disable at build time, or set the environment variable `MONO_THREADS_SUSPEND=preemptive` when running Mono to use preemptive suspend (the previous default).

   Pass `--disable-hybrid-suspend --enable-cooperative-suspend` to configure cooperative suspend at build time.

* [sdks] Disable coop and hybrid suspend for iOS and Android

   Only the devices and simulator builds, not the host ones.

* [coop] Add mono_threads_suspend_override_policy ()

   Do not use it.  It provides a last resort method to ignore configure and environment settings and use a hardcoded threads suspend policy.

* [interp] Override suspend policy - warn and use preemptive

   Until the interpreter supports safepoints and performs threads suspend states switches in its trampolines, always use preemptive suspend if the interpreter is used.

* [coop] Enter GC Safe around mono_threads_join_lock ()

   Like other uses of mono_threads_join_lock, enter GC Safe before trying to take the lock.

* [interp] Use preemptive suspend with --full-aot-interp

   Move safepoint suspend check to mono_runtime_set_execution_mode

* [test] fullaotmixed - force preemptive suspend[test] fullaotmixed - force preemptive suspend

   Force preemptive suspend in fullaotmixedcheck. We must compile the AOT images without safepoints.


Commit migrated from mono/mono@a7c699a
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.

3 participants