Upgrade to Pro — share decks privately, control downloads, hide ads and more …

A Comprehensive Study on the Energy Efficiency of Java Thread-Save Collections

Gustavo Pinto
January 14, 2018
130

A Comprehensive Study on the Energy Efficiency of Java Thread-Save Collections

Gustavo Pinto

January 14, 2018
Tweet

Transcript

  1. A Comprehensive Study on the Energy Efficiency of Java Thread-Safe

    Collections Fernando Castor Kenan Liu Gustavo Pinto David Liu 1
  2. First, energy consumption is not only a concern for unwired

    devices, but also for data centers 6 Second, multicore CPUs are ubiquitous
  3. First, energy consumption is not only a concern for unwired

    devices, but also for data centers 7 Second, multicore CPUs are ubiquitous Third, data structures are the fundamentals of computer programming
  4. 12 • ArrayList • LinkedList • Vector • Collections.synchronizedList() •

    CopyOnWriteArrayList List<Object> lists = …; Non Thread-Safe Thread-Safe
  5. 21 List<Object> lists = …; • ArrayList • LinkedList •

    Vector • Collections.synchronizedList() • CopyOnWriteArrayList Non Thread-Safe Thread-Safe
  6. 24 List<Object> lists = …; Set<Objects> sets = …; Map<Object,

    Object> maps = …; And how about energy consumption?
  7. 16 Collections 25 List ArrayList Vector Collections.syncList() CopyOnWriteArrayList Set LinkedHashSet

    Collections.syncSet() CopyOnWriteArraySet ConcurrentSkipListSet ConcurrentHashSet ConcurrentHashSetV8 Map LinkedHashMap Hashtable Collections.syncMap() ConcurrentSkipListMap ConcurrentHashMap ConcurrentHashMapV8
  8. 16 Collections 26 List ArrayList Vector Collections.syncList() CopyOnWriteArrayList Set LinkedHashSet

    Collections.syncSet() CopyOnWriteArraySet ConcurrentSkipListSet ConcurrentHashSet ConcurrentHashSetV8 Map LinkedHashMap Hashtable Collections.syncMap() ConcurrentSkipListMap ConcurrentHashMap ConcurrentHashMapV8 Non thread-safe Thread-safe
  9. 16 Collections 27 List ArrayList Vector Collections.syncList() CopyOnWriteArrayList Set LinkedHashSet

    Collections.syncSet() CopyOnWriteArraySet ConcurrentSkipListSet ConcurrentHashSet ConcurrentHashSetV8 Map LinkedHashMap Hashtable Collections.syncMap() ConcurrentSkipListMap ConcurrentHashMap ConcurrentHashMapV8 Java 7 Java 8
  10. 16 Collections 28 List ArrayList Vector Collections.syncList() CopyOnWriteArrayList Set LinkedHashSet

    Collections.syncSet() CopyOnWriteArraySet ConcurrentSkipListSet ConcurrentHashSet ConcurrentHashSetV8 Map LinkedHashMap Hashtable Collections.syncMap() ConcurrentSkipListMap ConcurrentHashMap ConcurrentHashMapV8 x 3 Operations Traversal Insertion Removal
  11. 2 Environments AMD CPU: A 2×16-core, running Debian, 2.4 GHz,

    64GB of memory, JDK version 1.7 .0 11, build 21. 29 Intel CPU: A 2×8-core (32-cores w/ hyper-threading), running Debian, 2.60GHz, with 64GB of memory, JDK version 1.7 .0 71, build 14.
  12. 2 Environments AMD CPU: A 2×16-core, running Debian, 2.4 GHz,

    64GB of memory, JDK version 1.7 .0 11, build 21. 30 Intel CPU: A 2×8-core (32-cores w/ hyper-threading), running Debian, 2.60GHz, with 64GB of memory, JDK version 1.7 .0 71, build 14. Hardware-based energy measurement Software-based energy measurement
  13. 31 More details about how the experiments were conducted? http:/

    /icsme2016.github.io/program/accepted.html
  14. 46 Maps Intel CPU Traversal Insertion Removal AMD CPU Traversal

    Insertion Removal Less energy than the non thread-safe implementation!
  15. 48 Tomcat > A web server > More than 170K

    lines of Java code > More than 300 Hashtables
  16. 49 Tomcat Xalan > Parses XML in HTML documents >

    More than 188K lines of Java code > More than 140 Hashtables > A web server > More than 170K lines of Java code > More than 300 Hashtables
  17. 50 For each Hashtable instance, change it for a ConcurrentHashMap

    one. Do it again for ConcurrentHashMapV8 Task:
  18. 52 Tomcat Xalan Hashtable to CHM: -12.21% Hashtable to CHM8:

    -17 .82% Hashtable to CHM: -5.82% Hashtable to CHM8: -9.32%
  19. 57 Hashtable ConcurrentHashMap List<Object> obj = new Hashtable<>(); obj.clone(); Cloneable

    
 Map 
 / / works fine / / compiler error implements List<Object> obj = new ConcurrentHashMap<>(); obj.clone();
  20. 58 Hashtable ConcurrentHashMap List<Object> obj = new Hashtable<>(); obj.clone(); Cloneable

    
 Map 
 / / works fine / / compiler error implements List<Object> obj = new ConcurrentHashMap<>(); obj.clone(); Danny Dig Opportunity for improving refactoring tools!
  21. 61 Doug Lea Stay up-to-date with the new releases of

    the java.util.concurrent library
  22. 63

  23. A Comprehensive Study on the Energy Efficiency of Java Thread-Safe

    Collections Fernando Castor Kenan Liu Gustavo Pinto David Liu 65
  24. Experimental Environments 66 AMD CPU: A 2×16-core, running Debian, 2.4

    GHz, 64GB of memory, JDK version 1.7 .0 11, build 21. Intel CPU: A 2×8-core (32-cores w/ hyper-threading), running Debian, 2.60GHz, with 64GB of memory, JDK version 1.7 .0 71, build 14.