java 8 support

128 views
Skip to first unread message

seth/nqzero

unread,
Jan 17, 2014, 11:21:27 PM1/17/14
to kilimt...@googlegroups.com
java 8 release candidate should be out in a week with general availability scheduled for the end of march. this introduces lambda expressions. syntactically, they're similar to anonymous inner classes (AICs), which i use extensively as kilim tasks. many end users are uncomfortable with AICs (and the boilerplate is a pain), so i'm curious if kilim is going to be able to support lambdas. for comparison, here are AIC and lambda impls:

        ctrl.place(
            new Task() { public void execute() throws Pausable {
                users.insert(tid, username, digest);
        }});

        ctrl.lambda(tid -> 
                users.insert(tid, username, digest));

ctrl.lambda() and ctrl.place() handle adding the task to a mailbox. ctrl.lambda warps the lambda in a Task. the functional interface for lambda is the same as Task.execute, ie Pausable. the bodies and functionality are identical, and the lambda is simpler / cleaner / prettier. i'm optimistic that end users will be more comfortable working with the lambdas than they have been with the AICs

i've tried using kilim with java 8 (ie without using any features of java 8) by replacing asm-all-4.1.jar with asm-all-5_beta.jar and it weaves without errors but the resulting bytecode won't run, ie java can't even find the main method. i haven't made any effort to debug what's happening

as for the lambda bytecode, i've just started reading: http://cr.openjdk.java.net/~briangoetz/lambda/lambda-translation.html
and have only glanced at the resulting bytecode

does kilim have any plans for java 8 or a sense of how much engineering effort is required to support lambdas ?

Sriram Srinivasan

unread,
Jan 17, 2014, 11:37:52 PM1/17/14
to kilimt...@googlegroups.com

seth/nqzero wrote:
> does kilim have any plans for java 8 or a sense of how much engineering effort is required to support lambdas ?

Am teaching a distributed systems class that has booked up all my cycles for the next three months. I have not looked at Java 8 bytecode yet, so don't know what it'll take yet. I suspect that to get it to work again should be quite trivial, but to intelligently take advantage of Java 8 would be a bit more effort; I do not have estimates yet. Thanks for the link. I'll take a glance.

--sriram

Sriram Srinivasan

unread,
Jan 17, 2014, 11:50:58 PM1/17/14
to kilimt...@googlegroups.com
I just remembered. I haven't yet taken a look at the bytecode, but I would need to add support for invokedynamic I faintly remember that they use this instruction for lambdas.

--s

seth/nqzero

unread,
Jul 3, 2014, 12:14:56 AM7/3/14
to kilimt...@googlegroups.com
sriram - have you made any progress with java 8 or invokedynamic ?
i've just started working on switching to asm5 and have things
compiling and weaving without errors, but not correctly (the methods
show up as un-woven at runtime)

i created an issue for java 8 support ...
https://github.com/kilim/kilim/issues/36
> --
> You received this message because you are subscribed to the Google Groups "kilimthreads" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to kilimthreads...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Sriram Srinivasan

unread,
Jul 3, 2014, 2:41:01 PM7/3/14
to kilimt...@googlegroups.com

On Jul 2, 2014, at 9:14 PM, seth/nqzero <bl...@nqzero.com> wrote:

> sriram - have you made any progress with java 8 or invokedynamic ?
> i've just started working on switching to asm5 and have things
> compiling and weaving without errors, but not correctly (the methods
> show up as un-woven at runtime)
>

No I have not started yet, alas. I have been working on some performance issues for a client, which I'm about to roll up into a release.
I'll get started on java8 now.

--sriram.

seth/nqzero

unread,
Jul 3, 2014, 4:44:48 PM7/3/14
to kilimt...@googlegroups.com
that's great news. if there's anything that i can do to help i am
willing. i've done a bit already - asm 5 runs ok with a few minor
changes to kilim. and the woven code runs ok sometimes, but most of
the time gives "not woven" errors
> --
> You received this message because you are subscribed to the Google Groups "kilimthreads" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to kilimthreads...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Jason Pell

unread,
Jul 3, 2014, 5:38:39 PM7/3/14
to kilimt...@googlegroups.com

Be interested to know about the performance issues too.

