mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-28 15:53:00 +00:00
ifcviewer: move the live budget only on sustained device readings
A 66-model session oscillated with a ~4 s period — 298 releases in one log: the pool grew to its ceiling, the next report read ~83 MB free, the budget dropped and the pool shrank, the reading rebounded, the budget rose and the pool re-grew, reloading the same chunks each time. Objects flickered on and off continuously. The report includes transients the viewer itself creates: the upload staging behind a burst of chunk loads (~170 MB in that session) and a released sub-buffer the driver has not yet reclaimed. A budget that followed every reading fed those straight back into growth decisions. GpuBudget::update now bounds the cache outright on the first device report and afterwards moves only on sustained readings: lower when free memory is below half the margin on two consecutive scheduled reports, raise when it is above 1.5× the margin on two, and nothing in between. Transients drain well within a poll interval, so a momentary low never reaches the pool, while a process that really took memory still does a second later. A refused allocation (onPressure) is never deferred. Verified in the saturated regime (working set ~990 MB against a 683 MB budget, continuous streaming): zero releases over 75 s. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -37,7 +37,24 @@ void GpuBudget::update(std::uint64_t device_free_bytes,
|
||||
if (device_free_bytes == 0) return;
|
||||
const std::uint64_t available = cache_capacity_bytes + device_free_bytes;
|
||||
const std::uint64_t margin = margin_bytes();
|
||||
bound(available > margin ? available - margin : 0);
|
||||
const std::uint64_t reading = available > margin ? available - margin : 0;
|
||||
if (!had_device_report_) {
|
||||
had_device_report_ = true;
|
||||
bound(reading);
|
||||
return;
|
||||
}
|
||||
|
||||
const bool tight = device_free_bytes < margin / 2;
|
||||
const bool roomy = device_free_bytes > margin + margin / 2 && reading > budget_;
|
||||
low_reports_ = tight ? low_reports_ + 1 : 0;
|
||||
high_reports_ = roomy ? high_reports_ + 1 : 0;
|
||||
if (low_reports_ >= kConfirmReports) {
|
||||
bound(std::min(budget_, reading));
|
||||
low_reports_ = 0;
|
||||
} else if (high_reports_ >= kConfirmReports) {
|
||||
bound(reading);
|
||||
high_reports_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool GpuBudget::onPressure(std::uint64_t cache_capacity_bytes,
|
||||
@@ -64,5 +81,6 @@ bool GpuBudget::onPressure(std::uint64_t cache_capacity_bytes,
|
||||
const std::uint64_t lowered = std::max(target, kMinCacheBudgetBytes);
|
||||
if (bounded_ && lowered >= budget_) return false;
|
||||
bound(lowered);
|
||||
low_reports_ = high_reports_ = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user