Commit b43e95a
feat(cache): trigger eviction by disk free space on the write path (alibaba#1548)
FileCachePool::updateSpace() previously only forced recycling when the
logical watermark was hit (totalUsed_ >= riskMark_). Since totalUsed_
only accounts for this cache's own writes, a shared medium filling up
from other writers — or a deployment that wants capacity governed by
disk free space rather than the logical watermark — was invisible to the
write path and only handled on the next periodic eviction tick.
Add a throttled real statvfs probe to the write path. It reuses the
existing eviction() disk logic and is throttled by both time
(kDiskCheckIntervalUs, via the syscall-free photon::now) and bytes
written (diskCheckStepBytes_ = max(diskAvailInBytes_/8, refillUnit_)),
keeping statvfs off the hot path on fast media such as tmpfs while
bounding overshoot of the diskAvailInBytes_ floor. The probe is skipped
entirely when diskAvailInBytes_ == 0, and a failed statvfs never forces
eviction.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent a80e71b commit b43e95a
2 files changed
Lines changed: 42 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
59 | 63 | | |
60 | 64 | | |
61 | 65 | | |
| |||
234 | 238 | | |
235 | 239 | | |
236 | 240 | | |
237 | | - | |
| 241 | + | |
238 | 242 | | |
239 | | - | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
240 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
241 | 262 | | |
242 | 263 | | |
243 | 264 | | |
| |||
246 | 267 | | |
247 | 268 | | |
248 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
249 | 280 | | |
250 | 281 | | |
251 | 282 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
138 | 142 | | |
139 | 143 | | |
140 | 144 | | |
| |||
144 | 148 | | |
145 | 149 | | |
146 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
147 | 156 | | |
148 | 157 | | |
149 | 158 | | |
| |||
0 commit comments