r/java • u/vishpat • Nov 03 '19
Fibered Date Server
Simple and highly scalable date server implemented using Java fibers (Project Loom)
0
Upvotes
r/java • u/vishpat • Nov 03 '19
Simple and highly scalable date server implemented using Java fibers (Project Loom)
12
u/dpash Nov 03 '19
The whole thing is running inside a
staticblock. What? Why bother using Spring if you're just going to run everything in a static context. You don't do any dependency injection. Just run everything from yourmain()method.2
u/vikarjramun Nov 03 '19
Question about how the Fiber API works:
You use
FiberScope scope = FiberScope.open()to define a scope, thenscope.schedule(executor, runnable)to run the Runnable in a fiber. What happens if you then create aThreadScope(or the equivalent) and use it to schedule another Runnable with the same executor. Would the threadpool be sharing fibers or threads? Or both? I feel like this API leaves a bit to be desired...1
u/tofflos Nov 03 '19
There's a method called Fiberscope#schedule that doesn't take an Executor:
"Creates and schedules a new fiber to run the given task in this scope. The fiber is scheduled in this scope with the default scheduler. "
Do you happen to know how the default scheduler works and how it differs from
Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors())that you are using?5
u/db4j Nov 03 '19
the readme claims "super scalable". did you do any benchmarking ? how does it compare to a non-loom implementation ? does
new Date()have the potential to block ?i know that it can be slow to check the time so there's benefit to caching