Copyright © 2014 Russel Winder 1
Groovy, GPars, @CompileStatic and
invokedynamic. And Java 8.
Russel Winder
email: russel@...
Copyright © 2014 Russel Winder 2
is a programming language.
Copyright © 2014 Russel Winder 3
is a dynamic programming language.
Copyright © 2014 Russel Winder 4
Dynamic language rarely
exhibit high performance.
Copyright © 2014 Russel Winder 5
This is generally not a problem as
most dynamic languages are
usually used in I/O-bound c...
Copyright © 2014 Russel Winder 6
In CPU-bound contexts however,
it is a REAL problem.
Copyright © 2014 Russel Winder 7
The biggest issue for Groovy performance
is that floating point values are
BigDecimal by ...
Copyright © 2014 Russel Winder 8
We need an example.
Copyright © 2014 Russel Winder 9

Copyright © 2014 Russel Winder 10
What is the Value of ?
Easy, it's known exactly.
It's .
Obviously.
Copyright © 2014 Russel Winder 11
Putative joke involving Alexander Orlov (*)
and the phrase It's simples. elided as UK“ ”...
Copyright © 2014 Russel Winder 12
Approximating 
● What is it's value represented as a floating point
number?
● We can on...
Copyright © 2014 Russel Winder 13
One Possible Algorithm
● Use quadrature to estimate the value of the integral
– which is...
Copyright © 2014 Russel Winder 14
Because addition is commutative and
associative, expression can be
decomposed into sums ...
Copyright © 2014 Russel Winder 15
a + b + c + d + e + f
=
( a + b ) + ( c + d ) + ( e + f )
Copyright © 2014 Russel Winder 16
Scatter – Gather
map reduce
fork join
Data parallel
Copyright © 2014 Russel Winder 17
Back to the BigDecimal issue…
Copyright © 2014 Russel Winder 18
…to the code:
Copyright © 2014 Russel Winder 19
As with (almost) all programming language,
Groovy is focussed on sequential activity.
Copyright © 2014 Russel Winder 20
In a multicore world, we harness all the
cores to improve performance.
Copyright © 2014 Russel Winder 21
The Java Platform offers threads,
Java, and hence Groovy, can use them.
Copyright © 2014 Russel Winder 22
Shared memory multithreading is an
infrastructure technique.
Copyright © 2014 Russel Winder 23
java.util.concurrent
Copyright © 2014 Russel Winder 24
Copyright © 2014 Russel Winder 25
Concurrency can be used for
I/O-bound systems, but…
Copyright © 2014 Russel Winder 26
…concurrency can also be used
for CPU-bound systems.
Parallelism.
Copyright © 2014 Russel Winder 27
Parallelism is about performance.
Copyright © 2014 Russel Winder 28
Look at some code…
Copyright © 2014 Russel Winder 29
Dynamism and parallelism are
rarely good bedfellows.
Copyright © 2014 Russel Winder 30
@CompileStatic is about…
…eliding dynamism.
…about performance.
Copyright © 2014 Russel Winder 31
invokedynamic is about…
…supporting dynamism.
…performance.
Copyright © 2014 Russel Winder 32
Java 8
The greatest revolution of
Java since 1994.
A far bigger revolution of
Java than ...
Copyright © 2014 Russel Winder 33
Java 8
Introduces various things, the most
important of which are:
Lambda expressions.
D...
Copyright © 2014 Russel Winder 34
Java 8
as a consequence of
lambda expressions introduces:
Streams†
.
†
And parallelism, ...
Copyright © 2014 Russel Winder 35
More codes…
Copyright © 2014 Russel Winder 36
Needs You…
Copyright © 2014 Russel Winder 37
Groovy, GPars, @CompileStatic and
invokedynamic. And Java 8
Russel Winder
email: russel@...
Upcoming SlideShare
Loading in …5
×

Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.

1,679
-1

Published on

