Fibers, Channels and Actors for the JVM

Overview

Quasar
Fibers, Channels and Actors for the JVM

Build Status Version License License

Getting started

Add the following Maven/Gradle dependencies:

Feature Artifact
Core (required) co.paralleluniverse:quasar-core:0.8.0
Actors co.paralleluniverse:quasar-actors:0.8.0
Reactive Streams co.paralleluniverse:quasar-reactive-streams:0.8.0
Disruptor Channels co.paralleluniverse:quasar-disruptor:0.8.0
Kotlin (JDK8+) co.paralleluniverse:quasar-kotlin:0.8.0

Or, build from sources by running:

./gradlew install

Usage

You can also study the examples here.

You can also read the introductory blog post.

When running code that uses Quasar, the instrumentation agent must be run by adding this to the java command line:

-javaagent:path-to-quasar-jar.jar

Related Projects

  • Pulsar is Quasar's extra-cool Clojure API
  • Comsat integrates Quasar with the JVM's web APIs

Getting help

Please make sure to double-check the System Requirements and Troubleshooting sections of the docs, as well as at currently open issues.

Questions and suggestions are welcome at this forum/mailing list.

You can also open a new GitHub issue especially for bug reports and feature requests but if you're not sure please first get in touch with the community through the forum/mailing list.

Contributions (including Pull Requests)

Please have a look at some brief information for contributors.

License

Quasar is free software published under the following license:

Copyright (c) 2013-2018, Parallel Universe Software Co. All rights reserved.

