G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many...

66

Transcript of G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many...

Page 1: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,
Page 2: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,
Page 3: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

G1 – Not Never Done!

Thomas [email protected] Java Hotspot Virtual Machine GC TeamFebruary 03, 2018

Page 4: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Safe Harbor Statement

The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.

4

Page 5: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Program Agenda

Parallel Full GC

Faster Card Scanning

Rebuild Remembered Sets Concurrently

Abortable Mixed Collections

Automatic Thread Sizing

Participate!

1

2

3

4

5

5

6

Page 6: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Program Agenda

Parallel Full GC

Faster Card Scanning

Rebuild Remembered Sets Concurrently

Abortable Mixed Collections

Automatic Thread Sizing

Participate!

1

2

3

4

5

6

6

Page 7: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

G1 Parallel Full GC

• G1 Full GC very slow– High worst-case latencies and bad throughput

– Goal: be on par with Parallel GC Full GC

• Solution– Parallelize Mark-Sweep-Compact

7

Page 8: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

G1 Parallel Full GC

8

● system.gc() test– performs many

System.gc(), very small live set, 5G heap

● BigRAMTester– LRU-cache-stress test

application, many references, large (90%) live set, 10G heap(JDK-8152438)

● TreeFragger– Fragmentation-inducing

benchmark from RedHat, medium live set, 20G heap

Page 9: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

G1 Parallel Full GC

• Available since build jdk-10-ea+34

9

Page 10: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Program Agenda

Parallel Full GC

Faster Card Scanning

Rebuild Remembered Sets Concurrently

Abortable Mixed Collections

Automatic Thread Sizing

Participate!

1

2

3

4

5

10

6

Page 11: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Faster Card Scanning

11

Region

Object

What is a card?

Reference

Java Heap

Page 12: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Faster Card Scanning

12

Move

What is a card?

Region

Object

Reference

Java Heap

Page 13: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Faster Card Scanning

13

?

?

Move

What is a card?

Region

Object

Reference

Java Heap

Page 14: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Faster Card Scanning

14

?

?

Move

Remembered set

What is a card?

Region

Object

Reference

Remembered set entry

Java Heap

Page 15: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Faster Card Scanning

15

!!

Move

What is a card?

Region

Object

Reference

Java Heap

Remembered set entry

Remembered set

Page 16: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Remembered set

Faster Card Scanning

16

What is a card? A small subdivision of memory

Region

Object

Reference

Remembered set entry

Page 17: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Faster Card Scanning

• GC needs to fnd references in cards in remembered sets to moved objects quickly

17

Problem

Page 18: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Faster Card Scanning

• Refactor and improve scanning and updating remembered sets– Remove overly generic code

– Replace by specialized code for diferent situations

– Subsume and remove obsolete checks

18

Solution

Page 19: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Faster Card Scanning

19

Page 20: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Faster Card Scanning

20

Page 21: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Faster Card Scanning

• Available since build jdk-10-ea+21

21

Page 22: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Program Agenda

Parallel Full GC

Faster Card Scanning

Rebuild Remembered Sets Concurrently

Abortable Mixed Collections

Automatic Thread Sizing

Participate

1

2

3

4

5

22

6

Page 23: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Rebuild Remembered Sets Concurrently

• Remembered sets may occupy a lot of memory– Known to take ~20% of total heap in some situations

• E.g. 20GB with a 100GB heap

