Characterizing the Energy Efficiency of Java’s Thread-Safe Collections in a Multi-Core Environment

Characterizing the Energy Efficiency of Java’s Thread-Safe Collections in a Multi-Core Environment

D0270498e20bd573441f1f48f2e425cf?s=128

Gustavo Pinto

January 15, 2018
Tweet

Transcript

  1. Characterizing the Energy Efficiency of Java’s Thread-Safe Collections in a

    Multi-Core Environment Gustavo Pinto ghlp@cin.ufpe.br Fernando Castor castor@cin.ufpe.br
  2. Motivation (1/3) • First, energy consumption is a concern for

    unwired devices and also for data centers • Second, there is a large body of work in hardware/architecture, OS, runtime systems • However, little is known about the application level 2
  3. Motivation (2/3) 3 • First, multicore CPUs are ubiquitous •

    Second, more cores used more power consumed • However, little is known about the energy-efficiency of multicore programs
  4. Motivation (3/3) 4 • Data structures are the fundamentals of

    computer programming
  5. 5 List<Object> lists = …; • ArrayList • LinkedList

  6. 6 List<Object> lists = new ArrayList<>();

  7. 7 List<Object> lists = new ArrayList<>(); Thread

  8. 8 • ArrayList • LinkedList • Vector • Collections.synchronizedList() •

    CopyOnWriteArrayList List<Object> lists = …;
  9. List<Object> lists = new Vector<>(); 9

  10. 10 List<Object> lists = new Vector<>(); Thread

  11. 11 List<Object> lists = new Vector<>(); Thread Thread-safe!

  12. 12 List<Object> lists = new Vector<>(); Thread { } …

    Thread-safe!
  13. 13 List<Object> lists = new Vector<>(); Thread { } …

    Thread-safe!
  14. List<Object> lists = new CopyOnWriteArrayList<>(); 14

  15. List<Object> lists = new CopyOnWriteArrayList<>(); 15 Thread

  16. List<Object> lists = new CopyOnWriteArrayList<>(); 16 Thread Thread-safe!

  17. List<Object> lists = new CopyOnWriteArrayList<>(); 17 { } Thread Thread-safe!

  18. List<Object> lists = new CopyOnWriteArrayList<>(); 18 { } Thread Thread-safe!

  19. List<Object> lists = new CopyOnWriteArrayList<>(); 19 { } Thread Thread-safe!

  20. 20 • ArrayList • LinkedList • …. • Vector •

    Collections.synchronizedList() • CopyOnWriteArrayList • …. List<Object> lists = …;
  21. 21 List<Object> lists = …; Set<Objects> sets = …; Map<Object,

    Object> maps = …;
  22. 22 List<Object> lists = …; Set<Objects> sets = …; Map<Object,

    Object> maps = …;
  23. Research Questions 23 • RQ1: Do different implementations of the

    same collection have different impacts on energy consumption? • RQ2: Do different operations in the same implementation of a collection consume energy differently?
  24. 24 List Set Map ArrayList LinkedHashSet LinkedHashMap Vector ——— Hashtable

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

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

    Collections.syncList() Collections.syncSet() Collections.syncMap() CopyOnWriteArrayList CopyOnWriteArraySet ——— ——— ConcurrentSkipListSet ConcurrentSkipListMap ——— ConcurrentHashSet ConcurrentHashMap ——— ConcurrentHashSetV8 ConcurrentHashMapV8 16 Benchmarks x 3 Operations Traversal Insertion Removal
  27. 27 Experimental Environment A 2×16-core AMD CPUs, running Debian Linux,

    64GB of memory, JDK version 1.7.0 11, build 21.
  28. 28 Experimental Environment A 2×16-core AMD CPUs, running Debian Linux,

    64GB of memory, JDK version 1.7.0 11, build 21.
  29. 29 Experimental Environment A 2×16-core AMD CPUs, running Debian Linux,

    64GB of memory, JDK version 1.7.0 11, build 21.
  30. 30 Experimental Environment A 2×16-core AMD CPUs, running Debian Linux,

    64GB of DDR3 1600 memory, and JDK version 1.7.0 11, build 21.
  31. List 31 Time

  32. List 32 Time

  33. List 33 Time 1.98x more energy!

  34. List 34 Time

  35. List 35 Time No sync!

  36. List 36 Time CopyOnWriteArrayList: +152x

  37. Set 37 Time

  38. Set 38 Time Time is proportional to energy Time is

    not proportional to energy
  39. Map 39 Time

  40. Map 40 Time Time is proportional to energy Time is

    not proportional to energy
  41. Map 41 Time

  42. Map 42 Time

  43. Map “Tuning Knobs” 43 Initial capacity

  44. 44 Load factor Map “Tuning Knobs”

  45. 45 Collision 100% Map “Tuning Knobs”

  46. 46

  47. Future Work 47 • Perform the “removal” operations on Lists

    • Vary the number of threads accessing the data structure • Perform the experiments in another machine
  48. Characterizing the Energy Efficiency of Java’s Thread-Safe Collections in a

    Multi-Core Environment Gustavo Pinto ghlp@cin.ufpe.br Fernando Castor castor@cin.ufpe.br