Skip to main content

My Tuesday at JavaOne 2013

Posted by haroldcarr on September 24, 2013 at 10:27 PM PDT

2013-09-24

Last Modified : 2013 Sep 24 (Tue) 22:39:06 by carr.

Tuesday, Sep 24, 2013


8:30am - Functional Reactive Programming with RxJava

  • Ben Christensen, Software Engineer - Edge Platform, Netflix

Excellent presentation - impossible to due justice with notes. Great
slides, but really need to see/hear live.

To see someone else's live blogging of a similar talk at the 2013 International Conference on Functional Programming, see

Overview

Turning sync to async

  • callback : NO
  • futures : NO

Iterable | Observable (from GoF)
pull | push
T next() | on Next(T)
throws Exception | onError(Exception)
returns | onCompleted()

like Akka but works on stream of values not just single value

client treats all interactions as async

API impl chooses (non)blocking and resources:

  • sync on same thread
  • async on different thread
  • on actor
  • on multiple threads
  • using NIO

Compose functions

  • transform
  • filter
  • combine
  • concurrency
  • error handling

10:00am - The JVM is dead! Long live the Polyglot VM!

  • Marcus Lagergren, Oracle

universal meta execution environment - multi-language runtime

history

  • first JIT compiler: LISP 1962 - John McCarthy
    • also GC with ref counting
    • first modern adaptive runtime
  • Alan Kay : Smalltalk
    • first class library
    • first GUI driven IDE
    • bytecode

dynamic languages

  • ActionScript, Clojure, JavaScript. Phython, Ruby, PHP, Rebol, …
  • easy to use; no explicit compile stage, readability, fast dev for
    small projects, performance good enough
  • implementations
    • native; metacircular; on top of (J)VM, CLR, …
  • characteristics
    • resolve at runtime (instead of compiletime)
    • liberal redefinition policy
    • code equals data; eval/REPL, GC
    • thins change at runtime

putting a language on top of JVM

  • get for free
    • GC, JIT optimization; native threading; hybridization (JSR-223);
      person decades of high tech
  • 2 biggest problems
    • loose types
    • dynamic redefinition
invokedynamic to punch thru indirection layer

  • since JDK7 - rewritten in u40
  • first new bytecode since 1996
  • more than a new type of call
  • breaks constraints of Java call/linkage
  • can impl calls that act like function pointers
  • can impl custom data access
  • the JVM can optimize invokedynamic
invokedynamic java.lang.invoke.*

Java 8 uses invokedynamic delegator with lambda

Nashorn

  • 100% Java runtime for JavaScript
  • 2-10x better than Rhino
  • approaching V8 performance
  • generates bytecode; invokedynamic everywhere
  • in JDK 8 (replaces Rhino)
  • ECMAScript compliant
  • key to performance
    • be optimistic - rollback if wrong
    • inlining; use assembly for math intrinsics;
  • used in

Da Vince Machine project


1pm - invokedynamic in 45 minutes

earliest adoptor of invokedynamic

https://github.com//headius/indy_deep_dive

history

  • JVM authors mentioned non-Java languages
  • hundreds of JVM languages now
  • previous to invokedynamic impls needed tricks that defeated JVM
    optimizations
  • 2006 - JRuby team hired
  • JSR-292 invokedynamic rebooted in 2007
  • 2011 - invokedynamic in Java 7
invokedynamic
  • user-definable bytecode
  • + method pointers and adapters

java.lang.invoke

method handles

  • function/field/array points
  • arg manipution
  • flow control
  • optimizable by JVM
java.lang.invoke
  • MethodHandle
    • invokable target
  • MethodType
  • MethodHandles
    • can get access to "things" in your class : e.g., method/field pointers

Adapters

  • methods on MethodHandle-s
  • arg manipulation
    • insert, drop, permute, filter, fold, cast, splat (varags), spread (unbox varargs)

Flow Control

  • guardWithTest to decide target
  • SwitchPoint on/off branch

Exception Handling

  • catchException

bytecode

invocation

  • static, virtual, interface, special
  • they mostly do same thing (check arg types, cache, …, invoke)
  • invokedynamic let you define the flow

