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

[scheduler] scala native support #866

Merged
merged 2 commits into from
Nov 26, 2024
Merged

[scheduler] scala native support #866

merged 2 commits into from
Nov 26, 2024

Conversation

fwbrasil
Copy link
Collaborator

First step to support Scala Native in kyo-core.

@@ -92,7 +93,8 @@ abstract private class Worker(

val a1, a2, a3, a4, a5, a6, a7 = 0L // padding

@volatile private var state: State = State.Idle
private val state = new AtomicReference[State](State.Idle)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Scala Native doesn't support method handles. This change might have a performance penalty but it seems worth it.

@@ -0,0 +1,11 @@
package kyo.scheduler.util
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be shared with JS?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The scheduler in JS is a separate and much simpler implementation since the runtime doesn't support threads. JS doesn't require a stub for this.

private[scheduler] def statsScope =
StatsRegistry.scope("kyo", "scheduler")

private[scheduler] def bug(msg: String, ex: Throwable) =
log.log(Level.SEVERE, s"🙈 !!Kyo Scheduler Bug!!", new Exception(msg, ex))
new Exception(s"🙈 !!Kyo Scheduler Bug!! " + msg, ex).printStackTrace()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There's no java logging in native. Logging to the standard err seems reasonable for a bug.

Copy link
Contributor

Choose a reason for hiding this comment

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

There is! https://github.com/scala-native/scala-native-java-logging

Guess which project motivated me to make the port of this library? Kyo itself 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

I've opened a PR #868

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ha! pretty cool :) It's nice to see the ecosystem growing. I was a bit skeptical of Scala Native initially but I think that was skewed by my experience working with Graal. Many Scala projects are mostly self-contained code that are trivial to port to Native if the ecosystem is more mature. Graal is great but it can also be a nightmare to set up. I'd say the odds is that kyo-tapir will have a Scala Native version before one that works on GraalVM Native 😅

@fwbrasil fwbrasil merged commit 9368c6b into main Nov 26, 2024
3 checks passed
@fwbrasil fwbrasil deleted the scheduler-native branch November 26, 2024 20:39
@hearnadam hearnadam mentioned this pull request Dec 4, 2024
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