我爱编程

JVM

2018-04-17  本文已影响0人  踏雪寻梅4149

JVM Tuning

很久以前的PPT,乘着最近对JVM的又一次折腾,再整理出来,分享一下。 

Hotspot JVM Architecture v.s. Memory Layout Of a Process

了解JVM之前,我们首先可以对操作系统的进程的内存布局作个了解,JVM作为操作系统的一个进程,大致上还是遵从了
进程的内存布局,并且两着直接有一定的关系。


process-mem.png jvm-archi.png

每个方法被执行的时候都会同时创建一个栈帧(Stack Frame)用于存储局部变量表、操作栈、动态链接、方法出口
等信息。每一个方法被调用直至执行完成的过程,就对应着一个栈帧在虚拟机栈中从入栈到出栈的过程。

proc.png

VmLck:正在锁住的物理内存
VmHWM:使用的物理内存的峰值
VmRSS:当前正在使用的物理内存
VmData:

heap.png

reference: https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/toc.html

Introduction

JVM tuning parameters

JVM调优的目标是什么?

Pauses are the times when an application appears unresponsive because garbage collection is occurring.
Throughput is the percentage of total time not spent in garbage collection considered over long periods of time. Throughput includes time spent in allocation (but tuning for speed of allocation is generally not needed).
If the throughput and maximum pause time goals have been met, then the garbage collector reduces the size of the heap until one of the goals (invariably the throughput goal) cannot be met. The goal that is not being met is then addressed.

GC Logs

-XX:PrintGCDetails -Xloggc
eg: -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Xloggc:/logs/gc.log

https://blog.csdn.net/f59130/article/details/74013460

堆栈大小调优

Xms Xmx NewRatio NewSize MaxNewSize SurvivorRatio
https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/toc.html

heap-adjust.png heap-new.png

如何查看分析JVM问题

https://mp.weixin.qq.com/s?__biz=MzAxMzQ3NzQ3Nw==&mid=2654249460&idx=3&sn=7233b88a667c24cad4d9ef99a9a28112&chksm=8061f2feb7167be8b21d29460df7e5f15a802f00e5ce2288c57b6410fb67b64b09dceac25035&scene=0&key=a226a081696afed0ced8883ddef645ec886e24bc65882754aad279d07970c51c599395c5e971e56fb42d3ad73ecac99ea91dcfac61c6eaa5b14d06eb267d46c03ab005b1899892bfa5a99d21f0cf1783&ascene=0&uin=MjEzNDU4ODUyMw%3D%3D&devicetype=iMac+MacBookPro12%2C1+OSX+OSX+10.11.6+build(15G1108)&version=12010210&nettype=WIFI&fontScale=100&pass_ticket=lQkdjKFceno65864XSxiVmIPnc19RTijAJnu8ZWf%2BJPjCtoSCdDRCp%2F9MrMzDXqV

gc算法

算法主要步骤:
- Initial mark(STW, single-thread) :Stop all application threads, identify the set of objects reachable from roots, and then resume all application threads.
- Concurrent mark : Concurrently trace the reachable object graph, using one or more processors, while the application threads are executing.
- Concurrent pre-clean[part of remark work] :
- Remark(STW, multi-thread) : Stop all application threads and retrace sections of the roots and object graph that may have been modified since they were last examined, and then resume all application threads.
- Concurrent sweep : Concurrently sweep up the unreachable objects to the free lists used for allocation, using one processor.
- Concurrent reset: Concurrently resize the heap and prepare the support data structures for the next collection cycle, using one processor.

G1算法主要步骤:

上一篇 下一篇

猜你喜欢

热点阅读