This program and the accompanying materials are dual-licensed under
either the terms of the Eclipse Public License v1.0 as published by
the Eclipse Foundation

  or (per the licensee's choosing)

under the terms of the GNU Lesser General Public License version 3.0
as published by the Free Software Foundation.
Comments
  • Performance test

    Performance test

    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())
            }
    }
    
    opened by cmpxchg16 47
  • Fiber class com.ailk.TestQuasar$1 has not been instrumented.

    Fiber class com.ailk.TestQuasar$1 has not been instrumented.

    I write a sample.but when i run it.

    QUASAR WARNING: Quasar Java Agent isn't running. If you're using another instrumentation method you can ignore this message; otherwise, please refer to the Getting Started section in the Quasar documentation. Exception in thread "main" java.lang.IllegalArgumentException: Fiber class com.ailk.TestQuasar$1 has not been instrumented.

    question 
    opened by GeekTemo 36
  • Allow ThreadLocal manipulation/serialisation to be disabled

    Allow ThreadLocal manipulation/serialisation to be disabled

    So far this feature is a massive net negative, at least for me. Things put in ThreadLocal's are invariably not designed to be serialised, it involves poking around in JVM internals and the JVM treats ThreadLocal's specially - back when I was hitting serialisation issues the JVM would segfault due to the use of Unsafe.

    Overall, I'd rather have a flag to disable this and have Quasar leave TLS slots alone.

    opened by mikehearn 35
  • RequestReplyHelper call-chain exceptions

    RequestReplyHelper call-chain exceptions

    (Copied from: https://groups.google.com/forum/#!topic/quasar-pulsar-user/wkENHH0xAIQ)

    If you would consider the following pattern:

    public class Start extends BasicActor<Object, Void> {
        @Override
        protected Void doRun() throws InterruptedException, SuspendExecution {
            Object call = RequestReplyHelper.call(new Mid().spawn(), new RequestMessage<Object>() {
            });
            System.out.println(call);
            return null;
        }
    }
    
    public class Mid extends BasicActor<RequestMessage<Object>, Void> {
        @Override
        protected Void doRun() throws InterruptedException, SuspendExecution {
            RequestMessage<Object> receive = receive();
            ActorRef<RequestMessage<Object>> spawn = new End().spawn();
            Object call = RequestReplyHelper.call(spawn, receive);
            RequestReplyHelper.reply(receive, call);
            return null;
        }
    }
    
    public class End extends BasicActor<RequestMessage<Object>, Void> {
        @Override
        protected Void doRun() throws InterruptedException, SuspendExecution {
            RequestMessage<Object> receive = receive();
            RequestReplyHelper.reply(receive, new Object());
            return null;
        }
    }
    
    new Start().spawn();
    

    The behavior works fine. However, the following exception (see below) chain is thrown in relation to ExitMessage signaling (?). This seems like a RequestReplyHelper chain issue. Is there anything wrong with the code above? Thanks

    java.lang.Object@7f681f5 Exception in Fiber "fiber-10000004" java.lang.RuntimeException at co.paralleluniverse.common.util.Exceptions.rethrow(Exceptions.java:26) at co.paralleluniverse.actors.behaviors.RequestReplyHelper$1.handleLifecycleMessage(RequestReplyHelper.java:167) at co.paralleluniverse.actors.SelectiveReceiveHelper.receive(SelectiveReceiveHelper.java:121) at co.paralleluniverse.actors.behaviors.RequestReplyHelper.call(RequestReplyHelper.java:174) at co.paralleluniverse.actors.behaviors.RequestReplyHelper.call(RequestReplyHelper.java:112) at com.xxx.services.rest.temp.Mid.doRun(Mid.java:17) at com.xxx.services.rest.temp.Mid.doRun(Mid.java:12) at co.paralleluniverse.actors.Actor.run0(Actor.java:691) at co.paralleluniverse.actors.ActorRunner.run(ActorRunner.java:51) at co.paralleluniverse.fibers.Fiber.run(Fiber.java:1026) WARNING: Uninstrumented methods (marked '') or call-sites (marked '!!') detected on the call stack: at co.paralleluniverse.common.util.Exceptions.rethrow(java.lang.Throwable) (Exceptions.java:26 bci: 29) ** at co.paralleluniverse.actors.behaviors.RequestReplyHelper$1.handleLifecycleMessage (RequestReplyHelper.java:167 bci: 41) ** at co.paralleluniverse.actors.SelectiveReceiveHelper.receive (SelectiveReceiveHelper.java:121 bci: 341) !! (instrumented suspendable calls at: []) at co.paralleluniverse.actors.behaviors.RequestReplyHelper.call (RequestReplyHelper.java:174 bci: 663) at co.paralleluniverse.actors.behaviors.RequestReplyHelper.call (RequestReplyHelper.java:112 bci: 335) at com.xxx.services.rest.temp.Mid.doRun (Mid.java:17 bci: 192) at com.xxx.services.rest.temp.Mid.doRun (Mid.java:12 bci: 1) (optimized) at co.paralleluniverse.actors.Actor.run0 (Actor.java:691 bci: 222) at co.paralleluniverse.actors.ActorRunner.run (ActorRunner.java:51 bci: 148) at co.paralleluniverse.fibers.Fiber.run (Fiber.java:1026 bci: 11) at co.paralleluniverse.fibers.Fiber.run1 (Fiber.java:1021 bci: 1) Exception in Fiber "fiber-10000004" java.lang.RuntimeException at co.paralleluniverse.common.util.Exceptions.rethrow(Exceptions.java:26) at co.paralleluniverse.actors.behaviors.RequestReplyHelper$1.handleLifecycleMessage(RequestReplyHelper.java:167) at co.paralleluniverse.actors.SelectiveReceiveHelper.receive(SelectiveReceiveHelper.java:121) at co.paralleluniverse.actors.behaviors.RequestReplyHelper.call(RequestReplyHelper.java:174) at co.paralleluniverse.actors.behaviors.RequestReplyHelper.call(RequestReplyHelper.java:112) at com.xxx.services.rest.temp.Mid.doRun(Mid.java:17) at com.xxx.services.rest.temp.Mid.doRun(Mid.java:12) at co.paralleluniverse.actors.Actor.run0(Actor.java:691) at co.paralleluniverse.actors.ActorRunner.run(ActorRunner.java:51) at co.paralleluniverse.fibers.Fiber.run(Fiber.java:1026) WARNING: Uninstrumented methods (marked '') or call-sites (marked '!!') detected on the call stack: at co.paralleluniverse.common.util.Exceptions.rethrow(java.lang.Throwable) (Exceptions.java:26 bci: 29) ** at co.paralleluniverse.actors.behaviors.RequestReplyHelper$1.handleLifecycleMessage (RequestReplyHelper.java:167 bci: 41) ** at co.paralleluniverse.actors.SelectiveReceiveHelper.receive (SelectiveReceiveHelper.java:121 bci: 341) !! (instrumented suspendable calls at: []) at co.paralleluniverse.actors.behaviors.RequestReplyHelper.call (RequestReplyHelper.java:174 bci: 663) at co.paralleluniverse.actors.behaviors.RequestReplyHelper.call (RequestReplyHelper.java:112 bci: 335) at com.xxx.services.rest.temp.Mid.doRun (Mid.java:17 bci: 192) at com.xxx.services.rest.temp.Mid.doRun (Mid.java:12 bci: 1) (optimized) at co.paralleluniverse.actors.Actor.run0 (Actor.java:691 bci: 222) at co.paralleluniverse.actors.ActorRunner.run (ActorRunner.java:51 bci: 148) at co.paralleluniverse.fibers.Fiber.run (Fiber.java:1026 bci: 11) at co.paralleluniverse.fibers.Fiber.run1 (Fiber.java:1021 bci: 1)

    opened by roded 30
  • Making `SuspendableCallable @Suspendable { .. }` work again with Kotlin

    Making `SuspendableCallable @Suspendable { .. }` work again with Kotlin

    Since M13 was pushed out the co.paralleluniverse.fibers.Suspendable annotation can no longer be applied to a lambda as it could before because the annotation now needs to have the Kotlin target AnnotationTarget.EXPRESSION or else it will simply not compile. An example would be:

    @Suspendable {
        println("Hi")
    }
    

    The above does not compile anymore because the annotation misses the target. I replaced the class by a custom variant using the Kotlin expression type:

    package co.paralleluniverse.fibers
    
    import kotlin.annotation.Retention
    import kotlin.annotation.Target
    
    @Retention // Defaults to RUNTIME
    @Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER,
            AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.CLASS,
            AnnotationTarget.FILE, AnnotationTarget.EXPRESSION)
    
    annotation public class Suspendable
    

    That does compile fine and results in compilation succeeding for the previously described example. However, replacing the packaged Suspendable annotation with the custom Kotlin variant seems to break the library (it does not detect instrumented methods anymore), so I'm looking for some kind of input on having this nifty feature working again.

    Cheers.

    bug 
    opened by Velocity- 27
  • RequestReplyHelper#call fails with IllegalMonitorStateException

    RequestReplyHelper#call fails with IllegalMonitorStateException

    Hey. First, I apologize for not being able to share all the code reproducing the problem which happens quite rarely (it seems like there is a race condition somewhere). But I can describe environment in some words - we have complex actor's interaction algorithm at our actor system, some of them are communicating via RequestReplyHelper#call. And sometimes this exception raises. The problems are

    1. I don't have enough knowledge about actors mailbox queue internals, and don't understand what happens
    2. There isn't lots of javadoc comments such internal classes like SingleConsumerQueueChannel, OwnedSynchronizer

    So its hard for me to reason about the source of this exception. Could you help me to find out are we doing something wrong or is this a bug in quasar-actors? It would be great if you've already encountered this problem and know the mistakes we are doing. Thanks.

    java.lang.IllegalMonitorStateException: attempt by Fiber@10000046:Communicator[task: ParkableForkJoinTask@56d103cb(Fiber@10000046), target: co.paralleluniverse.actors.ActorRunner@2c27afe, scheduler: co.paralleluniverse.fibers.FiberForkJoinScheduler@6a9637db] but owned by Fiber@10000046:Communicator[task: ParkableForkJoinTask@56d103cb(Fiber@10000046), target: co.paralleluniverse.actors.ActorRunner@2c27afe, scheduler: co.paralleluniverse.fibers.FiberForkJoinScheduler@6a9637db]
        at co.paralleluniverse.strands.OwnedSynchronizer.register(OwnedSynchronizer.java:36)
        at co.paralleluniverse.strands.channels.SingleConsumerQueueChannel.receive(SingleConsumerQueueChannel.java:87)
        at co.paralleluniverse.actors.Actor.receive(Actor.java:462)
        at co.paralleluniverse.actors.behaviors.BehaviorActor.behavior(BehaviorActor.java:236)
        at co.paralleluniverse.actors.behaviors.BehaviorActor.doRun(BehaviorActor.java:293)
        at co.paralleluniverse.actors.behaviors.BehaviorActor.doRun(BehaviorActor.java:36)
        at co.paralleluniverse.actors.Actor.run0(Actor.java:691)
        at co.paralleluniverse.actors.ActorRunner.run(ActorRunner.java:51)
        at co.paralleluniverse.fibers.Fiber.run(Fiber.java:1024)
        at co.paralleluniverse.fibers.Fiber.run1(Fiber.java:1019)
        at co.paralleluniverse.fibers.Fiber.exec(Fiber.java:730)
        at co.paralleluniverse.fibers.FiberForkJoinScheduler$FiberForkJoinTask.exec1(FiberForkJoinScheduler.java:265)
        at co.paralleluniverse.concurrent.forkjoin.ParkableForkJoinTask.doExec(ParkableForkJoinTask.java:116)
        at co.paralleluniverse.concurrent.forkjoin.ParkableForkJoinTask.exec(ParkableForkJoinTask.java:73)
        at co.paralleluniverse.fibers.FiberForkJoinScheduler$FiberForkJoinTask.doExec(FiberForkJoinScheduler.java:272)
        at co.paralleluniverse.fibers.Fiber.immediateExecHelper(Fiber.java:1205)
        at co.paralleluniverse.fibers.Fiber.exec(Fiber.java:1173)
        at co.paralleluniverse.fibers.Fiber.yieldAndUnpark1(Fiber.java:691)
        at co.paralleluniverse.fibers.Fiber.yieldAndUnpark(Fiber.java:619)
        at co.paralleluniverse.strands.Strand.yieldAndUnpark(Strand.java:531)
        at co.paralleluniverse.strands.OwnedSynchronizer.signalAndWait(OwnedSynchronizer.java:66)
        at co.paralleluniverse.strands.channels.QueueChannel.signalAndWait(QueueChannel.java:109)
        at co.paralleluniverse.strands.channels.QueueChannel.send0(QueueChannel.java:245)
        at co.paralleluniverse.strands.channels.QueueChannel.sendSync(QueueChannel.java:204)
        at co.paralleluniverse.actors.Mailbox.sendSync(Mailbox.java:73)
        at co.paralleluniverse.actors.Actor.sendSync(Actor.java:429)
        at co.paralleluniverse.actors.ActorRef.sendSync(ActorRef.java:97)
        at co.paralleluniverse.actors.behaviors.RequestReplyHelper.call(RequestReplyHelper.java:173)
        at co.paralleluniverse.actors.behaviors.RequestReplyHelper.call(RequestReplyHelper.java:112)
    
    opened by hsestupin 22
  • Calling ReentrantLock.lock() ends with NPE

    Calling ReentrantLock.lock() ends with NPE

    After calling ReentrantLock.lock() the following is thrown:

    java.lang.NullPointerException
        at co.paralleluniverse.strands.Strand.park(Strand.java:495)
        at co.paralleluniverse.strands.concurrent.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:838)
        at co.paralleluniverse.strands.concurrent.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:872)
        at co.paralleluniverse.strands.concurrent.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1203)
        at co.paralleluniverse.strands.concurrent.ReentrantLock$NonfairSync.lock(ReentrantLock.java:207)
        at co.paralleluniverse.strands.concurrent.ReentrantLock.lock(ReentrantLock.java:285)
        (...)
        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:1012)
        at co.paralleluniverse.fibers.Fiber.run1(Fiber.java:1007)
        at co.paralleluniverse.fibers.Fiber.exec(Fiber.java:719)
        at co.paralleluniverse.fibers.FiberForkJoinScheduler$FiberForkJoinTask.exec1(FiberForkJoinScheduler.java:248)
        at co.paralleluniverse.concurrent.forkjoin.ParkableForkJoinTask.doExec(ParkableForkJoinTask.java:116)
        at co.paralleluniverse.concurrent.forkjoin.ParkableForkJoinTask.exec(ParkableForkJoinTask.java:73)
        at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
        at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:902)
        at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1689)
        at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1644)
        at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
    
    opened by mnowrot 22
  • Allow Fibers to have a priority

    Allow Fibers to have a priority

    I'd like to request a feature. Allowing fibers to set priorities would be, in my opinion, a wonderful enhancement.

    This is a major feature that threads have over fibers. From the User Manual:

    Fibers provide functionality similar to threads, and a similar API, but they’re not managed by the OS.

    Setting a priority is a major feature of threads over fibers. If this is added to the fiber (and strand) API, this would make fibers even more powerful.

    Edit: To clarify, since Fibers use a non-preemptive scheduler and are OS independent, I am suggesting to only use the same API as threads, but not the same (OS dependent) prioritization approach as threads. I think the most straight forward approach may be to implement priorities such that:

    • Any fiber with a high priority will be started on a worker thread before (or at the same time as) a fiber with a low priority.
    • Any already running fibers with a low priority will remain running until they block as normal.
    • The priority should only dictate the order in which to run queued fibers, and will not affect already running fibers in any way.
    • Priorities can be changed at any time and by anyone with a reference to the Fiber.
    • Any change in priority will not have any affect until the next time a fiber blocks and a new fiber is selected to run.
    • By default, a fiber will have the same priority as the strand that spawned it.
    enhancement 
    opened by disposableme 21
  • Is it possible to combine channels and serialisation?

    Is it possible to combine channels and serialisation?

    It isn't clear to me how to use the serialisation framework. Imagine I have a fiber that's blocked waiting to receive something on a channel. Before blocking, I'd like to serialise the state of the fiber to checkpoint it, so if the app dies whilst the fiber is waiting, I can reload it from disk and restart it. But I can't combine the two as the serialisation support requires use of the lower level parkAndSerialise method.

    opened by mikehearn 21
  • Messages to actors are lost under heavy load

    Messages to actors are lost under heavy load

    Sometimes under heavy load and using cascading messages, some messages seem to get lost. When monitoring the actors, the number of received messages for some actors are too low.

    I have attached a small sample project. I have to run the sample 3-5 times for the problem to occur.

    Please keep in mind, that I am new to Quasar and might be doing something completely wrong.

    Test environment Macbook Pro:

    • 2,5 GHz Intel Core i7
    • 16 GB RAM
    • OSX 10.11.5

    Java:

    • Oracle Java 1.8.0_60-b27 server vm
    • Maven 3.0.5 to build and run

    bugreport.zip

    bug 
    opened by scameronde 20
  • [Kotlin] Fibers created with `fiber` have uninstrumented frames with AOT when not `@Suspendable`

    [Kotlin] Fibers created with `fiber` have uninstrumented frames with AOT when not `@Suspendable`

    Hi @pron !

    I remember it was possible to call fibers without @Suspendable, but now I see it's mandatory. Is it possible somehow to avoid it? I'm developing the DSL and it's a bit ugly to add @Suspendable everywhere in human-readable DSL :(

    Thanks!

    bug enhancement 
    opened by bsideup 19
  • Provide functional style API?

    Provide functional style API?

    Now, when I try to start a Fiber, I have to use generated code similar to traditional Thread

    Fiber<Void> echo = new Fiber<Void>("ECHO", () -> { // lambda }).start();

    Can you consider a functional programming style that provides a pattern for chained operators.

    like: go(() -> { /* lambda */ });

    This will make it easier for me in the chain call.

    opened by kevinten10 1
  • FATAL ERROR in native method: processing of -javaagent failed?

    FATAL ERROR in native method: processing of -javaagent failed?

    help! run failed image

    env:jdk1.8 ,win10

    dependency: org.springframework.boot spring-boot-starter 2.2.10.RELEASE co.paralleluniverse quasar-core 0.7.10 co.paralleluniverse quasar-actors 0.7.10

    package: image

    opened by Shaun-wang 0
  • do you forget something in  co.paralleluniverse.common.util.UtilUnsafe  class?

    do you forget something in co.paralleluniverse.common.util.UtilUnsafe class?

      public static Unsafe getUnsafe() {
            try {
                return Unsafe.getUnsafe();
            } catch (SecurityException se) {
                try {
                    return java.security.AccessController.doPrivileged(new java.security.PrivilegedExceptionAction<Unsafe>() {
                        @Override
                        public Unsafe run() throws Exception {
                            final Class<sun.misc.Unsafe> k = sun.misc.Unsafe.class;
                            if (true) {
                                final Field f = k.getDeclaredField("theUnsafe");
                                f.setAccessible(true);
                                final Object x = f.get(null);
                                return k.cast(x);
                            } else {
                                for (Field f : k.getDeclaredFields()) {
                                    f.setAccessible(true);
                                    final Object x = f.get(null);
                                    if (k.isInstance(x))
                                        return k.cast(x);
                                }
                                throw new NoSuchFieldError("the Unsafe");
                            }
                        }
                    });
                } catch (java.security.PrivilegedActionException e) {
                    throw new RuntimeException("Could not initialize intrinsics", e.getCause());
                }
            }
        }
    

    why would you use "if(true) .... else ..." in this method? do you forget to fill the expression of if?

    opened by mashirofang 0
  • Version 0.8.0 fails to instrument Java 11 classes

    Version 0.8.0 fails to instrument Java 11 classes

    When I migrated to Java 11 and quasar 0.8.0 and Vertx core 4.0.0-milestone5. The following errors were encountered. The first is that quasar fails to instrument any class - failing out of the box with this Exception:

    [quasar] ERROR: java/lang/Object java.lang.IllegalArgumentException at co.paralleluniverse.asm.ClassReader.(Unknown Source) at co.paralleluniverse.asm.ClassReader.(Unknown Source) at co.paralleluniverse.asm.ClassReader.(Unknown Source) at co.paralleluniverse.fibers.instrument.MethodDatabase.checkFileAndClose(MethodDatabase.java:344) at co.paralleluniverse.fibers.instrument.MethodDatabase.checkClass(MethodDatabase.java:324) at co.paralleluniverse.fibers.instrument.MethodDatabase.getOrLoadClassEntry(MethodDatabase.java:183) at co.paralleluniverse.fibers.instrument.SimpleSuspendableClassifier.isSuspendable(SimpleSuspendableClassifier.java:156) at co.paralleluniverse.fibers.instrument.SimpleSuspendableClassifier.isSuspendable(SimpleSuspendableClassifier.java:164) at co.paralleluniverse.fibers.instrument.DefaultSuspendableClassifier.isSuspendable(DefaultSuspendableClassifier.java:47) at co.paralleluniverse.fibers.instrument.InstrumentClass.visitMethod(InstrumentClass.java:147) at co.paralleluniverse.asm.ClassReader.b(Unknown Source) at co.paralleluniverse.asm.ClassReader.accept(Unknown Source) at co.paralleluniverse.asm.ClassReader.accept(Unknown Source) at co.paralleluniverse.fibers.instrument.QuasarInstrumentor.instrumentClass(QuasarInstrumentor.java:134) at co.paralleluniverse.fibers.instrument.QuasarInstrumentor.instrumentClass(QuasarInstrumentor.java:94) at co.paralleluniverse.fibers.instrument.JavaAgent$Transformer.transform(JavaAgent.java:209) at java.instrument/java.lang.instrument.ClassFileTransformer.transform(ClassFileTransformer.java:246) at java.instrument/sun.instrument.TransformerManager.transform(TransformerManager.java:188) at java.instrument/sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:563) at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016) at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174) at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802) at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:59) at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:50) at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150) at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124) at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:388) at com.hotleads.web.app.MainApplication.(MainApplication.java:17)

    However when I change SDK to Java 1.8 and quasar 0.7.5 and Vertx core 4.0.0-milestone2, things work as expected. Note - that this may not be a Vertx-Quasar issue. When the SDK is changed to Java 11 - quasar fails to instrument every single class at runtime. Please advise. Having to keep my platform at 1.8 is not advisable and migrating to Java 11 using quasar 0.8.0 fails out the box. What am I missing?

    opened by jbrinnand 0
  • added workaround for https://youtrack.jetbrains.com/issue/KT-30289

    added workaround for https://youtrack.jetbrains.com/issue/KT-30289

    this should fix quasar issue with Kotlin 1.3, the idea is to instrument any static synthetic method whose name ends with $default if it comes after a suspendable method with the same name (except for the $default suffix) and a similar signature (more details about it will follow).

    I did some manual testing and it seems to work, it relies on the fact that the Kotlin compiler writes the $default methods only after their base counterparts (which could be problematic since, although this is the current behavior, there is no guarantee around its stability).

    opened by woggioni 0
