JS_GetGCParameter 编辑

Adjust performance parameters related to garbage collection.

Syntax

uint32_t
JS_GetGCParameter(JSRuntime *rt, JSGCParamKey key);

void
JS_SetGCParameter(JSRuntime *rt, JSGCParamKey key, uint32_t value);

uint32_t
JS_GetGCParameterForThread(JSContext *cx, JSGCParamKey key); // Added in SpiderMonkeySidebar 17

void
JS_SetGCParameterForThread(JSContext *cx, JSGCParamKey key, uint32_t value); // Added in SpiderMonkeySidebar 17
NameTypeDescription
rtJSRuntime *The runtime to configure.
cxJSContext *The context to configure. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext.
keyJSGCParamKeySpecifies which garbage collection parameter to get or set.
valueuint32_t(JS_SetGCParameter only) The value to assign to the parameter.
typedef enum JSGCParamKey {
    JSGC_MAX_BYTES,
    JSGC_MAX_MALLOC_BYTES,
    JSGC_MAX_NURSERY_BYTES,
    JSGC_BYTES,
    JSGC_NUMBER,
    JSGC_MODE,
    JSGC_UNUSED_CHUNKS,
    JSGC_TOTAL_CHUNKS,
    JSGC_SLICE_TIME_BUDGET,
    JSGC_MARK_STACK_LIMIT,
    JSGC_HIGH_FREQUENCY_TIME_LIMIT,
    JSGC_HIGH_FREQUENCY_LOW_LIMIT,
    JSGC_HIGH_FREQUENCY_HIGH_LIMIT,
    JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX,
    JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN,
    JSGC_LOW_FREQUENCY_HEAP_GROWTH,
    JSGC_DYNAMIC_HEAP_GROWTH,
    JSGC_DYNAMIC_MARK_SLICE,
    JSGC_ALLOCATION_THRESHOLD,
    JSGC_MIN_EMPTY_CHUNK_COUNT,
    JSGC_MAX_EMPTY_CHUNK_COUNT,
    JSGC_COMPACTION_ENABLED,
    JSGC_ALLOCATION_THRESHOLD_FACTOR,
    JSGC_ALLOCATION_THRESHOLD_FACTOR_AVOID_INTERRUPT,
    JSGC_NURSERY_FREE_THRESHOLD_FOR_IDLE_COLLECTION,
    JSGC_PRETENURE_THRESHOLD,
    JSGC_PRETENURE_GROUP_THRESHOLD,
    JSGC_NURSERY_FREE_THRESHOLD_FOR_IDLE_COLLECTION_PERCENT,
    JSGC_MIN_NURSERY_BYTES,
    JSGC_MIN_LAST_DITCH_GC_PERIOD,
} JSGCParamKey;
Value (C++/JS Shell)Description
JSGC_MAX_BYTES / "maxBytes"Maximum nominal heap before last ditch GC.
JSGC_MAX_MALLOC_BYTES / "maxMallocBytes"Number of JS_malloc bytes before last ditch GC.
JSGC_MAX_NURSERY_BYTES / "maxNurseryBytes"Maximum size the nursery may grow to, or 0 to disable generational GC.
JSGC_MIN_NURSERY_BYTES / "minNurseryBytes"Minimum size the nursery may shrink to.
JSGC_BYTES / "gcBytes"Amount of bytes allocated by the GC.
JSGC_NUMBER / "gcNumber"Number of times GC has been invoked. Includes both major and minor GC.
JSGC_MODE / "mode"

Select GC mode:

JSGC_MODE_GLOBAL (0)
The GC runs all objects are visited in a singleslice.
JSGC_MODE_ZONE (1)
The GC runs only the objects that belong to somezones are visited in a singleslice.
JSGC_MODE_INCREMENTAL (2)
The GC runs all objects are visited in multipleslices.
JSGC_MODE_ZONE_INCREMENTAL (3)
The GC runs only the objects that belong to somezones are visited in multipleslices.

This does not affect generational GC, see JSGC_MAX_NURSERY_BYTES

