upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src
diff options
context:
space:
mode:
authorOreoFR <29048345+OreoFR@users.noreply.github.com>2026-11-27 02:20:24 +0100
committerOreoFR <29048345+OreoFR@users.noreply.github.com>2026-11-27 02:20:24 +0100
commite5d1a14681fa65de2d8b49b2efeeec62370ec8ee (patch)
tree79632e11839f4a0f0e18969d49be5a57fa958f8b /runtime/src
parentf7b2497303466eb3bcebe7fe88cde838b1f45334 (diff)
compile gate: a held probe needs the create beside it to have just left
A submission that stays 2 s or more in the driver turned its create kind's gate on (or back on). It now counts only if it came back within 500 ms after a create of that kind, there when it entered, left the driver: a submission held behind a create comes back when the create does. On the 4070 Laptop (621.40, 8 GB nearly full) a 36 s submission came back 18 s before the compute create beside it; counted as held, it re-armed the gate, which then kept the next submission 78 s behind compute creates. One that is slow with its creates still there is logged (the first 8) and judged nothing. Tests: the held-probe tests release the create 100 ms before the submission comes back; a new one checks that a slow submission with the create still there gives no held verdict. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/src')
-rw-r--r--runtime/src/vulkan_device_fault.h35
1 files changed, 32 insertions, 3 deletions
diff --git a/runtime/src/vulkan_device_fault.h b/runtime/src/vulkan_device_fault.h
index 26e02bbb0..0641c49f3 100644
--- a/runtime/src/vulkan_device_fault.h
+++ b/runtime/src/vulkan_device_fault.h
@@ -445,7 +445,11 @@ public:
445 // every kind whose gate is not off; the probe budget applies only while all of those are of kinds still pending. 445 // every kind whose gate is not off; the probe budget applies only while all of those are of kinds still pending.
446 // A kind that is off is still timed: a submission that stays kProbeHeldMs or more beside one of its creates turns 446 // A kind that is off is still timed: a submission that stays kProbeHeldMs or more beside one of its creates turns
447 // that kind's gate back on for the rest of the run (logged once), so the submissions after it wait. The one that 447 // that kind's gate back on for the rest of the run (logged once), so the submissions after it wait. The one that
448 // stayed cannot be helped. A submission never goes ahead (at the limit or the budget) while a create of a kind 448 // stayed cannot be helped. A held probe counts only if the submission came back within kHeldReturnMs after a
449 // create of that kind, there when it entered, left the driver: a submission held behind a create comes back when
450 // the create does. One that comes back slow with its creates still there was slow for another reason (on 621.40,
451 // a 36 s submission came back 18 s before the compute create beside it, and the 4070 Laptop's 8 GB were full);
452 // counting it re-armed the gate and starved the title for 78 s behind creates that were not holding anything. A submission never goes ahead (at the limit or the budget) while a create of a kind
449 // that holds submissions is in the driver, and such creates are waited for even if one was gone past before the 453 // that holds submissions is in the driver, and such creates are waited for even if one was gone past before the
450 // verdict: on 621.40, with the gate off, a vkQueueSubmit sat 54 s in the driver beside a 56 s mesh create and the 454 // verdict: on 621.40, with the gate off, a vkQueueSubmit sat 54 s in the driver beside a 56 s mesh create and the
451 // device was lost; waiting here starves the title as long, but keeps the device. Graphics creates pass the gate 455 // device was lost; waiting here starves the title as long, but keeps the device. Graphics creates pass the gate
@@ -455,6 +459,7 @@ public:
455 enum class GateVerdict { pending, driver_does_not_hold, driver_holds }; 459 enum class GateVerdict { pending, driver_does_not_hold, driver_holds };
456 static constexpr std::int64_t kProbeQuickMs = 250; 460 static constexpr std::int64_t kProbeQuickMs = 250;
457 static constexpr std::int64_t kProbeHeldMs = 2000; 461 static constexpr std::int64_t kProbeHeldMs = 2000;
462 static constexpr std::int64_t kHeldReturnMs = 500;
458 static constexpr std::int64_t kProbeSpanMs = 1000; 463 static constexpr std::int64_t kProbeSpanMs = 1000;
459 static constexpr unsigned kQuickProbes = 2; 464 static constexpr unsigned kQuickProbes = 2;
460 static constexpr std::int64_t kProbeWindowMs = 10000; 465 static constexpr std::int64_t kProbeWindowMs = 10000;
@@ -626,6 +631,9 @@ public:
626 std::lock_guard lock(gate_mutex_); 631 std::lock_guard lock(gate_mutex_);
627 for (auto it = in_driver_.begin(); it != in_driver_.end(); ++it) 632 for (auto it = in_driver_.begin(); it != in_driver_.end(); ++it)
628 if (it->seq == seq) { 633 if (it->seq == seq) {
634 const std::size_t k = std::size_t(it->info.kind);
635 last_leave_ms_[k] = diagnostic_ms();
636 last_leave_seq_[k] = seq;
629 in_driver_.erase(it); 637 in_driver_.erase(it);
630 break; 638 break;
631 } 639 }
@@ -848,8 +856,25 @@ private:
848 diagnostic_thread_id(), static_cast<long long>(took), still, ahead.creates); 856 diagnostic_thread_id(), static_cast<long long>(took), still, ahead.creates);
849 } 857 }
850 if (!adaptive_) return; 858 if (!adaptive_) return;
851 for (std::size_t k = 0; k < kKinds; ++k) 859 for (std::size_t k = 0; k < kKinds; ++k) {
852 if (kinds & (1u << k)) judge(CreateKind(k), took, now); 860 if (!(ahead.kinds & (1u << k))) continue;
861 if (took >= kProbeHeldMs) {
862 // Held behind a create of this kind only if one it entered beside has just left.
863 const bool left_just_before = last_leave_seq_[k] != 0 && last_leave_seq_[k] <= ahead.last_create &&
864 last_leave_ms_[k] >= ahead.since_ms &&
865 now - last_leave_ms_[k] <= kHeldReturnMs;
866 if (left_just_before) {
867 judge(CreateKind(k), took, now);
868 } else if (logged_not_held_++ < 8) {
869 std::fprintf(stderr, "[rt] compile-gate: a submission stayed %lld ms in the driver beside a %s "
870 "create but came back %s: not counted as held by it\n",
871 static_cast<long long>(took), kind_name(CreateKind(k)),
872 (kinds & (1u << k)) ? "with the create still there" : "long after the create left");
873 }
874 } else if (kinds & (1u << k)) {
875 judge(CreateKind(k), took, now);
876 }
877 }
853 } 878 }
854 void judge(CreateKind kind, std::int64_t took, std::int64_t now) { 879 void judge(CreateKind kind, std::int64_t took, std::int64_t now) {
855 const std::size_t k = std::size_t(kind); 880 const std::size_t k = std::size_t(kind);
@@ -939,6 +964,10 @@ private:
939 // Per CreateKind. 964 // Per CreateKind.
940 std::array<GateVerdict, kKinds> verdict_{GateVerdict::pending, GateVerdict::pending}; 965 std::array<GateVerdict, kKinds> verdict_{GateVerdict::pending, GateVerdict::pending};
941 std::array<bool, kKinds> rearmed_{}; 966 std::array<bool, kKinds> rearmed_{};
967 // When the last create of each kind left the driver, and its number: a held probe needs one to have just left.
968 std::array<std::int64_t, kKinds> last_leave_ms_{};
969 std::array<std::uint64_t, kKinds> last_leave_seq_{};
970 unsigned logged_not_held_ = 0;
942 std::array<unsigned, kKinds> quick_probes_{}; 971 std::array<unsigned, kKinds> quick_probes_{};
943 std::array<std::int64_t, kKinds> first_quick_ms_{}, longest_quick_ms_{}; 972 std::array<std::int64_t, kKinds> first_quick_ms_{}, longest_quick_ms_{};
944 unsigned logged_held_waits_ = 0; 973 unsigned logged_held_waits_ = 0;