tools

  • ASM : byte code gen
  • Jitescript : DSL/fluent API around ASM
  • InvokeBinder : DSL/fluent API for MH chains
CallSite
  • holder for MethodHandle

your turn

  • play with MethodHandle-s
  • try generating invokedynamic= - see "JVM Bytecode for Dummies"

http://blog.headius.com


3pm - Wholly Graal - Java on GPU

  • Vansant Venkatachalam, AMD
  • Christian Thalinger, Oracle
  • Christian Wimmer, Oracle Labs

graal overview

Graal is new JIT compiler for HotSPot

research project

|--------+----------+------+
| Server | Client   | Graal|
|Compler | Compiler |      |
|--------+----------+------+
|compiler interface        |
|--------------------------+
|Java HotSpot VM           |
+--------------------------+

OpenJDK project

Sumatra OpenJDK project

backends for graal

truffle

bytecode ---------+--> graal -> cpu | ptx | hsail
                  |
ast interpreter ->+
truffle API

graal structure

bytecode

bytecode compiler

method inlining
global value numbering
escape analysis
loop optimizations

vm lowering

memory optimizations
architecture lowering

register allocation
code generation

machine code

graal intermediate representation

  • iterable and named fields
  • automatic def-use edges
  • lots of visualization tools

produces code better than client compiler but not as good as server compiler

GPU offload

why?

  • GPU has hundreds of cores
  • data-parallel parts of program
    • e.g., squaring array elements
  • save power

considerations

  • java needs programming model to express data-parallel
    • jdk 8: parallel streams
  • generate code for GPU while running on CPU
  • intermediate GPU target language then translate to specific GPU
    • e.g., HSAIL

sumatra

  • goal: GPU enablement for Java
  • use stream API and sumatra does rest

heterogeneous system architecture (HSA)

  • standard interface to GPU
  • common intermediate language: HSAIL
  • common runtime: HSA stack
  • shared virtual memory
    • direct access to Java heap object in main memory from GPU cores

execution model

  • grid based
  • programmer supplies "kernel" that is run on each work-item
  • kernel: written as single thread of execution
  • each work item has unique id
  • programmer specifies number of work-items

hsail

  • emitted by JVM
  • translated to GPU ISA by "finalizer"
  • mul_s32 $s3, $s0, $s1

examples

  • Math intrinsics (e.g., sqrt)
  • arrays, string manipulation
  • instanceof
  • increment point.x in array of points
  • atomic operations

5:30pm - Experimenting with the Boundaries of Static Typing

make rock solid via static types : good for mission-critical code

API - compiletime error if

  • move: calling on finished game
  • whoWon: calling on non-finished
  • takeBack: empty board
  • playerAt : …

carry "state/shape" in type

move type complexity into library so developer does not have to deal

examples in Groovy, Java, Scala


7:30pm - Developing Small Languages with Scala Parser Combinators

  • Travis Dazell, Systems Architect, Digi-Key Corporation
RegexParsers

small parsers COMBINed (combinator) to form a larger parser

use-case


8:30pm - GlassFish Community BoF

  • Anil Gaur - VP, Software Development, Oracle
  • Reza Rahman - Java EE/GlassFish Evangelist, Oracle
  • Santiago * - Avatar Lead, Oracle

EE 7 / GlassFish 4

Java EE 7

  • developer productivity
  • HTML5

Community contributions

  • FishCat
  • Adopt-a-JSR - 20+ JUGs
  • Tic Tac Toe sample

GlassFish 4

  • admin console : concurrency, jbatch
  • background exec of admin commands
    • attach/detach : foreground/background cmd (just like unix &, jobs)
  • more REST/SSE support for admin
  • log format changes
    • change from Uniform Log Formatter (ULF) to Oracle Diagnostics Logging (ODL)
  • more cmds
  • config defaults
  • OSGi admin
    • integrate GoGo so works from asadmin
  • Concurrency : Managed*
  • JBatch : admin

Ecosystem for GlassFish 4

  • NetBeans
  • Eclipse
  • JetBRAINS
  • OSGi
  • Oracle Enterprise Manager

Project Avatar

  • http://avatar.java.net/
  • thin-server model
  • data communication - model on client
  • http/rest; websockets; SSE
  • services written in EE or nashhorn/javascript
Related Topics >>