JSGC_UNUSED_CHUNKS / "unusedChunks"Number of cached empty GC chunks.
JSGC_TOTAL_CHUNKS / "totalChunks"Total number of allocated GC chunks.
JSGC_SLICE_TIME_BUDGET / "sliceTimeBudget"Max milliseconds to spend in an incremental GC slice. 0 for infinite.
JSGC_MARK_STACK_LIMIT / "markStackLimit"Maximum size the GC mark stack can grow to (units: entries).
JSGC_HIGH_FREQUENCY_TIME_LIMIT / "highFrequencyTimeLimit"GCs less than this far apart in time will be considered 'high-frequency GCs'.
JSGC_HIGH_FREQUENCY_LOW_LIMIT / "highFrequencyLowLimit"

Controls for dynamic heap growth. When the GC is in "high frequency" mode (see above) then, the heap will be allowed to grow between collections according to these four parameters. See ZoneHeapThreshold::computeZoneHeapGrowthFactorForHeapSize in GC.cpp for the details.

The first two parameters are in MB and the remaining two are in percentage of heap size.

JSGC_HIGH_FREQUENCY_HIGH_LIMIT / "highFrequencyHighLimit"
JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX / "highFrequencyHeapGrowthMax"
JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN / "highFrequencyHeapGrowthMin"
JSGC_LOW_FREQUENCY_HEAP_GROWTH / "lowFrequencyHeapGrowth"Heap growth percentage for low frequency GCs.
JSGC_DYNAMIC_HEAP_GROWTH / "dynamicHeapGrowth"If false, the heap growth percentage is fixed at 300%. If true, it is determined based on whether GCs are high- or low- frequency.
JSGC_DYNAMIC_MARK_SLICE / "dynamicMarkSlice"If true, high-frequency GCs will use a longer mark slice.
JSGC_ALLOCATION_THRESHOLD / "allocationThreshold"Lower limit after which we limit the heap growth. The heap will be collected if it is greater than: MAX(allocThreshold, lastSize) * thresholdFactor, This establishes allocThreshold as a baseline or default heap size.
JSGC_ALLOCATION_THRESHOLD_FACTOR / "allocationThresholdFactor"

These thresholds (as percentages) are compared with the zone threshold (above) to decide when to begin an incremental collection. JSGC_ALLOCATION_THRESHOLD_FACTOR_AVOID_INTERRUPT is used when a GC is already in progress for other zones and we may wish to avoid interrupting it.

Additionally if a zone expands beyond the threshold without this factor, then it will be collected non-incrementally

JSGC_ALLOCATION_THRESHOLD_FACTOR_AVOID_INTERRUPT / "allocationThresholdfactorAvoidInterrupt"
JSGC_MIN_EMPTY_CHUNK_COUNT / "minEmptyChunkCount"We try to keep at least this many unused chunks in the free chunk pool at all times, even after a shrinking GC.
JSGC_MAX_EMPTY_CHUNK_COUNT / "maxEmptyChunkCount"We never keep more than this many unused chunks in the free chunk pool.
JSGC_COMPACTION_ENABLED / "compactingEnabled"non-zero to enable compacting, zero to disable.
JSGC_NURSERY_FREE_THRESHOLD_FOR_IDLE_COLLECTION / "nurseryFreeThresholdForIdleCollection"Collect the nursery in idle time if it has less than this many bytes of free space.
JSGC_NURSERY_FREE_THRESHOLD_FOR_IDLE_COLLECTION_PERCENT / "nurseryFreeThresholdForIdleCollectionPercent"Collect the nursery in idle time if it has less than this percentage of capacity free (value from 0 - 99).
JSGC_PRETENURE_THRESHOLD / "pretenureThreshold"If this percentage of the nursery is tenured and the nursery is at least 4MB, then process object groups to look for pretenuring candidates.
JSGC_PRETENURE_GROUP_THRESHOLD / "pretenureGroupThreshold"If more than this number of objects in a given object group are tenured, then pretenruing will be enabled for new objects in this group.
JSGC_MIN_LAST_DITCH_GC_PERIOD / "minLastDitchGCPeriod"The minimum time to allow between triggering last ditch GCs in seconds.

Description

JS_GetGCParameter returns the current parameter of the garbage collection.

If successful, JS_GetGCParameter returns the current parameter.

JS_SetGCParameter ajusts the parameter of the garbage collection.

See Also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:41 次

字数:13099

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文