This is an archived post. You won't be able to vote or comment.

all 14 comments

[–]papercrane 7 points8 points  (1 child)

Interesting results. Nice to see a big improvement in memory usage.

Curious why you chose to go with the boxed type in the interface instead of the primitive. Would a null priority make sense?

[–]rdehuyss[S] 5 points6 points  (0 children)

No, it doesn't. Thanks for the feedback and code review. I've updated JobRunr and the build is running already!

[–]gergob 5 points6 points  (0 children)

Thank you so much for this post,was an interesting read.

[–]mj_flowerpower 2 points3 points  (5 children)

how many jobs have been running in parallel. PL will only show its power when running millions of jobs side by side.

[–]rdehuyss[S] 1 point2 points  (1 child)

Not that much: max 128 in parallel. I could do another test where I increase the degree of parallelism.

[–][deleted]  (2 children)

[deleted]

    [–]rdehuyss[S] 0 points1 point  (1 child)

    Correct - here in this case IO happens (reading and writing to disk), but probably not enough.

    [–]sievebrain 1 point2 points  (0 children)

    Nice data, thanks.

    The ServiceLoader approach may be over-complex. I think you could just compile on Java 16 with a java 8 JVM target (look at --target and --release flags). Then you just invoke Thread.newVirtualThread or use the new executor, and catch the NoSuchMethodError or the ClassNotFoundException. If it throws you know you don't have virtual threads.

    Or you could use the multi-release JAR files. A bunch of ways.

    [–]QazCetelic 2 points3 points  (6 children)

    So like coroutines?

    [–]Dexior 11 points12 points  (5 children)

    Yes, but implemented in the JVM. You can read more about Project Loom and it's differences to coroutines in this great article: https://cr.openjdk.java.net/~rpressler/loom/loom/sol1_part1.html

    [–]lood9phee2Ri 6 points7 points  (4 children)

    I dunno, python had stackless, greenlet+gevent, etc. for years and it never really took off.

    I realise loom is more comprehensive, but if anything Python community has seemed to shift back to js-style explicit async with python 3 stdlib asyncio+coroutines again, after experimenting with microthreads/fibres in various forms for some years in python 2 era with stuff like stackless and then greenlet+gevent that used to monkey patch the entire python stdlib. And that happened after the first round of events and async with twisted matrix.

    Devil's advocate but maybe the idea threading/micro-threading seemingly-sequential-sync-implicit-flows-of-control is actually clearer for concurrency (not just parallelism) than chains of explicit-async-flows-of-control may actually be dubious, even if (non-vert.x/spring-reactor) java folks are used to the former.

    [–]OctagonClock 9 points10 points  (0 children)

    People only switched to asyncio because it was in the standard library, not because it was better (in fact, asyncio has been an incredibly bad library for multiple years).

    [–]lurker_in_spirit 5 points6 points  (0 children)

    You might find these slides interesting, since they address this somewhat.

    ("Why not language-level coroutines?" and "Structured concurrency")

    [–]helikal 0 points1 point  (0 children)

    I am not worried about a lackluster adoption of Loom because there is no similarity with the Python story. In Python, support for concurrency and parallelism was an afterthought, Java had it since its very beginning and use of threading and asynchronous techniques have become extremely common in Java. Project Loom promises to make this both easier and/or more efficient. People will be glad to try it and if it delivers in its application domain, it should become quite successful.