$30 off During Our Annual Pro Sale. View Details »

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

Gustavo Pinto

January 15, 2018
Tweet

More Decks by Gustavo Pinto

Other Decks in Research

Transcript

  1. Characterizing the Energy Efficiency of
    Java’s Thread-Safe Collections in a
    Multi-Core Environment
    Gustavo Pinto
    [email protected]
    Fernando Castor
    [email protected]

    View Slide

  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

    View Slide

  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

    View Slide

  4. Motivation (3/3)
    4
    • Data structures are the fundamentals of computer
    programming

    View Slide

  5. 5
    List lists = …;
    • ArrayList
    • LinkedList

    View Slide

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

    View Slide

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

    View Slide

  8. 8
    • ArrayList
    • LinkedList
    • Vector
    • Collections.synchronizedList()
    • CopyOnWriteArrayList
    List lists = …;

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    Thread-safe!

    View Slide

  13. 13
    List lists = new Vector<>();
    Thread
    {
    }

    Thread-safe!

    View Slide

  14. List lists = new CopyOnWriteArrayList<>();
    14

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  20. 20
    • ArrayList
    • LinkedList
    • ….
    • Vector
    • Collections.synchronizedList()
    • CopyOnWriteArrayList
    • ….
    List lists = …;

    View Slide

  21. 21
    List lists = …;
    Set sets = …;
    Map maps = …;

    View Slide

  22. 22
    List lists = …;
    Set sets = …;
    Map maps = …;

    View Slide

  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?

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  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.

    View Slide

  31. List
    31
    Time

    View Slide

  32. List
    32
    Time

    View Slide

  33. List
    33
    Time
    1.98x more energy!

    View Slide

  34. List
    34
    Time

    View Slide

  35. List
    35
    Time
    No sync!

    View Slide

  36. List
    36
    Time
    CopyOnWriteArrayList: +152x

    View Slide

  37. Set
    37
    Time

    View Slide

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

    View Slide

  39. Map
    39
    Time

    View Slide

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

    View Slide

  41. Map
    41
    Time

    View Slide

  42. Map
    42
    Time

    View Slide

  43. Map “Tuning Knobs”
    43
    Initial capacity

    View Slide

  44. 44
    Load factor
    Map “Tuning Knobs”

    View Slide

  45. 45
    Collision 100%
    Map “Tuning Knobs”

    View Slide

  46. 46

    View Slide

  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

    View Slide

  48. Characterizing the Energy Efficiency of
    Java’s Thread-Safe Collections in a
    Multi-Core Environment
    Gustavo Pinto
    [email protected]
    Fernando Castor
    [email protected]

    View Slide