Releases(v0.8.0)
  • v0.8.0(Nov 2, 2018)

    • Supports JDK 11
    • Dropped support of JDK 7 and 8
    • Modularized
    • The quasar-galaxy module has been removed
    • The co.paralleluniverse.data.record has been removed from the quasar-actors module.
    • Added support for custom fiber serializers
    • Suppports Kotlin 1.3
    Source code(tar.gz)
    Source code(zip)
  • v0.7.10(Jun 10, 2018)

  • v0.7.9(Jul 28, 2017)

    Enhancements

    • Suppport for Kotlin 1.1

    Bug Fixes

    • Fixed memory leak through fiber stack under certain circumstances (#282)
    • Fixed regression of verifyInstrumentation (#280, #279)
    • Registered actors stop their (JMX) monitors when deregistered
    • Fixed documentation of actor's mailbox overflow policy (#283)
    • Various small fixes.
    Source code(tar.gz)
    Source code(zip)
  • v0.7.8(May 24, 2017)

    Enhancements

    • Improved reporting of instrumentation problems with verifyInstrumentation (#238, #255)
    • Interrupting FiberAsync.runBlocking interrupts the thread executing the operation (#245)
    • Java agent can be configured to exclude packages from instrumentation in order to improve startup time (#243)
    • ExitMessages received from actors after they've been unlinked/unwatched will be ignored (#163)

    Bug Fixes

    Various small fixes.

    Source code(tar.gz)
    Source code(zip)
  • v0.7.7(Dec 2, 2016)

  • v0.7.6(Aug 7, 2016)

    This release contains a fix to a major bug

    #204

    a fix to a medium-severity bug

    #212

    an improvement to handling multiple class loaders

    #196

    as well as minor bug fixes.

    Source code(tar.gz)
    Source code(zip)
  • v0.7.5(May 2, 2016)

    New features

    • https://github.com/puniverse/quasar/commit/9c0b63a0bfba4cda391011776ce2217d67dbf42a by @mikehearn: ThreadLocals serialization in fibers is now optional

    Improvements

    • https://github.com/puniverse/quasar/commit/f37b8c892a80bef52cfe31aa0d9005bf5eed6606, https://github.com/puniverse/quasar/commit/08583f1df951b41edd50fbc96182cd76dd7b5cbb and https://github.com/puniverse/quasar/commit/80802e49dc0a0463d13e7c054a08514e3d5e7a09: Substantial performance improvements in several areas
    • https://github.com/puniverse/quasar/commit/269d73a67a572a4ef0656847ee908a05b055a0f1 and https://github.com/puniverse/quasar/commit/0057c2869fd1c602bd2febd634850f3ab206e164: Improved ThreadLocals serialization in fibers
    • https://github.com/puniverse/quasar/commit/842ed49247b2b33102776462a85b0fce1cc581bf: Support for blocking handlers, https://github.com/puniverse/pulsar/issues/55
    • Various deps upgrades, including Kotlin -> 1.0.1-2

    Closed issues

    • [CRITICAL] #185: Strands synchronization race
    • #176: Possible TransferChannel race
    • #154: Minor docs typos
    • #159: Kotlin upgrade
    • #156: Exception in fiber prints stack trace twice
    • #160 by @LesNovell: JavaAgent.transform not checking for null className
    • #168: Failing suspendable lambda case
    • https://github.com/puniverse/quasar/commit/14d7f2f414910a2251a428bf6385ddf886afea5e related to #146 by @cbeams: Exclude from instrumentation shaded variant of Kotlin's ModuleDescriptorImpl
    • https://github.com/puniverse/quasar/commit/685e89df55f076a0f2ab4305acea59b700ed9146 by @Latros: Typo
    • #173: Monitored ProxyServerActors do not provide correct stats in MXBean
    • https://github.com/puniverse/quasar/commit/c8ba7e42c5d9b6d23ab5d7800ff225fbda0d439e by @remen: Typo
    • https://github.com/puniverse/quasar/commit/98ee54b733250517bf49f840baba1b82b4a06cb2: Wait longer in select, thanks and related to https://groups.google.com/forum/#!topic/quasar-pulsar-user/U2ztEdoPFqw with Chris Pennello
    • #186: MessageSelector.select() results requires cast to MessageSelector<Object,Object> in order to be used
    Source code(tar.gz)
    Source code(zip)
  • v0.7.4(Jan 18, 2016)

  • v0.7.3(Aug 28, 2015)

    Breaking changes

    • Kotlin's fiber function has been moved to the co.paralleluniverse.kotlin package, has several convenient overloads and by default will also start the fiber.

    New features

    • co.paralleluniverse.kotlin also includes a convenient select syntax to perform channel selection:
    val ch1 = Channels.newChannel<Int>(1)
    val ch2 = Channels.newChannel<Int>(1)
    
    assertTrue (
        fiber {
            select(Receive(ch1), Send(ch2, 2)) {
                it
            }
        }.get() is Send
    )
    
    ch1.send(1)
    
    assertTrue (
        fiber {
            select(Receive(ch1), Send(ch2, 2)) {
                when (it) {
                    is Receive -> it.msg
                    is Send -> 0
                    else -> -1
                }
            }
        }.get() == 1
    )
    
    • The new FiberForkJoinScheduler.onIdle() hook notifies when the fiber scheduler becomes idle.

    Improvements

    • Several dependencies upgraded

    Closed issues:

    • #111
    • #110
    • #109
    • #108
    • #106
    • #104
    • #102
    • https://github.com/puniverse/quasar/commit/1f946ed13bfa7566eead39845c73c3787a75790a
    • https://github.com/puniverse/quasar/commit/e755bf5
    • https://github.com/puniverse/quasar/commit/0f65292b649b90050bbd85cee1b10b837c97d0dd
    • https://github.com/puniverse/quasar/commit/6612b71e38af8db154aecc19f084bf3fc5376ae6
    Source code(tar.gz)
    Source code(zip)
  • v0.7.2(Jun 25, 2015)

    New features:

    • A fully TCK-compliant Reactive Streams implementation based on Quasar Channels in the quasar-reactive-streams module

    Improvements:

    • Instrumentation optimisation has been introduced: methods that don't need instrumentation will be left untouched and this improves performance
    • Instrumentation verification is more precise, it checks call sites (see #86) and it prints extended stack trace information on HotSpot JRE 8; in addition it works even without verification enabled (and without performance penalty) when an uncaught exception is thrown in a fiber
    • Improved JDK8-optimised build, no duplicate classes anymore (see #91)
    • Minor channels improvements and fixes
    • Kotlin upgraded to 0.12.613(post-M12) and several other dependencies upgrade
    • The @Suspendable annotation is now supported on individual interface methods rather than just on the whole interface

    Closed issues:

    • #86
    • #91
    • #93
    • #94
    • #95
    • #96
    • A minor issue in scanSuspendables has been addressed, it sometimes included unnecessary (but harmless) lines in suspendable-supers

    Notes:

    • The Gradle wrapper has been removed to simplify the codebase and its maintenance. If you're building Quasar locally just install the latest Gradle distribution before doing so and use plain gradle
    Source code(tar.gz)
    Source code(zip)
  • v0.7.0(May 29, 2015)

    Breaking changes:

    • FiberSocketChannel and FiberServerSocketChannel are created passing a ChannelGroup rather than an AsynchronousChannelGroup; this makes them independent from the async channels API
    • quasar-core is now a provided dependency for quasar-actors and quasar-galaxy rather than a compile one

    New features:

    • Initial Kotlin support (quasar-kotlin module)
    • StrandFactory API
    • Additional transforming channels for take, reduce, split operations
    • ReceivePortGroup now supports additional mix-style operations
    • Pipeline channel transfer utility
    • Additional FiberSocketChannel.connect() with timeout
    • New Java8 lambdas API for ports
    • New FiniteStateMachine behavior
    • getChildren in supervisor actors

    Improvements:

    • Faster fiber stack layout and improved fiber stack management performance
    • Improved buffered channels performance
    • ProxyServer performance improvement
    • Migration from glib to byte-buddy
    • Dependencies upgrade

    Closed issues:

    • #73
    • #74
    • #76
    • #78
    • #79
    • #81
    • #82
    • #87
    • #90
    • Fix possible SupervisorActor NPE
    • Duplicate files in quasar-core-jdk8.jar
    • Possible instrumentation problem with conditionally initialized arrays
    Source code(tar.gz)
    Source code(zip)
  • v0.6.2(Dec 23, 2014)

    This is a bug-fix release. Fixed bugs include:

    • #65
    • #66
    • #67
    • #68

    In addition, quasar-core now embeds shadowed ASM artifacts rather than externally depending on ASM.

    Source code(tar.gz)
    Source code(zip)
  • v0.6.1(Sep 23, 2014)

  • v0.6.0(Jul 23, 2014)

    New Features:

    • Automatic suspendable method detection
    • Fiber serialization
    • Actor migration
    • Dataflow variables

    Changes and Improvements

    • Fiber.join and Fiber.get are now suspendable rather than thread-blocking. This should improve join performance.
    • co.paralleluniverse.strands.channels.DelayVal is now co.paralleluniverse.strands.dataflow.Val
    • FiberAsync has been simplified
    • Much improved fiber-blocking NIO performance
    Source code(tar.gz)
    Source code(zip)
  • v0.5.0(Mar 26, 2014)

    Quasar 0.5.0 Release Notes

    • Support for JDK 8
    • Propagate an exception through a channel with SendPort.close(Throwable).
    • Additional channel transformations in Channels.
    • Better reporting of uninstrumented methods with -DverifyInstrumentation=true
    • Various bug fixes
    Source code(tar.gz)
    Source code(zip)
  • v0.4.0(Jan 22, 2014)

    Quasar 0.4.0

    What's New

    • Hot Code Swapping
    • Channel Transformations (Reactive Extensions)
    • Custom Fiber Schedulers (run fibers on any thread, not just in a ForkJoinPool)
    Source code(tar.gz)
    Source code(zip)
  • v0.3.0(Oct 14, 2013)

    Quasar 0.3.0 Release Notes

    quasar-core

    • Bug-fixes, performance improvements
    • Additional concurrency constructs
    • Minor API improvements

    qusar-actors

    • Better isolation with ActorRef
    • co.paralleluniverse.data.record for safe, fast and isolated shared data elements
    Source code(tar.gz)
    Source code(zip)
  • v0.2.0(Jul 19, 2013)

    Quasar 0.2.0

    New Features

    • Behaviors (GenServer, GenEvent)
    • Supervisors
    • Transfer channels and channel selectors
    • Fiber-blocking IO
    • Initial implementation of distributed actors (using Galaxy)
    Source code(tar.gz)
    Source code(zip)
Build highly concurrent, distributed, and resilient message-driven applications on the JVM

Akka We believe that writing correct concurrent & distributed, resilient and elastic applications is too hard. Most of the time it's because we are us

Akka Project 12.6k Jan 3, 2023
Vert.x is a tool-kit for building reactive applications on the JVM

Vert.x Core This is the repository for Vert.x core. Vert.x core contains fairly low-level functionality, including support for HTTP, TCP, file system

Eclipse Vert.x 13.3k Jan 8, 2023
Reactive Microservices for the JVM

Lagom - The Reactive Microservices Framework Lagom is a Swedish word meaning just right, sufficient. Microservices are about creating services that ar

Lagom Framework 2.6k Dec 30, 2022
Netflix, Inc. 23.1k Jan 5, 2023
BitTorrent library and client with DHT, magnet links, encryption and more

Bt A full-featured BitTorrent implementation in Java 8 peer exchange | magnet links | DHT | encryption | LSD | private trackers | extended protocol |

Andrei Tomashpolskiy 2.1k Jan 2, 2023
Resilience4j is a fault tolerance library designed for Java8 and functional programming

Fault tolerance library designed for functional programming Table of Contents 1. Introduction 2. Documentation 3. Overview 4. Resilience patterns 5. S

Resilience4j 8.5k Jan 2, 2023
Zuul is a gateway service that provides dynamic routing, monitoring, resiliency, security, and more.

Zuul Zuul is an L7 application gateway that provides capabilities for dynamic routing, monitoring, resiliency, security, and more. Please view the wik

Netflix, Inc. 12.4k Jan 3, 2023
Distributed Stream and Batch Processing

What is Jet Jet is an open-source, in-memory, distributed batch and stream processing engine. You can use it to process large volumes of real-time eve

hazelcast 1k Dec 31, 2022
a blockchain network simulator aimed at researching consensus algorithms for performance and security

Just Another Blockchain Simulator JABS - Just Another Blockchain Simulator. JABS is a blockchain network simulator aimed at researching consensus algo

null 49 Jan 1, 2023
Simple and lightweight sip server to create voice robots, based on vert.x

Overview Lightweight SIP application built on vert.x. It's intended to be used as addon for full-featured PBX to implement programmable voice scenario

Ivoice Technology 7 May 15, 2022
Apache Mesos is a cluster manager that provides efficient resource isolation and sharing across distributed applications, or frameworks

Apache Mesos is a cluster manager that provides efficient resource isolation and sharing across distributed applications, or frameworks. It can run Hadoop, Jenkins, Spark, Aurora, and other frameworks on a dynamically shared pool of nodes.

The Apache Software Foundation 5k Dec 31, 2022
Fibers and actors for web development

COMSAT Scalable, Concurrent Web Apps Getting started Add the following Maven/Gradle dependencies: Feature Artifact Servlet integration for defining fi

Parallel Universe 600 Dec 23, 2022
tasks, async await, actors and channels for java

AsyncUtils tasks, async, await, actors and channels for java This project tries to explore several approaches to simplify async/concurrent programming

Michael Hoffer 6 Dec 1, 2022
The first Java Actor System supporting fibers from Project Loom

Fibry Fibry is an experimental Actor System built to be simple and flexible. Hopefully, it will also be fun to use. Fibry is the first Java Actor Syst

Luca Venturi 196 Dec 26, 2022
Simple, declarative mail utility for sending mails with default smtp server or with custom channels.

Introduction email-util is simple, declarative utility library. Key features are: declarative email building; text or html rendering; annotation suppo

Nijat Asgarzada 3 Oct 12, 2021
WebSocket server with creatable/joinable channels.

bytesocks ?? bytesocks is a WebSocket server which allows clients to create "channels" and send messages in them. It's effectively an add-on for byteb

lucko 6 Nov 29, 2022
JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.

pact-jvm JVM implementation of the consumer driven contract library pact. From the Ruby Pact website: Define a pact between service consumers and prov

Pact Foundation 962 Dec 31, 2022
Packages your JAR, assets and a JVM for distribution on Windows, Linux and Mac OS X

About Packages your JAR, assets and a JVM for distribution on Windows, Linux and macOS, adding a native executable file to make it appear like a nativ

libgdx 2.4k Dec 24, 2022