--
You received this message because you are subscribed to the Google Groups "kilimthreads" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kilimthreads...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrew Bate

unread,
Jul 3, 2014, 5:43:32 PM7/3/14
to kilimt...@googlegroups.com
I too would be interested in learning more about the performance issues.

Are these issues to do with (1) the bytecode weaving technique, or (2) the scheduling of tasks, or (3) the implementation of mailboxes? Or some combination of the three?

Sriram Srinivasan

unread,
Jul 3, 2014, 5:52:06 PM7/3/14
to kilimt...@googlegroups.com

On Jul 3, 2014, at 2:38 PM, Jason Pell <ja...@pellcorp.com> wrote:

> Be interested to know about the performance issues too.
>


I was given two sets of changes (largely), one a change to Cell using atomics instead of synchronized, and the other the use of the ExecutorService instead of my round robin scheduler. These two have been on the anvil anyway, but I want to characterize the change properly. A student of mine is investigating ways of incorporating the lessons learnt from the lmax disruptor into kilim (such as padding to avoid false sharing, reducing synchronization to batch boundaries to reduce true sharing and so on).

Happily, kilim is being adopted very nicely into a product that could have good visibility, and I can do tests on real end-to-end systems to get numbers. Microbenchmarks can really lead one astray in terms of effort expended.

--s


Jason Pell

unread,
Jul 3, 2014, 7:00:58 PM7/3/14
to kilimt...@googlegroups.com

Exciting

Kilim is in production for us for quite a few clients and is performing very well.

But any improvements and java 8 support will be very welcome

Sriram Srinivasan

unread,
Jul 3, 2014, 7:05:03 PM7/3/14
to kilimt...@googlegroups.com

On Jul 3, 2014, at 4:00 PM, Jason Pell <ja...@pellcorp.com> wrote:
> But any improvements and java 8 support will be very welcome
>

Yes, I like lambdas of course, but I am more intrigued by the underlying implementation (the lambda metafactories and invokedynamic) and whether they can be leveraged to give some added flexibility without loss of performance.


Jason Pell

unread,
Jul 3, 2014, 7:16:04 PM7/3/14
to kilimt...@googlegroups.com

Will you create branch to continue java 7 version. As we would want both supported ourselves

Sriram Srinivasan

unread,
Jul 3, 2014, 7:18:58 PM7/3/14
to kilimt...@googlegroups.com
On Jul 3, 2014, at 4:16 PM, Jason Pell <ja...@pellcorp.com> wrote:

> Will you create branch to continue java 7 version. As we would want both supported ourselves

I am hoping to have a single version that can work for both.

--s

seth/nqzero

unread,
Jul 16, 2014, 11:09:36 AM7/16/14
to kilimt...@googlegroups.com
decided i needed to work on my bytecode-fu a bit and wanted to
understand invokedynamic so i did a little work on java 8 support. i
have a branch with asm5 and proof of concept support for lambdas.
stuff is hardcoded so it only works with kilim.examples.Dummy, and it
fails to resume, but the bootstrap and invokedynamic are successful (i
was "worried" that the jvm wasn't going to accept the lambda
assignment because the signature doesn't match the functional
interface)

https://github.com/kilim/kilim/issues/36
https://github.com/nqzero/kilim/commit/7d8217cbbe7fdd4700fb719945d3557a1b60827d

Sriram Srinivasan

unread,
Jul 17, 2014, 10:26:49 PM7/17/14
to kilimt...@googlegroups.com
This is very encouraging indeed. Thanks so much.
I'll take a look.

--sriram.

On Jul 16, 2014, at 8:39 PM, seth/nqzero <bl...@nqzero.com> wrote:

> decided i needed to work oHan my bytecode-fu a bit and wanted to

Sriram Srinivasan

unread,
Aug 9, 2014, 5:21:32 AM8/9/14
to kilimt...@googlegroups.com
Lambda functions are now pausable. 

Pick it up from the asm5-jdk8 branch.

public void execute() throws Pausable {
       Foo  f = () -> {
                ...;
                Task.sleep(100);
               ...
        }

        f.call();
}

interface Foo {
    int call() throws Pausable;
}

As always, feedback, criticisms and code reviews welcome. 

--sriram.


Reply all
Reply to author
Forward
0 new messages