– Upper Bounds are even higher• O(#regions2)

• Old regions use most remembered set memory

23

Problem

Page 24: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Rebuild Remembered Sets ConcurrentlyCollection Cycle – Some Young-Only GCs

24

x

Remembered set

Region

Object

YO IM YO

Remark

YO

Cleanup

YO Mixed

YO … Young-OnlyIM … Initial-Mark

Page 25: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Rebuild Remembered Sets ConcurrentlyCollection Cycle – Start marking with Initial Mark

25

xx

Region

Object

YO IM YO

Remark

YO

Cleanup

YO Mixed

YO … Young-OnlyIM … Initial-Mark

Remembered set

Page 26: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Rebuild Remembered Sets ConcurrentlyCollection Cycle – Some more Young-Only while marking

26

xxx

Region

Object

YO IM YO

Remark

YO

Cleanup

YO Mixed

YO … Young-OnlyIM … Initial-Mark

x

Remembered set

Remembered set

Page 27: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Rebuild Remembered Sets ConcurrentlyCollection Cycle – Marking fnished

27

xxx

Region

Object

YO IM YO

Remark

YO

Cleanup

YO Mixed

YO … Young-OnlyIM … Initial-Mark

xxxx

Remembered set

Page 28: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Rebuild Remembered Sets ConcurrentlyCollection Cycle – Create “live data map”

28

xxx

Region

Object

YO IM YO

Remark

YO

Cleanup

YO Mixed

YO … Young-OnlyIM … Initial-Mark

xx

xxx

xx

Remembered set

Page 29: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Rebuild Remembered Sets ConcurrentlyCollection Cycle – Clean out obsolete remembered set entries

29

Region

Object

YO IM YO

Remark

YO

Cleanup

YO Mixed

YO … Young-OnlyIM … Initial-Mark

xx

xx

xx

x

Remembered set

Page 30: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Rebuild Remembered Sets ConcurrentlyCollection Cycle – Wait for old gen reclamation start

30

Region

Object

YO IM YO

Remark

YO

Cleanup

YO Mixed

YO … Young-OnlyIM … Initial-Mark

xx

xx

xxx

xx

xxx

xx

xxx

xx

xxx

xx

xx

x

x

Remembered set

Page 31: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Rebuild Remembered Sets ConcurrentlyCollection Cycle – Region gets evacuated

31

Region

Object

YO IM YO

Remark

YO

Cleanup

YO Mixed

YO … Young-OnlyIM … Initial-Mark

Page 32: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Rebuild Remembered Sets ConcurrentlyCollection Cycle – Region does not get reclaimed

32

x Region

Object

YO IM YO

Remark

YO

Cleanup

YO Mixed

YO … Young-OnlyIM … Initial-Mark

xxx

x x

xx

x

Remembered set

Page 33: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Rebuild Remembered Sets Concurrently

• G1 maintains remembered sets all the time for all regions– Not required

• Young regions: always• Old regions: only needed during Mixed GC

• Removing obsolete remembered set entries is costly– Create live data map

– Remove remembered set entries during Cleanup

Key observations

33

Page 34: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Rebuild Remembered Sets Concurrently

• Only keep required remembered sets when needed– For collection set regions only (<< all regions!)

– Minimizes fragmentation

• Construct remembered sets concurrently between Remark and Cleanup– Instead of live data map calculation

– No removal of obsolete remembered set entries during Cleanup pause

34

Solution

Page 35: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Rebuild Remembered Sets Concurrently

• Lengthens time from Remark to Cleanup– Up to 30% longer marking cycles

– Dynamic IHOP automatically adapts

• Improves Throughput and Pause Times– Less work outside of rebuild phase, creates dense remembered sets

Side efects

35

Page 36: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Rebuild Remembered Sets Concurrently

• Lengthens time from Remark to Cleanup– Up to 30% longer marking cycles

– Dynamic IHOP automatically adapts

• Improves Throughput and Pause Times– Less work outside of rebuild phase, creates dense remembered sets

• Allows bounded remembered set memory usage– Just stop collecting remembered sets for some regions

Side efects

36

Page 37: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Rebuild Remembered Sets Concurrently

• Baseline:– ~10% of maximum heap size

• Current:– ~0.5% outside of rebuilding and mixed gc phase

– ~7.5% after rebuilding 60% of the heap

Remembered set memory usage on BigRAMTester

37

Page 38: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Rebuild Remembered Sets Concurrently

38

Page 39: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Rebuild Remembered Sets Concurrently

39

Page 40: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Rebuild Remembered Sets Concurrently

• More information: JDK-8180415• Work in progress

40

Page 41: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Program Agenda

Parallel Full GC

Faster Card Scanning

Rebuild Remembered Concurrently

Abortable Mixed Collections

Automatic Thread Sizing

Participate!

1

2

3

4

5

41

6

Page 42: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Abortable Mixed Collections

• G1 strives to keep pause time goal– Determines “Collection set” using predictions at the start of GC

• Particularly during Mixed collections predictions are hard– G1 mispredicts often

– Signifcant efort to tune Mixed collection pauses

42

Problem

Page 43: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Abortable Mixed Collections

43

Free

O Old

Y Young

Y

O

Y

O

Java Heap

O

O O O

Page 44: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Abortable Mixed CollectionsCollection set

44

Free

O Old

Y Young

Y

O

Y

O

Java Heap

O

O O O

Page 45: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Abortable Mixed Collections

45

Free

O Old

Y Young

Y

O

Y

O

Java Heap Before

O

O O O

O

Java Heap After

O

Time taken

MaxPauseTime

Current evacuation policy

Page 46: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Abortable Mixed Collections

46

Free

O Old

Y Young

Y

O

Y

O

Java Heap Before

O

O O O

O

Java Heap After

O Y

O O

Time taken

MaxPauseTime

Current evacuation policy

Page 47: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Abortable Mixed Collections

47

Free

O Old

Y Young

Y

O

Y

O

Java Heap Before

O

O O O

O

Java Heap After

O Y

O O

Time taken

MaxPauseTime

Current evacuation policy exceeds pause time

Page 48: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Abortable Mixed Collections

• Incrementally evacuate collection set– “Abort” evacuation if next increment would take too long

48

Solution

Page 49: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Abortable Mixed Collections

49

Free

O Old

Y Young

Y

O

Y

O

Java Heap Before

O

O O O

O

Java Heap After

O

Time taken

MaxPauseTime

Try again, incrementally

Page 50: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Abortable Mixed Collections

50

Free

O Old

Y Young

Y

O

Y

O

Java Heap Before

O

O O O

O

Java Heap After

O Y

O

Time taken

First Young regions as a whole

MaxPauseTime

Page 51: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Abortable Mixed Collections

51

Free

O Old

Y Young

Y

O

Y

O

Java Heap Before

O

O O O

O

Java Heap After

O Y

O O

MaxPauseTime

Time taken

“Large” set of Old regions

Page 52: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Abortable Mixed Collections

52

Free

O Old

Y Young

Y

O

Y

O

Java Heap Before

O

O O O

O

Java Heap After

O Y

O O

“Small” set of Old regions

MaxPauseTime

Time taken

Page 53: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Abortable Mixed Collections

53

Free

O Old

Y Young

Y

O

Y

O

Java Heap Before

O

O O O

O

Java Heap After

O Y

O O

“Abort”

MaxPauseTime

Time taken

Page 54: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Abortable Mixed Collections

• Enter “abortable mode” only if needed– To decrease overhead

• More information– JEP draft: Abortable mixed collections for G1 JDK-8190269

• Work in progress

54

Page 55: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Program Agenda

Parallel Full GC

Faster Card Scanning

Rebuild Remembered Concurrently

Abortable Mixed Collections

Automatic Thread Sizing

Participate!

1

2

3

4

5

55

6

Page 56: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Automatic Thread Sizing

• Manually setting the right number of threads impossible– Or even not even desired

– Lots of work as hardware, application, even application phase specifc

– Can only set number of threads statically for everything• e.g. -XX:ParallelGCThreads, -XX:ConcGCThreads, -XX:ParallelRefProcEnabled

• Benefts of using the right number of threads– Saves resources, faster startup

– (Small pause time improvements)

56

Problem

Page 57: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Automatic Thread Sizing

• Let G1 automatically decide the optimal number of threads– G1 already tracks lots of statistics about a GC

• Actual bytes copied• References processed• Cards scanned• …

– Actually G1 already does that for a lot of phases since JDK9….

57

Solution

Page 58: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Automatic Thread Sizing - Example

58

Page 59: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Automatic Thread Sizing

• More information: JEP 308: G1 ergonomics JDK-8172792• Work in progress

59

Page 60: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Program Agenda

Parallel Full GC

Faster Card Scanning

Rebuild Remembered Sets On The Fly

Abortable Mixed GC

Automatic Thread Sizing

Participate!

1

2

3

4

5

60

6

Page 61: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Participate!

• Hang out on [email protected]– Provide answers to community

• Fix small bugs– Bugs labeled “starter”/”cleanup” on Hotspot GC component at

https://bugs.openjdk.java.net

– Discuss at [email protected]

• Interesting larger projects

61

Page 62: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Participate! - Larger projects

• NMethod barriers• Throughput barriers• NUMA support

62

Page 63: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Participate! – NMethod barriers

• NMethod barriers– Small piece of code that is run before NMethod is entered

• Could be used to disable pre-barrier when not in use• Most of the time!

63

... cmpb ofs(%tls), 0 jz NoPreBarrier call slow_pathNoPreBarrier: ...

...nopnopnop...

Page 64: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Participate! – Throughput barriers

• Throughput barriers– G1 has throughput defciencies

– Mostly write barrier related

• Use Parallel GC barrier instead of large G1 barrier– Increases throughput

– May or may not have some impact on latency/pause time

• More information: FOSDEM 2017 talk Three ideas for the G1 GC (and how to get involved)

64

Page 65: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Participate! - NUMA support

• NUMA support– Improve throughput on large multi-socket machines

– Exploit memory locality

– JEP 137 open for 6 years now (JDK-8046147)

65

Page 66: G1 – Not Never Done! - FOSDEM · G1 Parallel Full GC 8 system.gc() test – performs many System.gc(), very small live set, 5G heap BigRAMTester – LRU-cache-stress test application,

Copyright © 2018, Oracle and/or its afliates. All rights reserved. |

Questions?

(See you on hotspot-gc-use/[email protected])

([email protected])

66