Weitere ähnliche Inhalte
Mehr von Vladimir Ivanov (9)
Многоуровневая компиляция в HotSpot JVM
- 1. India
3–4 May 2012
San Francisco
September 30–October 4, 2012
1 Copyright © 2012, Oracle and/or its affiliates. All rights Insert Informaion Protection Policy Classification from Slide 7
reserved.
- 2. Многоуровневая компиляция в HotSpot JVM
Владимир Иванов
Oracle Corporation
2 Copyright © 2012, Oracle and/or its affiliates. All rights Insert Informaion Protection Policy Classification from Slide 7
vladimir.x.ivanov@oracle.com
reserved.
- 3. JIT-компиляторы в HotSpot JVM
• Client / C1
• java -client …
• быстро генерирует приемлемый машинный код
• Базовые оптимизации
• Не требуется профиль исполнения кода
• Порог компиляции: 1.5к вызовов
• Server / C2
• java -server …
• Генерирует максимально быстрый код
• Большое количество агрессивных оптимистичных
оптимизаций
• Порог компиляции: 10к вызовов
3 Copyright © 2012, Oracle and/or its affiliates. All rights Insert Informaion Protection Policy Classification from Slide 7
reserved.
- 4. JIT-компиляторы в HotSpot JVM
Сильные и слабые стороны
• Client / C1
“+” Быстрый старт приложения
“-” Страдает пиковая производительность
• Server / C2
“+” Быстрый код для «горячих» методов
“-” Требуется долгий «разогрев» приложения
4 Copyright © 2012, Oracle and/or its affiliates. All rights Insert Informaion Protection Policy Classification from Slide 7
reserved.
- 5. Многоуровневая компиляци
Цели
• Взять лучшее от 2 компиляторов
• Производительность кода серверного компилятора
• Скорость запуска, как с клиентским компилятором
• Автоматическая настройка
5 Copyright © 2012, Oracle and/or its affiliates. All rights Insert Informaion Protection Policy Classification from Slide 7
reserved.
- 6. Сценарий работы
• Начать исполнение в интерпретаторе
• Быстро создать версию C1 для профилирования
• На основе собранной информации скомпилировать
C2
6 Copyright © 2012, Oracle and/or its affiliates. All rights Insert Informaion Protection Policy Classification from Slide 7
reserved.
- 7. Уровни компиляции
• 5 уровней
• #0: интерпретатор
• профилирование по необходимости
• #1: C1 без профилирования
• #2: С1 с базовым профилированием
• Invocation & backedge counters
• #3: С1 с полным профилированием
• Invocation & backedge counters + MDO
• На 30% медленнее #2
• #4: C2
7 Copyright © 2012, Oracle and/or its affiliates. All rights Insert Informaion Protection Policy Classification from Slide 7
reserved.
- 8. Профилирование
• Сбор информации о деталях исполнения метода
• Требуется C2 для ряда оптимизаций
• Профилирование происходит на уровнях #0 и #3
• Что интересует
• Ветвления
• Вызовы виртуальных методов
• Проверки типов
• сheckcast, instanceof, aastore
• null-значения
8 Copyright © 2012, Oracle and/or its affiliates. All rights Insert Informaion Protection Policy Classification from Slide 7
reserved.
- 9. Эргономика
• Порог на изменение уровня зависит от длины
очереди на компиляцию
• Учитывается очередь и С1, и С2
• Приоритизация методов в очереди
9 Copyright © 2012, Oracle and/or its affiliates. All rights Insert Informaion Protection Policy Classification from Slide 7
reserved.
- 10. Уровни компиляции
3 4
0
2 1
0: интерпретатор
1: C1 w/o profiling
2: С1 + basic profiling
3: С1 + full profiling
4: C2
10 Copyright © 2012, Oracle and/or its affiliates. All rights Insert Informaion Protection Policy Classification from Slide 7
reserved.
- 11. Стандартный сценарий
3 4
0
2 1
0: интерпретатор
1: C1 w/o profiling
0→3→4 2: С1 + basic profiling
3: С1 + full profiling
4: C2
11 Copyright © 2012, Oracle and/or its affiliates. All rights Insert Informaion Protection Policy Classification from Slide 7
reserved.
- 12. Компиляция простого метода
3 4
0
2 1
0: интерпретатор
1: C1 w/o profiling
0 → (2,3) → 1 2: С1 + basic profiling
3: С1 + full profiling
4: C2
12 Copyright © 2012, Oracle and/or its affiliates. All rights Insert Informaion Protection Policy Classification from Slide 7
reserved.
- 13. Очередь на компиляцию С1 переполнена
3 4
0
2 1
0: интерпретатор
1: C1 w/o profiling
0 → (3 → 2) → 4 2: С1 + basic profiling
3: С1 + full profiling
4: C2
13 Copyright © 2012, Oracle and/or its affiliates. All rights Insert Informaion Protection Policy Classification from Slide 7
reserved.
- 14. Очередь на компиляцию C2 переполнена
3 4
0
2 1
0: интерпретатор
1: C1 w/o profiling
0→2→3→4 2: С1 + basic profiling
3: С1 + full profiling
4: C2
14 Copyright © 2012, Oracle and/or its affiliates. All rights Insert Informaion Protection Policy Classification from Slide 7
reserved.
- 15. Метод не может быть скомпилирован C1
3 4
0
2 1
0: интерпретатор
1: C1 w/o profiling
0→4 2: С1 + basic profiling
3: С1 + full profiling
4: C2
15 Copyright © 2012, Oracle and/or its affiliates. All rights Insert Informaion Protection Policy Classification from Slide 7
reserved.
- 16. Деоптимизация
3 4
0
2 1
0: интерпретатор
1: C1 w/o profiling
(1,2,3,4) → 0 2: С1 + basic profiling
3: С1 + full profiling
4: C2
16 Copyright © 2012, Oracle and/or its affiliates. All rights Insert Informaion Protection Policy Classification from Slide 7
reserved.
- 17. Использование
• -XX:+TieredCompilation
• В скором будущем режим по-умолчанию
– $ java -server …
– $ java -client …
17 Copyright © 2012, Oracle and/or its affiliates. All rights Insert Informaion Protection Policy Classification from Slide 7
reserved.
- 18. Q&A
18 Copyright © 2012, Oracle and/or its affiliates. All rights Insert Informaion Protection Policy Classification from Slide 7
reserved.
- 19. India
3–4 May 2012
San Francisco
September 30–October 4, 2012
19 Copyright © 2012, Oracle and/or its affiliates. All rights Insert Informaion Protection Policy Classification from Slide 7
reserved.