`

An article about TLAB

    博客分类:
  • Java
 
阅读更多

(From: https://blogs.oracle.com/jonthecollector/entry/the_real_thing)

 

A Thread Local Allocation Buffer (TLAB) is a region of Eden
that is used for allocation by a single thread.  It enables
a thread to do object allocation using thread local top and
limit pointers, which is faster than doing an atomic operation
on a top pointer that is shared across threads.


A thread acquires a TLAB at it's first object allocation
after a GC scavenge.  The size of the TLAB is computed via
a somewhat complex process discribed below.  The TLAB is
released when it is full (or nearly so), or the next GC scavenge
occurs. TLABs are allocated only in Eden, never from From-Space
or the OldGen.

Flags               default description

          
UseTLAB     true   Use thread-local object allocation
ResizeTLAB  false  Dynamically resize tlab size for threads
TLABSize           (below) Default (or starting) size of a TLAB (in bytes)
TLABWasteTargetPercent   1    Percentage of Eden that can be wasted
PrintTLAB              false  Print various TLAB related information

AggressiveHeap settings:

  TLABSize          256Kb
  ResizeTLAB        true     (Corrected 2007/05/09)

Minor flags

MinTLABSize             2\*K   Minimum allowed TLAB size (in bytes)
TLABAllocationWeight     35   Weight for exponential averaging of allocation
TLABRefillWasteFraction  64   Max TLAB waste at a refill (internal fragmentation)
TLABWasteIncrement        4   Increment allowed waste at slow allocation
ZeroTLAB              false   Zero out the newly created TLAB

These flags are for tuning the current implementation of
TLABs and maybe disappear or change their initial value in a
future release of the jvm.

If it is not specified on the command-line (or specified as zero)
via the -XX:TLABSize flag, the initial size of a TLAB is computed as:

  init_size = size_of_eden / (allocating_thread_count \* target_refills_per_epoch)

where:

  a) Allocating_thread_count is the expected number of threads
    which will be actively allocating during the next epoch
    (an epoch is the mutator time between GC scavenges.)
    At jvm startup this is defined to be one.  It is then
    recomputed at each GC scavenge from the number of threads
    that did at least one allocation of a tlab during the
    latest epoch. It's then exponentially averaged over the
    past epochs.
 
  b) Target_refills_per_epoch is the desired number of tlab
    allocations per thread during an epoch.  It is computed from
    the value of TLABWasteTargetPercent which is the percentage of
    Eden allowed to be wasted due to TLAB fragmentation.
 
    From a mutator thread's perspective a GC scavenge can occur
    unexpectedly at any time.  So, on average, only half of a
    thread's current TLAB will be allocated when a GC scavenge
    occurs.
 
      TLABWasteTargetPercent = 0.5 \* (1/target_refills_per_epoch) \* 100
 
    Solving for target_refills_per_epoch:
 
      target_refills_per_epoch = ( 0.5 \* 100) / TLABWasteTargetPercent
 
    With the default value of 1 for TLABWasteTargetPercent
 
      target_refills_per_epoch =  50


When TLABResize is true (which it is by default) the tlab size
  is recomputed for each thread that did an allocation in the latest
  epoch.  Threads that did not allocate in the latest epoch do not
  have their TLABs resized.  The resize goal is to get the number
  of refills closer to the ideal: target_refills_per_epoch (default
  value is 50).  For each thread, the number of refills in the latest
  epoch is exponentially averaged with values from previous
  epochs.  If this average refill number is greater than
  target refills_per_epoch, then the tlab size is increased.  If
  the average is less, the tlab size is decreased.
 
  The computation is (approximately):
 
     new_size = (old_size \* avg_refills_per_epoch) / target_refills_per_epoch
 
  It's actually computed from the fraction of the latest epoch's
  eden size used by this thread, because the next epoch may use a
  resized eden.

To experiment with a specific TLAB size, two -XX flags need
  to be set, one to define the initial size, and one to disable
  the resizing:

     -XX:TLABSize= -XX:-ResizeTLAB

  The minimum size of a tlab is set with -XX:MinTLABSize which
  defaults to 2K bytes.  The maximum size is the maximum size
  of an integer Java array, which is used to fill the unallocated
  portion of a TLAB when a GC scavenge occurs.


Diagnostic Printing Options

-XX:+PrintTLAB

  Prints at each scavenge one line for each thread (starts with "TLAB: gc thread: "
  without the "'s) and one summary line.

Thread example:

TLAB: gc thread: 0x0004ac00 [id:  2] size: 61KB slow allocs: 5  refill waste: 980B
         alloc: 0.99996     3072KB refills: 50 waste  0.1% gc: 0B slow: 4144B fast: 0B

  The tag "gc" indicates that this information was printed at a GC scavenge,
  after the tlabs have been filled. The "gc" tag doesn't mean a thread is a gc
  thread.
 
  Fields:
 
  thread:
 
     The address of the gc thread structure and it's system thread id.
 
  size:
 
     The size of the tlab in kilobytes.
 
  slow allocs:
 
     The number of allocations too large for remaining space in the TLAB.
     The allocation was done directly in eden space.
 
  refill waste: (in HeapWord units)
 
     The name is truncated in the dump, and should be: refill_waste_limit
     and is used to limit the amount of wasted space from internal
     fragmentation.  If the remaining space in the TLAB is larger than
     this amount, and an allocation is requested that is too large to
     be allocated in the TLAB, then the allocation is done directly in
     Eden and the TLAB is not retired.  If the remaining space is less
     than refill_waste_limit then the TLAB is retired, a new TLAB is
     allocated, and the object allocation is attempted in the new TLAB.

     After each allocation outside of the TLAB, the refill_waste_limit
     is incremented by TLABWasteIncrement to prevent an allocation of
     a size slightly less than refill_waste_limit from continually
     being allocated outside of the TLAB.

  alloc: [fraction]  [sizeInBytes]

     Expected amount of eden allocated by this thread computed as
     a fraction of eden and number of heap words.

  refills:

     Number of tlab refills.    

  waste [percent] gc: [bytes] slow: [bytes] fast: [bytes]

     Percentage of eden allocated to this thread that was wasted.
     Waste is the sum of three components:
        gc:   unused space in the current TLAB when stopped for a scavenge.
        slow: sum of unused space in TLABs when they're retired to allocate a new one.
        fast: the client system can allocate a TLAB with a fast allocator.
              This is the amount of waste via that method.

Summary example:

TLAB totals: thrds: 1  refills: 50 max: 50 slow allocs: 5 max 5 waste:  0.1%
             gc: 0B max: 0B slow: 4144B max: 4144B fast: 0B max: 0B

  thrds:

     Number of threads that did an allocation.
             
  refills: [tt] max: [mm]

     Total number of TLAB refills by all threads, and
     maximun number of TLAB refills by a single thread.

  slow allocs: [ss] max [mm]

     Total number of allocations done outside of a TLAB, and
     maximum number by a single thread.

  waste [percent] gc: [bytes] slow: [bytes] max: [mm] fast: [bytes] max: [mm]

     Percentage of eden that was wasted across all threads.
     Waste is the sum of three components:
        gc:   unused space in the current TLABs when scavenge starts.
        slow: sum of unused space in TLABs when they're retired to allocate a new ones.
        fast: the client system can allocate a TLAB with a fast allocator.
              This is the amount of waste via that method.

     For "slow" and "fast", the maximum value by a single thread is printed.


More detail with addition of Verbose flag.

-XX:+PrintTLAB -XX:+Verbose

  Using both: -XX:+PrintTLAB -XX:+Verbose will print the
  new tlab sizes for each thread when it is resized.  Resizing is
  only done at GC scavenges.

  Example:

TLAB new size: thread: 0x001eac00 [id: 19] refills 50  alloc: 0.402570 size: 19684 -> 18996

  New size 18996.  Previous size was: 19684.

  refills:

     Number of tlab refills for this thread.

  alloc:

     The expected fraction of eden this thread will use.

分享到:
评论

相关推荐

    matlab开发-CALIPSOS卫星时间转换为TLAB时间

    在MATLAB编程环境中,开发针对特定任务的工具是常见的需求,比如本例中的"MATLAB开发-CALIPSOS卫星时间转换为TLAB时间"。这个项目聚焦于将CALIOP仪器HDF(Hierarchical Data Format)文件中记录的时间数据转换为TLAB...

    matlab开发-在TLAB中使用ekassvmregessionfunctions

    - **调用TLAB**:在MATLAB中,你需要初始化TLAB接口,这通常涉及加载TLAB库并创建一个TLAB对象。 - **设置SVM参数**:EKSVMRegression允许你调整各种参数,如ε值、核函数类型(如线性、多项式或高斯RBF)、核函数...

    matlab开发-将Qdata从Tektronixrstsatlab转换为Tlab.zip

    在MATLAB开发中,将Qdata从Tektronix RSTSatLab格式转换为TLab格式是一项常见的任务,特别是在处理Tektronix示波器捕获的数据时。Qdata是Tektronix设备存储数据的一种专有格式,而TLab是MATLAB中用于分析这种数据的...

    matlab开发-TLAB中的活动检测.zip

    在MATLAB开发中,TLAB(可能是指"Telematics Lab"或自定义工具箱)是一个用于特定领域,如信号处理、图像分析或机器学习的扩展库。在这个案例中,我们关注的是“活动检测”,这是一个在计算机视觉和图像处理领域中的...

    TLAB调用CPP代码例子

    "TLAB调用CPP代码例子"就是一个这样的实践,它展示了如何通过MATLAB的MEX接口来调用C++代码。MEX文件是MATLAB可执行的二进制模块,能够直接在MATLAB环境中运行,使得MATLAB与C++之间实现高效的数据交换。 首先,...

    matlab开发-在TLAB中筛选关键点检测器

    在MATLAB开发环境中,TLAB(Toolbox for Local Image Analysis and Processing)是一个强大的扩展工具箱,专注于图像处理和分析,特别是在关键点检测方面。本文将深入探讨如何在TLAB中利用SIFT(Scale-Invariant ...

    matlab开发-在TLAB中对部件的时间进行视频指导.zip

    《MATLAB开发:在TLAB中对部件时间的视频指导》 MATLAB,全称“Matrix Laboratory”,是一款强大的数学计算软件,广泛应用于工程计算、数据分析、算法开发、模型创建等多个领域。TLAB,可能指的是“Toolbox for LAB...

    matlab开发-应用TLAB分析微阵列的意义

    本文将深入探讨MATLAB开发与应用TLAB(可能指的是一个基于MATLAB的微阵列数据分析工具)分析微阵列的意义。 首先,MATLAB提供的强大数学函数库和灵活的编程环境,使得开发针对微阵列数据的分析算法变得相对容易。...

    matlab开发-在TLAB中执行的wsnsimualation

    标题中的“matlab开发-在TLAB中执行的wsnsimualation”指的是使用MATLAB进行无线传感器网络(Wireless Sensor Network, WSN)的模拟,而TLAB可能是一个特定的MATLAB工具箱或者工作环境,用于支持并行计算和仿真。...

    matlab开发-TLAB中的Kernelridger出口

    在MATLAB开发环境中,TLAB是一个可能的工具箱或者自定义库,用于扩展MATLAB的功能。本主题聚焦于"Kernel Ridge Regression"(核岭回归)的实现,这是一种结合了核方法与岭回归的统计学习技术。它在处理非线性问题和...

    matlab开发-TLAB中的可编辑表格

    在MATLAB开发中,TLAB库提供了一种高级的数据可视化工具——可编辑表格。这种功能使得用户能够在图形界面中直接操作数据,进行编辑、查看和分析,极大地提升了交互性和效率。下面将详细介绍这个功能及其应用。 一、...

    matlab开发-在TLAB中使用时间周期数据

    TLAB(可能是指Time Lab)是MATLAB的一个扩展工具或工作环境,专为处理时间序列数据提供便利。以下是对“在TLAB中使用时间周期数据”这一主题的详细解释。 时间序列数据指的是按照特定时间顺序收集的一系列数值数据...

    matlab开发-在TLAB中高效地处理大型数据集

    在本文中,我们将深入探讨如何在TLAB环境中有效地处理这些大规模的数据。 首先,了解TLAB是什么至关重要。TLAB可能指的是一个自定义的MATLAB工作环境或者一个专门用于大数据处理的MATLAB扩展工具箱。尽管没有足够的...

    matlab开发-TLAB中的结构和运动工具包

    在MATLAB开发中,TLAB(可能是指一个特定的MATLAB工具箱)提供了对结构和运动处理的高级功能。这个工具包旨在帮助用户在MATLAB环境中处理与结构和物体运动相关的问题,例如图像处理、三维重建、跟踪以及机器人学等...

    matlab开发-在TLAB中使用SOSON设计的设备

    标题中的“matlab开发-在TLAB中使用SOSON设计的设备”指的是使用MATLAB进行软件开发,并在TLAB环境中运用SOSON(可能是特定的工具或库)来设计和优化设备。描述中提到的“粒子群优化在Matlab设备布局设计中的应用”...

    matlab开发-TLAB中的Kernelridger出口.zip

    这个压缩包文件“matlab开发-TLAB中的Kernelridger出口.zip”似乎包含了与在MATLAB环境下使用KernelRidge回归算法相关的代码或者工具箱资源。下面将详细介绍KernelRidge回归以及它在MATLAB中的实现。 **KernelRidge...

    matlab开发-加速有限元分析在TLAB中有效

    在MATLAB开发中,加速有限元分析(FEA)在TLAB中的有效性是现代工程计算领域的一个重要课题。有限元分析是一种数值方法,用于解决各种工程和物理问题,如结构力学、热传导、流体力学等。在TLAB环境下,通过有效利用...

    matlab开发-在TLAB中实现多条件algotolike.zip.zip

    在MATLAB开发中,TLAB(可能是指Toolbox或特定的工作环境)被用作一个平台来构建和执行多条件算法。这个"algotolike"可能是用户自定义的一个算法库或者一种特定的算法模板,旨在处理复杂的问题。下面将详细讨论如何...

    matlab开发-将Qdata从Tektronixrstsatlab转换为Tlab

    标题提到的"matlab开发-将Qdata从Tektronixrstsatlab转换为Tlab"是关于如何利用MATLAB读取Tektronix实时频谱分析仪(RTSAnalyzer)的数据,并将其转化为特定格式,即Tlab格式,以便进一步处理或分析。Tektronix是一家...

    matlab开发-在TLAB中使用Ekassvm分类功能

    本教程将详细介绍如何在TLAB中集成Weka库,并通过EkaSVM进行分类任务。 首先,你需要确保已经安装了MATLAB和TLAB。TLAB是MATLAB的一个扩展,提供了更多的统计和机器学习工具。同时,你也需要下载并安装Weka库,这是...

Global site tag (gtag.js) - Google Analytics