mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 10:53:44 +00:00
feat(ugc): a model's time keeps its icon's when the icon is drawn again
A make's recorded time (process_ms, stats.json's ms.total) includes the icon drawn at its end. Drawing only the icons again (the icon editor's Draw all icons of this type again) left the stats and the rows with the old icons' time. Now the icon-only job writes stats.json with the new icon's time (ms.icon, ms.total changed by the difference, UgcJobs::WithIconTime) and the main thread changes the row's process_ms and process_cpu_ms by the same difference (the icon is drawn on one thread, so its time is taken as its CPU time). The dashboard's Took, CPU and totals follow. Check: open a player model on the UGC page, Draw all icons of this type again: afterwards its Took changes by the icon's difference and its stats show the new icon time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -289,8 +289,13 @@ void UgcProcessor::Worker() {
|
||||
const auto nif = m_Storage.ReadNif(Kind::MODEL, job.id, "model.nif");
|
||||
auto options = settings.icon;
|
||||
UgcIconParams::Apply(options, job.iconValues);
|
||||
const auto iconStart = std::chrono::steady_clock::now();
|
||||
done.outcome.ok = nif && UgcJobs::IconFromNif(*nif, options, done.outcome.files, done.outcome.error, settings.shaders.TagLooks(), settings.shaders.OverlayTags());
|
||||
if (!nif) done.outcome.error = "no stored .nif";
|
||||
// The make's time keeps its icon's: the stats get the new icon's time, the row the difference (Collect)
|
||||
const auto stats = done.outcome.ok ? m_Storage.ReadNif(Kind::MODEL, job.id, "stats.json") : std::nullopt;
|
||||
const double iconMs = std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - iconStart).count();
|
||||
if (const auto updated = stats ? UgcJobs::WithIconTime(*stats, iconMs, done.iconChangeMs) : std::nullopt) done.outcome.files["stats.json"] = *updated;
|
||||
} else {
|
||||
done.outcome = job.kind == Kind::MODEL
|
||||
? UgcJobs::ProcessModel(job.blob, m_Library, settings, static_cast<uint64_t>(job.id), job.iconValues)
|
||||
@@ -442,6 +447,15 @@ void UgcProcessor::Poll() {
|
||||
m_Wake.notify_all();
|
||||
}
|
||||
|
||||
void UgcProcessor::RecordIconTime(LWOOBJID id, double changeMs) {
|
||||
for (const auto& entry : Database::Get()->GetUgcEntries({ id })) {
|
||||
if (entry.kind != IUgcLookup::eUgcKind::MODEL || entry.processMs == 0) continue;
|
||||
// The icon is drawn on one thread, so its time is its CPU time too
|
||||
const auto change = [changeMs](uint32_t value) { return static_cast<uint32_t>(std::max(0.0, static_cast<double>(value) + changeMs)); };
|
||||
Database::Get()->SetUgcModelProcessStats(id, { change(entry.processMs), change(entry.processCpuMs), entry.processMemoryKb });
|
||||
}
|
||||
}
|
||||
|
||||
void UgcProcessor::Record(const Done& done) {
|
||||
// What the make cost (wall time, the worker's CPU time, the estimated memory), for the dashboard
|
||||
const IUgc::ProcessStats cost{ static_cast<uint32_t>(done.milliseconds), static_cast<uint32_t>(done.cpuMilliseconds), static_cast<uint32_t>(done.memoryEstimate / 1024) };
|
||||
@@ -495,6 +509,7 @@ void UgcProcessor::Collect() {
|
||||
Record(done);
|
||||
continue;
|
||||
}
|
||||
if (done.outcome.ok && done.iconChangeMs != 0.0) RecordIconTime(done.id, done.iconChangeMs);
|
||||
m_Log.push_back({ Kind::MODEL, done.id, done.outcome.ok, done.milliseconds, done.outcome.ok ? "icon drawn again" : done.outcome.error, UnixNow() });
|
||||
while (m_Log.size() > LOG_LENGTH) m_Log.pop_front();
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user