The Wayback Machine - https://web.archive.org/web/20210823172225/https://github.com/scala-native/scala-native/pull/2327
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

Add multithreadingEnabled switch to NativeConfig #2327

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

@WojciechMazur
Copy link
Contributor

@WojciechMazur WojciechMazur commented Jun 21, 2021

This PR adds a new field in the NativeConfig, allowing us to remain current low-overhead single-threaded runtime, as well as test experimental multithreading support, as pointed in #2323

By placing this field in the NativeConfig we'd be able to pass specific flags to Clang if needed in the future, eg. to prepare GC for multithreading execution. Additionally thanks to adding a new linktime-property we would be able to perform link-time conditional branching, eg. to disable locking without any additional overhead.

@WojciechMazur WojciechMazur force-pushed the WojciechMazur:feature/multithreading-switch branch from e5cf020 to adcc89a Jul 10, 2021
copy(multithreadingSupport = enabled)
.withLinktimeProperties(
linktimeProperties.updated(
"scala.scalanative.meta.linktimeinfo.isMultithreadingEnabled",
enabled
)
)
}
Comment on lines 177 to 184

This comment has been minimized.

@lolgab

lolgab Jul 14, 2021
Contributor

I think the setting should be defined in one place instead of two.
What happens if I set:

nativeConfig ~= {_.withLinktimeProperties(
  linktimeProperties.updated(
    "scala.scalanative.meta.linktimeinfo.isMultithreadingEnabled",true)
  )
}

?
Will this enable "half" of the multithreading code (just the runtime one without the compiler) ?

And if I do:

nativeConfig ~= {
  _.withMultithreadingSupport(true)
    .withLinktimeProperties(linktimeProperties - "scala.scalanative.meta.linktimeinfo.isMultithreadingEnabled")
}

It will have only the compiler support without the runtime.

I think we should define only a single setting that can be enabled/disabled atomically.

This comment has been minimized.

@WojciechMazur

WojciechMazur Aug 10, 2021
Author Contributor

That was a good point, I've replaced isMultithreadingEnabled and isWindows properties with predefined values (computed from NativeConfig or Platform settings) and introduced custom properties that can be set by the user. At this point Discover.linktimeProperties might be obsolete, however, I guess we can keep it for future uses, eg. reading props from env variable - right now introducing parsing would be quite problematic.

…ites - introduce predefinded and custom linktime properties
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants