puniverse / quasar Goto Github PK
View Code? Open in Web Editor NEWFibers, Channels and Actors for the JVM
Home Page: http://docs.paralleluniverse.co/quasar/
License: Other
Fibers, Channels and Actors for the JVM
Home Page: http://docs.paralleluniverse.co/quasar/
License: Other
The ASM dependency might be troublesome for AOT intstrumentation
Instead, they wreak havoc...
In the current code (just committed) for my Pong clone in Quasar, I'm getting a NullPointerException after using RequestReplyHelper.call three times inside of the CollisionFinder. This is with the latest code in GitHub. (in order to have instrumentation verification for the Registry.get/set problem)
The exception happens in RequesetReplyHelper.java line 151. The third time call is used, the actor field in the ActorRef returned from getFrom is null.
Bound mismatch: The generic method getChild(Object) of type SupervisorActor is not applicable for the arguments (Object). The inferred
type T&ActorRef<Object> is not a valid substitute for the bounded parameter <T extends ActorRef<M>>
at co.paralleluniverse.actors.behaviors.Supervisor
public final <T extends ActorRef<M>, M> T getChild(Object id) throws SuspendExecution, InterruptedException
Exception in thread "main" java.lang.IllegalArgumentException: Fiber class class co.paralleluniverse.actors.ActorRegistry$3 has not been instrumented.
at co.paralleluniverse.fibers.Fiber.<init>(Fiber.java:157)
at co.paralleluniverse.fibers.Fiber.<init>(Fiber.java:177)
at co.paralleluniverse.fibers.Fiber.<init>(Fiber.java:453)
at co.paralleluniverse.actors.ActorRegistry$3.<init>(ActorRegistry.java:126)
at co.paralleluniverse.actors.ActorRegistry.getActor(ActorRegistry.java:126)
This can be reproduced using this gist.
restoreThreadLocals in finally is called based on local, volatile state. May be invalidated if fiber is scheduled before finally is reached (for example, if fiber yields)
Hi,
Please add quasar maven example with instrumentation, it will be really appreciated.
Seems there's an issue with instrumenting JDK 8 streams.
Doing:
new Fiber<>((SuspendableRunnable) () -> {
IntStream.range(0, 1)
.mapToObj((s) -> new Fiber<>(() -> "pong").start())
.map((t) -> {
try {
return t.get();
} catch (ExecutionException | InterruptedException e) {
throw Throwables.propagate(e);
}
});
}).start();
Produces:
java.lang.IllegalArgumentException: INVOKESPECIAL/STATIC on interfaces require ASM 5
at org.objectweb.asm.MethodVisitor.visitMethodInsn(Unknown Source)
at org.objectweb.asm.ClassReader.a(Unknown Source)
at org.objectweb.asm.ClassReader.b(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at co.paralleluniverse.fibers.instrument.QuasarInstrumentor.instrumentClass(QuasarInstrumentor.java:100)
at co.paralleluniverse.fibers.instrument.QuasarInstrumentor.instrumentClass(QuasarInstrumentor.java:81)
at co.paralleluniverse.fibers.instrument.JavaAgent$Transformer.transform(JavaAgent.java:187)
at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428)
...
This is using the jdk8 quasar core jar. See https://github.com/danielnorberg/quasar-crash for full repro.
Keeping Erlang names for Java classes is unnecessary.
In the code below from Fiber 0.6 - name parameter is never used.
/**
* Creates a new child Fiber from the given {@link SuspendableCallable}.
* This constructor may only be called from within another fiber. This fiber will use the same fork/join pool as the creating fiber.
* The new fiber uses the default initial stack size.
*
* @param name The name of the fiber (may be null)
* @param target the SuspendableRunnable for the Fiber.
* @throws IllegalArgumentException when stackSize is <= 0
*/
public Fiber(String name, SuspendableCallable<V> target) {
this(null, -1, target);
}
The Var class will wrap a ticker channel, and automatically create a thread-local ticker-consumer.
The method receive(long, TimeUnit) in the type ReceivePortGroup<Message> is not applicable for the arguments (ReceivePort<capture#1-
of ? extends Message>)
at co.paralleluniverse.strands.channels.ReceivePortGroup<Message>
public ReceivePortGroup(Collection<ReceivePort<? extends Message>> ports)
See https://github.com/danielnorberg/quasar-crash for repro.
I'm using JDK 8u20 and co.paralleluniverse:quasar-core:jar:jdk8:0.6.0.
Exception in Fiber "fiber-10001002" java.lang.IllegalMonitorStateException: attempt by Fiber@10001002[task: ParkableForkJoinTask@56fa8d0b(Fiber@10001002), target: co.paralleluniverse.strands.SuspendableUtils$VoidSuspendableCallable@4c33bede, scheduler: co.paralleluniverse.fibers.FiberForkJoinScheduler@ef9bc95] but owned by null
at co.paralleluniverse.strands.OwnedSynchronizer.register(OwnedSynchronizer.java:36)
at co.paralleluniverse.strands.channels.QueueChannel.receive(QueueChannel.java:332)
at QuasarCrashRepro.lambda$main$1f5289dc$2(QuasarCrashRepro.java:29)
at QuasarCrashRepro$$Lambda$2/1643691748.run(Unknown Source)
at co.paralleluniverse.strands.SuspendableUtils$VoidSuspendableCallable.run(SuspendableUtils.java:42)
at co.paralleluniverse.strands.SuspendableUtils$VoidSuspendableCallable.run(SuspendableUtils.java:30)
at co.paralleluniverse.fibers.Fiber.run(Fiber.java:1001)
It'd be great if pulsar actors could exchange messages directly with erlang processes.
Consider this a vague feature request :)
How this test case can pass when FiberAsync<String, Void, RuntimeException> does not have exact no. of arguments. This is defined as >
public abstract class FiberAsync<V, Callback, A, E extends Throwable>
It appear that, there is something which i am missing. Plz let me know.
Thanks
... it will optionally take a timeout argument.
With galaxy, we'll have to watch for changes to the cache-line.
In the Pong clone I'm developing using Quasar, (https://github.com/Freezerburn/libgdx-quasar-pong) I just started running into an issue where events are issues to one specific actor, but that actor never actually seems to receive any events. (I have print statements surrounding the call to receive(), and only the ones before it are printed)
Specifically, the Ball actor is the one not receiving events. This is causing the game to lock up, as the Ball will never proceed to arrive at any phasers, preventing any graphics from being drawn or input from being processed. (arguably input/graphics shouldn't have the ability to get stuck on phasers, but it's a good way to make sure everything is running smoothly at least, because when things aren't, this lock up happens)
This is off of quasar-core Github master, using the assembled jdk8 jars.
Actor's should be able to migrate from one machine to another on the Galaxy cluster.
Is there any easy mechanism to re-initialise the system between unit tests, or any best practice documentation on how to address this.
Currently I am have unit tests that run OK in isolation but fail if I run them all. It seems that the newly created actors don't become live and the tests just timeout.
I'm having a problem getting the Ant instrumentation to work, and need this for integration in build server.
I get this error:
[InstrumentationTask] ERROR: Unable to instrument class com/bnpp/fitt/scada/actors/ModelNode
BUILD FAILED
D:\Work2\trunk\Scada\model\build.xml:8: java.lang.NullPointerException
at org.objectweb.asm.Item.a(Unknown Source)
at org.objectweb.asm.ClassWriter.c(Unknown Source)
at org.objectweb.asm.ClassWriter.a(Unknown Source)
at org.objectweb.asm.Frame.a(Unknown Source)
at org.objectweb.asm.Frame.a(Unknown Source)
at org.objectweb.asm.MethodWriter.visitMaxs(Unknown Source)
at co.paralleluniverse.fibers.instrument.InstrumentMethod.accept(InstrumentMethod.java:415)
at co.paralleluniverse.fibers.instrument.InstrumentClass.visitEnd(InstrumentClass.java:241)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at co.paralleluniverse.fibers.instrument.QuasarInstrumentor.instrumentClass(QuasarInstrumentor.java:100)
at co.paralleluniverse.fibers.instrument.QuasarInstrumentor.instrumentClass(QuasarInstrumentor.java:86)
at co.paralleluniverse.fibers.instrument.InstrumentationTask.instrumentClass(InstrumentationTask.java:180)
at co.paralleluniverse.fibers.instrument.InstrumentationTask.execute(InstrumentationTask.java:167)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.Main.runBuild(Main.java:851)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
This class instruments OK with the command line javaagent call.
My ant script looks like this:
Is there something else that I need in the ant script? asm-all-5.0 gives same error.
ModelNode is an Actor and is the first Actor class it finds - so I suspect it's something systematic.
The register(name) method is broken, in 0.5.0, in Actor.java register method.
First off the test for wrong name does a "!name.equals(name)" which should be "!getName().equals(name)".
But then it calls setName, which then throws IllegalStateException if name is already set, even if its the same name. It would be better if register only called setName if getName() returns null.
I am running performance tests on FiberServerSocketChannel,
the test is very simple, it's dummy http server implementation that I try to load it, but the program behavior looks buggy.
I use some tool I wrote (you can use ab or any http benchmark tool you prefer):
https://github.com/cmpxchg16/gobench
when I ran that command (no keepalive, 4 clients, 10 seconds test):
$>go run gobench.go -k=false -u http://localhost:1234 -c 4 -t 10
I got ~reasonable results, but when I try 500 clients:
$>go run gobench.go -k=false -u http://localhost:1234 -c 500 -t 10
there are a lot of socket errors, and the throughput is very poor,
also when I repeat the test over and over the whole clients was failed and the server not responding at all.
Env:
Ubuntu 13.10
JDK7 && JDK8
4 cores
16GB RAM
fibers with javaagent 0.5.0
Note that for comparison I have some dummy implementation also in Go (below):
Server source code (based on test/fibers/io):
//###################################################################
package main;
import co.paralleluniverse.fibers.Fiber;
import co.paralleluniverse.fibers.FiberForkJoinScheduler;
import co.paralleluniverse.fibers.FiberScheduler;
import co.paralleluniverse.fibers.SuspendExecution;
import co.paralleluniverse.fibers.io.FiberServerSocketChannel;
import co.paralleluniverse.fibers.io.FiberSocketChannel;
import co.paralleluniverse.strands.SuspendableRunnable;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
public class Main {
private static final int PORT = 1234;
private static final Charset charset = Charset.forName("UTF-8");
private static final CharsetEncoder encoder = charset.newEncoder();
private static FiberScheduler scheduler = new FiberForkJoinScheduler("test", 4);
public static void main(String[] args) throws Exception {
final Fiber server = new Fiber(scheduler, new SuspendableRunnable() {
@Override
public void run() throws SuspendExecution {
try {
FiberServerSocketChannel socket = FiberServerSocketChannel.open().bind(new InetSocketAddress(PORT));
int counter = -1;
while(true)
{
FiberSocketChannel ch = socket.accept();
++counter;
ByteBuffer buf = ByteBuffer.allocateDirect(1024);
int n = ch.read(buf);
String response = "HTTP/1.0 200 OK\r\n" +
"Date: Fri, 31 Dec 1999 23:59:59 GMT\r\n" +
"Content-Type: text/html\r\n" +
"Content-Length: 0\r\n\r\n";
n = ch.write(encoder.encode(CharBuffer.wrap(response)));
ch.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
});
server.start();
server.join();
}
}
//###################################################################
//###################################################################
GO:
//###################################################################
package main
import (
"net"
"os"
"runtime"
)
const (
RECV_BUF_LEN = 1024
)
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
println("Starting the server")
listener, err := net.Listen("tcp", "0.0.0.0:1234")
if err != nil {
println("Error Listen:", err.Error())
os.Exit(1)
}
for {
conn, err := listener.Accept()
if err != nil {
println("Error Accept:", err.Error())
return
}
go Handler(conn)
}
}
func Handler(conn net.Conn) {
defer conn.Close()
buf := make([]byte, RECV_BUF_LEN)
_, err := conn.Read(buf)
if err != nil {
println("Error Read:", err.Error())
return
}
_, err = conn.Write([]byte("HTTP/1.0 200 OK\r\nDate: Fri, 31 Dec 1999 23:59:59 GMT\r\nContent-Type: text/html\r\nContent-Length: 0\r\n\r\n"))
if err != nil {
println("Error Write:", err.Error())
}
}
The POM is expected to be found at this url, but that returns a 404 error. This is strange because the file is listed as being in the parent folder.
This is a pretty big deal, because it means I can't use the latest version of quasar-core in my latest project without jumping through some hoops.
When running the spaceships-demo on my Windows 7 SP1 I get the error below.
I've got an Intel Core i7 X940 @ 2.13 GHz, 16 GB memory.
JVM is as follows:
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) Client VM (build 24.45-b08, mixed mode, sharing)
XXXXXX
java.lang.AssertionError: different array base
at co.paralleluniverse.data.record.SimpleRecord.<clinit>(SimpleRecord.java:578)
at co.paralleluniverse.data.record.SimpleRecordArray.newAccessor(SimpleRecordArray.java:68)
at co.paralleluniverse.data.record.SimpleRecordArray$1.<init>(SimpleRecordArray.java:108)
at co.paralleluniverse.data.record.SimpleRecordArray.iterator(SimpleRecordArray.java:107)
at co.paralleluniverse.spaceships.render.GLPort.display(GLPort.java:333)
at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:588)
at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:572)
at jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:379)
at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1034)
at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:909)
at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:608)
at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:74)
at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:440)
at com.jogamp.opengl.util.FPSAnimator$MainTask.run(FPSAnimator.java:167)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
Exception in thread "main-FPSAWTAnimator-Timer0" java.lang.AssertionError: different array base
at co.paralleluniverse.data.record.SimpleRecord.<clinit>(SimpleRecord.java:578)
at co.paralleluniverse.data.record.SimpleRecordArray.newAccessor(SimpleRecordArray.java:68)
at co.paralleluniverse.data.record.SimpleRecordArray$1.<init>(SimpleRecordArray.java:108)
at co.paralleluniverse.data.record.SimpleRecordArray.iterator(SimpleRecordArray.java:107)
at co.paralleluniverse.spaceships.render.GLPort.display(GLPort.java:333)
at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:588)
at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:572)
at jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:379)
at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLeHelper.java:1034)
at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:909)
at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:608)
at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:74)
at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:440)
at com.jogamp.opengl.util.FPSAnimator$MainTask.run(FPSAnimator.java:167)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
0 RATE: 0.0 fps
1 RATE: 0.0 fps
2 RATE: 0.0 fps
3 RATE: 0.0 fps
With the recent release of IntelliJ IDEA 13.1, they have integrated the Chronon debugger which records the execution of a Java program so you can play it back later. This requires instrumentation of the classes that the developer wants to record. If I try to do this when Quasar is enabled as the instrumentation agent, I get a couple IllegalArgumentExceptions, and Chronon fails to record anything. I'm currently assuming that the way Quasar and Chronon instrument code are fighting with each other, causing Chronon to be unable to do anything.
Title says it all. :)
Determine potentially blocking methods by analyzing the call graph. Don't require manual designation of methods as blocking.
git log v0.3.0..head --oneline | wc -l
shows ~270 commits from the last release.
I think it's a good idea to release a new version. What do you think?
I'm just going to put this warning out front directly: I don't know how to give a small test case for this to happen. I'm currently developing a test project attempting to learn a game engine and use quasar with it, and I hit this problem after updating to the latest master code, and started using the jdk8 version of quasar-core.
I can, however, provide the project I'm working on as a large-ish test case to show the problem I'm hitting. The actual problem is that it seems like quasar is attempting to suspend a fiber, and is casting a SuspendExecution to a RuntimeException. Java is then throwing up an error saying that it can't cast SuspendExecution to a RuntimeException. (co.paralleluniverse.actors.Actor:760, method checkThrownIn)
The project I am working on is here: https://github.com/Freezerburn/libgdx-quasar-pong
It's a pretty standalone project, and includes all the jars (including quasar) under a libs directory, so getting it running should be really easy. (just make sure it's running from the assets folder, so that it can find the fonts)
All the actual code I'm using when it runs is under com.unlockeddors.pong
receive returns null;
receive(ProcessManager) throws exception
Exception in thread "main" java.util.concurrent.ExecutionException: java.lang.ClassCastException: co.paralleluniverse.fibers.SuspendExecution cannot be cast to java.lang.RuntimeException
at jsr166e.ForkJoinTask.get(ForkJoinTask.java:960)
at co.paralleluniverse.fibers.Fiber.get(Fiber.java:1165)
at co.paralleluniverse.fibers.Fiber.join(Fiber.java:1155)
at co.paralleluniverse.actors.Actor.join(Actor.java:520)
at co.paralleluniverse.actors.LocalActorUtil.join(LocalActorUtil.java:38)
Caused by: java.lang.ClassCastException: co.paralleluniverse.fibers.SuspendExecution cannot be cast to java.lang.RuntimeException
at co.paralleluniverse.actors.Actor.checkThrownIn(Actor.java:688)
at co.paralleluniverse.actors.Actor.tryReceive(Actor.java:441)
at co.paralleluniverse.actors.Actor.run(Actor.java:571)
at co.paralleluniverse.fibers.Fiber.run(Fiber.java:905)
at co.paralleluniverse.fibers.Fiber.run1(Fiber.java:900)
at co.paralleluniverse.fibers.Fiber.exec1(Fiber.java:659)
at co.paralleluniverse.fibers.Fiber.access$100(Fiber.java:64)
at co.paralleluniverse.fibers.Fiber$FiberForkJoinTask.exec1(Fiber.java:1428)
at co.paralleluniverse.concurrent.forkjoin.ParkableForkJoinTask.doExec(ParkableForkJoinTask.java:107)
at co.paralleluniverse.concurrent.forkjoin.ParkableForkJoinTask.exec(ParkableForkJoinTask.java:69)
at co.paralleluniverse.fibers.Fiber$FiberForkJoinTask.exec(Fiber.java:1502)
at jsr166e.ForkJoinTask.doExec(ForkJoinTask.java:261)
at jsr166e.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:988)
at jsr166e.ForkJoinPool.runWorker(ForkJoinPool.java:1628)
at jsr166e.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Looks like a file not found, can the build.gradle file be regenerated to point to an updated version? I'm not at all familiar with gradle myself, but it's convenient to get the quasar-*.jar file.
Downloading http://services.gradle.org/distributions-snapshots/gradle-1.5-20130302103424+0000-bin.zip
Exception in thread "main" java.io.FileNotFoundException: http://downloads.gradle.org/distributions-snapshots/gradle-1.5-20130302103424+0000-bin.zip
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1610)
at org.gradle.wrapper.Download.downloadInternal(Download.java:61)
at org.gradle.wrapper.Download.download(Download.java:49)
at org.gradle.wrapper.Install.createDist(Install.java:51)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:47)
If possible, allow fibers to be started again after they terminate...
Like an IO selector
Hi!
When running the unit test of the server, or FiberServerSocketChannel with dummy main inside infinite loop for infinite connections handling, the first client (external tcp client) success, the second cause to BindException.
can you please also add such real dummy server example (e.g echoserver).
Thanks!
forEach
would take a suspendable op (SuspendableRunnable).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.