gpt4 book ai didi

java - jdk11 g1gc 花费大量时间准备 TLAB

转载 作者:行者123 更新时间:2023-12-04 11:39:07 27 4
gpt4 key购买 nike

gc.log 显示 Prepare TLABs 阶段花费了大约 57 秒,这是 Not Acceptable 。而且,这种情况五天才发生一次。我只想弄清楚究竟发生了什么以及如何避免。
[gc.log]

[2021-08-02T11:38:38.134+0800][322490.377s][161325][safepoint     ] Entering safepoint region: G1CollectForAllocation
[2021-08-02T11:38:38.134+0800][322490.378s][161325][gc,start ] GC(238) Pause Young (Normal) (G1 Evacuation Pause)
[2021-08-02T11:38:38.134+0800][322490.378s][161325][gc,task ] GC(238) Using 18 workers of 18 for evacuation
[2021-08-02T11:39:35.179+0800][322547.422s][161325][gc,phases ] GC(238) Pre Evacuate Collection Set: 0.1ms
[2021-08-02T11:39:35.179+0800][322547.422s][161325][gc,phases ] GC(238) Prepare TLABs: 57039.1ms
[2021-08-02T11:39:35.179+0800][322547.422s][161325][gc,phases ] GC(238) Choose Collection Set: 0.0ms
[2021-08-02T11:39:35.179+0800][322547.422s][161325][gc,phases ] GC(238) Humongous Register: 0.1ms
[2021-08-02T11:39:35.179+0800][322547.422s][161325][gc,phases ] GC(238) Evacuate Collection Set: 3.8ms
[2021-08-02T11:39:35.179+0800][322547.422s][161325][gc,phases ] GC(238) Ext Root Scanning (ms): Min: 0.0, Avg: 0.4, Max: 3.5, Diff: 3.5, Sum: 7.2, Workers: 18
[2021-08-02T11:39:35.179+0800][322547.422s][161325][gc,phases ] GC(238) Update RS (ms): Min: 0.0, Avg: 0.5, Max: 0.9, Diff: 0.9, Sum: 8.7, Workers: 18
[2021-08-02T11:39:35.179+0800][322547.422s][161325][gc,phases ] GC(238) Processed Buffers: Min: 0, Avg: 2.9, Max: 16, Diff: 16, Sum: 53, Workers: 18
[2021-08-02T11:39:35.179+0800][322547.422s][161325][gc,phases ] GC(238) Scanned Cards: Min: 0, Avg: 265.7, Max: 623, Diff: 623, Sum: 4783, Workers: 18
[2021-08-02T11:39:35.179+0800][322547.422s][161325][gc,phases ] GC(238) Skipped Cards: Min: 0, Avg: 20.4, Max: 32, Diff: 32, Sum: 368, Workers: 18
[2021-08-02T11:39:35.179+0800][322547.422s][161325][gc,phases ] GC(238) Scan RS (ms): Min: 0.0, Avg: 0.2, Max: 0.3, Diff: 0.3, Sum: 3.2, Workers: 18
[2021-08-02T11:39:35.179+0800][322547.422s][161325][gc,phases ] GC(238) Scanned Cards: Min: 0, Avg: 27.3, Max: 120, Diff: 120, Sum: 491, Workers: 18
[2021-08-02T11:39:35.179+0800][322547.422s][161325][gc,phases ] GC(238) Claimed Cards: Min: 0, Avg: 29.9, Max: 129, Diff: 129, Sum: 538, Workers: 18
[2021-08-02T11:39:35.179+0800][322547.422s][161325][gc,phases ] GC(238) Skipped Cards: Min: 0, Avg: 187.6, Max: 347, Diff: 347, Sum: 3377, Workers: 18
[2021-08-02T11:39:35.179+0800][322547.422s][161325][gc,phases ] GC(238) Code Root Scanning (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1, Workers: 18
[2021-08-02T11:39:35.179+0800][322547.422s][161325][gc,phases ] GC(238) AOT Root Scanning (ms): skipped
[2021-08-02T11:39:35.179+0800][322547.422s][161325][gc,phases ] GC(238) Object Copy (ms): Min: 0.0, Avg: 2.0, Max: 2.6, Diff: 2.6, Sum: 35.7, Workers: 18
[2021-08-02T11:39:35.179+0800][322547.422s][161325][gc,phases ] GC(238) Termination (ms): Min: 0.0, Avg: 0.4, Max: 0.6, Diff: 0.6, Sum: 7.4, Workers: 18
[2021-08-02T11:39:35.179+0800][322547.423s][161325][gc,phases ] GC(238) Termination Attempts: Min: 1, Avg: 4.8, Max: 9, Diff: 8, Sum: 86, Workers: 18
[2021-08-02T11:39:35.179+0800][322547.423s][161325][gc,phases ] GC(238) GC Worker Other (ms): Min: 0.0, Avg: 0.1, Max: 0.3, Diff: 0.2, Sum: 2.2, Workers: 18
[2021-08-02T11:39:35.179+0800][322547.423s][161325][gc,phases ] GC(238) GC Worker Total (ms): Min: 3.4, Avg: 3.6, Max: 3.7, Diff: 0.3, Sum: 64.7, Workers: 18
[2021-08-02T11:39:35.179+0800][322547.423s][161325][gc,phases ] GC(238) Post Evacuate Collection Set: 1.0ms
[2021-08-02T11:39:35.179+0800][322547.423s][161325][gc,phases ] GC(238) Code Roots Fixup: 0.0ms
[2021-08-02T11:39:35.179+0800][322547.423s][161325][gc,phases ] GC(238) Clear Card Table: 0.2ms
[2021-08-02T11:39:35.179+0800][322547.423s][161325][gc,phases ] GC(238) Reference Processing: 0.1ms
[2021-08-02T11:39:35.179+0800][322547.423s][161325][gc,phases ] GC(238) Weak Processing: 0.1ms
[2021-08-02T11:39:35.179+0800][322547.423s][161325][gc,phases ] GC(238) Merge Per-Thread State: 0.1ms
[2021-08-02T11:39:35.179+0800][322547.423s][161325][gc,phases ] GC(238) Code Roots Purge: 0.0ms
[2021-08-02T11:39:35.179+0800][322547.423s][161325][gc,phases ] GC(238) Redirty Cards: 0.1ms
[2021-08-02T11:39:35.179+0800][322547.423s][161325][gc,phases ] GC(238) DerivedPointerTable Update: 0.0ms
[2021-08-02T11:39:35.179+0800][322547.423s][161325][gc,phases ] GC(238) Free Collection Set: 0.3ms
[2021-08-02T11:39:35.179+0800][322547.423s][161325][gc,phases ] GC(238) Humongous Reclaim: 0.1ms
[2021-08-02T11:39:35.179+0800][322547.423s][161325][gc,phases ] GC(238) Start New Collection Set: 0.0ms
[2021-08-02T11:39:35.179+0800][322547.423s][161325][gc,phases ] GC(238) Resize TLABs: 0.0ms
[2021-08-02T11:39:35.179+0800][322547.423s][161325][gc,phases ] GC(238) Expand Heap After Collection: 0.0ms
[2021-08-02T11:39:35.179+0800][322547.423s][161325][gc,phases ] GC(238) Other: 57039.6ms
[2021-08-02T11:39:35.179+0800][322547.423s][161325][gc,heap ] GC(238) Eden regions: 865->0(867)
[2021-08-02T11:39:35.179+0800][322547.423s][161325][gc,heap ] GC(238) Survivor regions: 27->25(112)
[2021-08-02T11:39:35.179+0800][322547.423s][161325][gc,heap ] GC(238) Old regions: 20->20
[2021-08-02T11:39:35.179+0800][322547.423s][161325][gc,heap ] GC(238) Humongous regions: 5->5
[2021-08-02T11:39:35.180+0800][322547.423s][161325][gc,metaspace ] GC(238) Metaspace: 45664K->45664K(1091584K)
[2021-08-02T11:39:35.180+0800][322547.423s][161325][gc ] GC(238) Pause Young (Normal) (G1 Evacuation Pause) 916M->48M(1488M) 57045.332ms
[2021-08-02T11:39:35.180+0800][322547.423s][161325][gc,cpu ] GC(238) User=0.00s Sys=0.09s Real=57.05s
[2021-08-02T11:39:35.180+0800][322547.423s][161325][safepoint ] Leaving safepoint region
[2021-08-02T11:39:35.180+0800][322547.423s][161325][safepoint ] Total time for which application threads were stopped: 57.0457609 seconds, Stopping threads took: 0.0000407 seconds

最佳答案

就我而言,gc 日志不足以找到根本原因。
一些建议:

  • 添加 -Xlog:gc+tlab=debug显示与 TLAB 相关的日志。
  • 注意日志以:“TLAB totals: thrds:”开头,引用TLAB源码:threadLocalAllocBuffer.cpp
  • 与gc日志对比分析可能出现的问题
  • 如果日志显示“TLAB totals: thrds:”和“Pre Evacuate Collection Set”之间有很大的延迟,你应该深入研究“TLAB totals: thrds:”日志并找出原因(线程数太大,新创建线程并分配一些新对象...)
  • 如果日志显示“TLAB totals: thrds:”和“Pre Evacuate Collection Set”之间几乎没有延迟,那么您应该将日志级别切换到 -Xlog:gc*=debug了解更多信息

  • 一些怀疑:
  • 也许有很多新创建的线程,每个线程至少创建一个对象。这可能会导致 TLAB 准备缓慢,因为会有很多 TLAB 来填充虚拟对象。
  • 关于java - jdk11 g1gc 花费大量时间准备 TLAB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68644526/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com