diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-12-07 15:45:11 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-12-07 15:45:11 -0300 |
| commit | 925fe8a0f2a667c96c015ee74d1a702af9ea5507 (patch) | |
| tree | bca1cb92e11218498f4c76f651f4a5fa1a8c87b5 /lgc.h | |
| parent | 789e7acdea3ada96bd00b7aac6d82e805bfee85c (diff) | |
| download | lua-925fe8a0f2a667c96c015ee74d1a702af9ea5507.tar.gz lua-925fe8a0f2a667c96c015ee74d1a702af9ea5507.tar.bz2 lua-925fe8a0f2a667c96c015ee74d1a702af9ea5507.zip | |
First criteria for shifts minor<->major
Diffstat (limited to 'lgc.h')
| -rw-r--r-- | lgc.h | 48 |
1 files changed, 26 insertions, 22 deletions
| @@ -161,10 +161,24 @@ | |||
| 161 | 161 | ||
| 162 | /* Default Values for GC parameters */ | 162 | /* Default Values for GC parameters */ |
| 163 | 163 | ||
| 164 | /* generational */ | 164 | /* |
| 165 | ** Minor collections will shift to major ones after LUAI_MINORMAJOR% | ||
| 166 | ** objects become old. | ||
| 167 | */ | ||
| 168 | #define LUAI_MINORMAJOR 100 | ||
| 169 | |||
| 170 | /* | ||
| 171 | ** Major collections will shift to minor ones after a collection | ||
| 172 | ** collects at least LUAI_MAJORMINOR% of the new objects. | ||
| 173 | */ | ||
| 174 | #define LUAI_MAJORMINOR 80 | ||
| 175 | |||
| 176 | /* | ||
| 177 | ** A young (minor) collection will run after creating LUAI_GENMINORMUL% | ||
| 178 | ** new objects. | ||
| 179 | */ | ||
| 180 | #define LUAI_GENMINORMUL 20 | ||
| 165 | 181 | ||
| 166 | #define LUAI_GENMAJORMUL 100 /* major multiplier */ | ||
| 167 | #define LUAI_GENMINORMUL 20 /* minor multiplier */ | ||
| 168 | 182 | ||
| 169 | /* incremental */ | 183 | /* incremental */ |
| 170 | 184 | ||
| @@ -187,27 +201,17 @@ | |||
| 187 | 201 | ||
| 188 | /* | 202 | /* |
| 189 | ** Macros to set and apply GC parameters. GC parameters are given in | 203 | ** Macros to set and apply GC parameters. GC parameters are given in |
| 190 | ** percentage points, but are stored as lu_byte. To reduce their | 204 | ** percentage points, but are stored as lu_byte. To avoid repeated |
| 191 | ** values and avoid repeated divisions by 100, these macros store | 205 | ** divisions by 100, these macros store the original parameter |
| 192 | ** the original parameter multiplied by 2^n and divided by 100. | 206 | ** multiplied by 128 and divided by 100. To apply them, if it first |
| 193 | ** To apply them, the value is divided by 2^n (a shift) and then | 207 | ** divides the value by 128 it may lose precision; if it first |
| 194 | ** multiplied by the stored parameter, yielding | 208 | ** multiplies by the parameter, it may overflow. So, it first divides |
| 195 | ** value / 2^n * (original parameter * 2^n / 100), or approximately | 209 | ** by 32, then multiply by the parameter, and then divides the result by |
| 196 | ** (value * original parameter / 100). | 210 | ** 4. |
| 197 | ** | ||
| 198 | ** For most parameters, which are typically larger than 100%, 2^n is | ||
| 199 | ** 16 (2^4), allowing maximum values up to ~1500%, with a granularity | ||
| 200 | ** of ~6%. For the minor multiplier, which is typically smaller, | ||
| 201 | ** 2^n is 64 (2^6) to allow more precision. In that case, the maximum | ||
| 202 | ** value is ~400%, with a granularity of ~1.5%. | ||
| 203 | */ | 211 | */ |
| 204 | #define gcparamshift(p) \ | ||
| 205 | (offsetof(global_State, p) == offsetof(global_State, genminormul) ? 6 : 4) | ||
| 206 | |||
| 207 | #define setgcparam(g,p,v) \ | ||
| 208 | (g->p = (cast_uint(v) << gcparamshift(p)) / 100u) | ||
| 209 | #define applygcparam(g,p,v) (((v) >> gcparamshift(p)) * g->p) | ||
| 210 | 212 | ||
| 213 | #define setgcparam(g,p,v) (g->gcp##p = (cast_uint(v) << 7) / 100u) | ||
| 214 | #define applygcparam(g,p,v) ((((v) >> 5) * g->gcp##p) >> 2) | ||
| 211 | 215 | ||
| 212 | 216 | ||
| 213 | /* | 217 | /* |
