Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions docs/core/runtime-config/garbage-collector.md
Original file line number Diff line number Diff line change
Expand Up @@ -824,3 +824,67 @@ For more information about the first 3 settings, see the [Middle ground between
| **runtimeconfig.json** | `System.GC.DynamicAdaptationMode` | `1` - enabled<br/> `0` - disabled | .NET 8 |

[!INCLUDE [runtimehostconfigurationoption](includes/runtimehostconfigurationoption.md)]

#### Target TCP

DATAS uses the Throughput Cost Percentage (TCP) as the memory cost measurement on throughput. It takes into consideration both GC pauses and how much allocations have to wait. Usually, GC pauses dominates, so you can use the "% pause time in GC" to approximate this cost. There are two transient cases where the allocation wait time can dominate:

- When a process starts, DATAS always starts with one heap. So if there are enough threads allocating, they experience waits.
- When the workload changes from lighter to heavier, for example, when peak hours start, allocating threads might experience waits during that period of time. That's because it takes a few GCs before the number of heaps gets increased.

DATAS uses 2% as the default TCP, which you can adjust with this setting. It's an integer that is interpreted as a percentage, for example, 5 means the target TCP will be 5%.

| | Setting name | Values | Version introduced |
|--------------------------|----------------------------|-----------|--------------------|
| **runtimeconfig.json** | `System.GC.DTargetTCP` | *decimal value* | .NET 9 |
| **Environment variable** | `DOTNET_GCDTargetTCP` | *hexadecimal value* | .NET 9 |

[!INCLUDE [runtimehostconfigurationoption](includes/runtimehostconfigurationoption.md)]

#### Gen0 max budget settings

Adjusting the gen0 budget is one of the key elements DATAS uses to adapt to application sizes. DATAS defines an upper threshold called the BCD (Budget Computed via DATAS) for the total gen0 budget as a function of the application size. The formula to calculate a multiplier is as follows:

$$
f(\text{application\_size\_in\_MB}) = \frac{20 - \text{conserve\_memory}}{\sqrt{\text{application\_size\_in\_MB}}}
$$

The formula is then clamped by a maximum and minimum value before it's applied to the application size in MB. If the [conserve memory](#conserve-memory) setting isn't specified, DATAS uses 5 by default. The maximum and minimum value default to 10 and 0.1, respectively.

For example, if the application size is 1 GB, the formula calculates `(20 - 5) / sqrt (1000) = 0.474`. Since it's between 10 and 0.1, clamping has no effect. This means the total gen0 budget is 47.4% of 1 GB which is 474 MB. If the application size is 1 MB, the formula would calculate 15 which would then be adjusted to 10, meaning the total gen0 budget allowed is 10 MB.

Three settings are provided to adjust what the formula calculates and modify the clamping values:

- The percent that will be applied to what `f` calculates.

| | Setting name | Values | Version introduced |
|--------------------------|----------------------------|-----------|--------------------|
| **runtimeconfig.json** | `System.GC.DGen0GrowthPercent` | *decimal value* | .NET 10 |
| **Environment variable** | `DOTNET_GCDGen0GrowthPercent` | *hexadecimal value* | .NET 10 |

[!INCLUDE [runtimehostconfigurationoption](includes/runtimehostconfigurationoption.md)]

So if `f` calculates 0.474 and this setting is 200, the multiplier becomes `0.474 * 200% = 0.948` before the clamping is applied.

- The maximum clamping value in permil.

| | Setting name | Values | Version introduced |
|--------------------------|----------------------------|-----------|--------------------|
| **runtimeconfig.json** | `System.GC.DGen0GrowthMaxFactor` | *decimal value* | .NET 10 |
| **Environment variable** | `DOTNET_GCDGen0GrowthMaxFactor` | *hexadecimal value* | .NET 10 |

[!INCLUDE [runtimehostconfigurationoption](includes/runtimehostconfigurationoption.md)]

If this value is 20000, it means the maximum clamping value is `20000 * 0.001 = 20`.

- The minimum clamping value in permil.

| | Setting name | Values | Version introduced |
|--------------------------|----------------------------|-----------|--------------------|
| **runtimeconfig.json** | `System.GC.DGen0GrowthMinFactor` | *decimal value* | .NET 10 |
| **Environment variable** | `DOTNET_GCDGen0GrowthMinFactor` | *hexadecimal value* | .NET 10 |

[!INCLUDE [runtimehostconfigurationoption](includes/runtimehostconfigurationoption.md)]

If this value is 200, the minimum clamping value is `200 * 0.001 = 0.2`.