Skip to content
Merged
Changes from 2 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
61 changes: 61 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,64 @@ 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 both GC pauses and how much allocations have to wait into consideration. Usually the former dominates so you can use the "% pause time in GC" to approximate this cost. There are 2 transient cases where the latter dominates -

- 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, eg, when peak hours start, since it takes a few GCs before the number of heaps gets increased, allocating threads may experience waits during that period of time.

DATAS uses 2% as the default TCP which can be adjusted with this setting. It's an integer that is interpreted as a percentage, eg, 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. We use this formula to calculate a multiplier -

`f (application_size_in_MB) = (20 - conserve_memory) / sqrt (application_size_in_MB)`

which 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. And the maximum and minimum value are default to 10 and 0.1.

For example, if the application size is 1 GB, the formula gives us `(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 give us 15 which would then be adjusted to 10, meaning the total gen0 budget allowed is 10 MB.

3 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, it means the multiplier will become `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, it means the minimum clamping value is `200 * 0.001 = 0.2`.