The beginnings of an investigation into the benefit of @CompileStatic and invokedynamic for CPU-bound Groovy codes. This is the slide set for my Greach2014 talk. Code in my Pi_Quadrature repository on GitHub: https://github.com/russel/Pi_Quadrature

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,679
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
14
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.

  1. 1. Copyright © 2014 Russel Winder 1 Groovy, GPars, @CompileStatic and invokedynamic. And Java 8. Russel Winder email: russel@winder.org.uk xmpp: russel@winder.org.uk twitter: @russel_winder http://www.russel.org.uk
  2. 2. Copyright © 2014 Russel Winder 2 is a programming language.
  3. 3. Copyright © 2014 Russel Winder 3 is a dynamic programming language.
  4. 4. Copyright © 2014 Russel Winder 4 Dynamic language rarely exhibit high performance.
  5. 5. Copyright © 2014 Russel Winder 5 This is generally not a problem as most dynamic languages are usually used in I/O-bound contexts.
  6. 6. Copyright © 2014 Russel Winder 6 In CPU-bound contexts however, it is a REAL problem.
  7. 7. Copyright © 2014 Russel Winder 7 The biggest issue for Groovy performance is that floating point values are BigDecimal by default.
  8. 8. Copyright © 2014 Russel Winder 8 We need an example.
  9. 9. Copyright © 2014 Russel Winder 9 
  10. 10. Copyright © 2014 Russel Winder 10 What is the Value of ? Easy, it's known exactly. It's . Obviously.
  11. 11. Copyright © 2014 Russel Winder 11 Putative joke involving Alexander Orlov (*) and the phrase It's simples. elided as UK“ ” television-related comedy doesn't travel. (*) A fairly cute meerkat.
  12. 12. Copyright © 2014 Russel Winder 12 Approximating  ● What is it's value represented as a floating point number? ● We can only obtain an approximation. ● A plethora of possible algorithms to choose from, a popular one is to employ the following integral equation.  4 =∫0 1 1 1x2 dx
  13. 13. Copyright © 2014 Russel Winder 13 One Possible Algorithm ● Use quadrature to estimate the value of the integral – which is the area under the curve. = 4 n ∑i=1 n 1 1 i−0.5 n  2 With n = 3 not much to do, but potentially lots of error. Use n = 107 or n = 109 ? Embarrassingly parallel.
  14. 14. Copyright © 2014 Russel Winder 14 Because addition is commutative and associative, expression can be decomposed into sums of partial sums.
  15. 15. Copyright © 2014 Russel Winder 15 a + b + c + d + e + f = ( a + b ) + ( c + d ) + ( e + f )
  16. 16. Copyright © 2014 Russel Winder 16 Scatter – Gather map reduce fork join Data parallel
  17. 17. Copyright © 2014 Russel Winder 17 Back to the BigDecimal issue…
  18. 18. Copyright © 2014 Russel Winder 18 …to the code:
  19. 19. Copyright © 2014 Russel Winder 19 As with (almost) all programming language, Groovy is focussed on sequential activity.
  20. 20. Copyright © 2014 Russel Winder 20 In a multicore world, we harness all the cores to improve performance.
  21. 21. Copyright © 2014 Russel Winder 21 The Java Platform offers threads, Java, and hence Groovy, can use them.
  22. 22. Copyright © 2014 Russel Winder 22 Shared memory multithreading is an infrastructure technique.
  23. 23. Copyright © 2014 Russel Winder 23 java.util.concurrent
  24. 24. Copyright © 2014 Russel Winder 24
  25. 25. Copyright © 2014 Russel Winder 25 Concurrency can be used for I/O-bound systems, but…
  26. 26. Copyright © 2014 Russel Winder 26 …concurrency can also be used for CPU-bound systems. Parallelism.
  27. 27. Copyright © 2014 Russel Winder 27 Parallelism is about performance.
  28. 28. Copyright © 2014 Russel Winder 28 Look at some code…
  29. 29. Copyright © 2014 Russel Winder 29 Dynamism and parallelism are rarely good bedfellows.
  30. 30. Copyright © 2014 Russel Winder 30 @CompileStatic is about… …eliding dynamism. …about performance.
  31. 31. Copyright © 2014 Russel Winder 31 invokedynamic is about… …supporting dynamism. …performance.
  32. 32. Copyright © 2014 Russel Winder 32 Java 8 The greatest revolution of Java since 1994. A far bigger revolution of Java than Java 5.
  33. 33. Copyright © 2014 Russel Winder 33 Java 8 Introduces various things, the most important of which are: Lambda expressions. Default methods in interfaces.
  34. 34. Copyright © 2014 Russel Winder 34 Java 8 as a consequence of lambda expressions introduces: Streams† . † And parallelism, and parallelism is about performance.
  35. 35. Copyright © 2014 Russel Winder 35 More codes…
  36. 36. Copyright © 2014 Russel Winder 36 Needs You…
  37. 37. Copyright © 2014 Russel Winder 37 Groovy, GPars, @CompileStatic and invokedynamic. And Java 8 Russel Winder email: russel@winder.org.uk xmpp: russel@winder.org.uk twitter: @russel_winder http://www.russel.org.uk
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×