perf: harden runtime for weaker hardware

This commit is contained in:
Rijad Zuzo
2026-08-12 10:02:45 +02:00
parent cd29da95e0
commit 34428d836a
47 changed files with 2164 additions and 243 deletions
+11 -1
View File
@@ -74,6 +74,7 @@ func _run() -> void:
var report := {
"schema_version": SimulationScalingBenchmark.SCHEMA_VERSION,
"simulation_state_schema_version": SimulationStateRecord.SCHEMA_VERSION,
"captured_utc": Time.get_datetime_string_from_system(true) + "Z",
"engine_version": String(Engine.get_version_info().get("string", "unknown")),
"platform": OS.get_name(),
@@ -83,7 +84,8 @@ func _run() -> void:
"workload_id": String(SimulationScalingBenchmark.WORKLOAD_ID),
"workload":
(
"All NPCs receive full per-tick needs/task updates and ordinary action decisions; "
"All NPCs receive full per-tick needs/task updates, ordinary action decisions, "
+ "and one matching authoritative combatant record; "
+ "travel resolves through the deterministic immediate-arrival headless convention."
),
"timed_phases": ["simulation_tick", "headless_arrival_completion"],
@@ -130,10 +132,18 @@ func _summarize_samples(case_id: String, samples: Array[Dictionary]) -> Dictiona
"arrivals_processed",
"warmup_arrivals",
"npc_updates",
"npc_combatant_count",
"npc_combatant_coverage_valid",
"start_tick",
"end_tick",
]
for sample in samples:
if (
not bool(sample.get("npc_combatant_coverage_valid", false))
or int(sample.get("npc_combatant_count", -1)) != int(sample.get("population", -2))
):
push_error("Scaling benchmark case %s lost NPC combatant coverage" % case_id)
return {}
if String(sample["final_checksum"]) != checksum:
push_error("Scaling benchmark case %s diverged across checksums" % case_id)
return {}
+58
View File
@@ -25,6 +25,9 @@ $CROSS_PLATFORM_PLUGIN_FILES = @(
"addons/terrain_3d/bin/libterrain.windows.release.x86_64.dll"
)
$REQUIRED_GODOT_SERIES = "4.7"
$RUNNING_ON_MACOS = [Runtime.InteropServices.RuntimeInformation]::IsOSPlatform(
[Runtime.InteropServices.OSPlatform]::OSX
)
function Exit-Quality {
param([int]$ExitCode)
@@ -182,6 +185,31 @@ function To-ResPath($p) {
return "res://$p"
}
function Test-AllowedScenarioDiagnostic {
param([string]$Diagnostic)
# Godot 4.7 can fail to read the system certificate store on macOS when HOME
# is intentionally isolated. Scenario tests do not perform network access.
if ($script:RUNNING_ON_MACOS -and
$Diagnostic -ceq 'ERROR: Condition "ret != noErr" is true. Returning: ""') {
return $true
}
# Pinned Terrain3D 1.0.2 invokes this Godot 4.7 compatibility method while
# loading its vendored GDExtension. Remove this exception with that vendor fix.
if ($Diagnostic -ceq 'WARNING: instance_reset_physics_interpolation() is deprecated.') {
return $true
}
# Godot 4.7's dummy headless renderer retains exactly one DummyShader RID at
# process teardown. A different RID type or count remains a gate failure.
if ($Diagnostic -ceq "ERROR: 1 RID allocations of type 'N13RendererDummy15MaterialStorage11DummyShaderE' were leaked at exit.") {
return $true
}
return $false
}
function Invoke-GodotWithTimeout {
param(
[string]$ArgumentString,
@@ -437,6 +465,36 @@ foreach ($test in $scenarioTests) {
$ERRORS += "scenario: $($test.Name) failed or timed out"
}
}
$compatibilityTest = "jajce_presentation_quality_test.gd"
$compatibilityLabel = "$compatibilityTest (gl_compatibility)"
Add-Content -Path "$LOG/scenarios.log" -Value "[RUN] $compatibilityLabel" -Encoding utf8
$compatibilityArgs = "--headless --rendering-method gl_compatibility --path `"$ROOT`" --script res://tests/$compatibilityTest"
$compatibilityOutput, $compatibilityExit = Invoke-GodotWithTimeout -ArgumentString $compatibilityArgs
$compatibilityOutput | Add-Content -Path "$LOG/scenarios.log" -Encoding utf8
if ($compatibilityExit -eq $null -or $compatibilityExit -ne 0) {
$scenarioResult = "FAIL"
$ERRORS += "scenario: $compatibilityLabel failed or timed out"
}
$unexpectedScenarioDiagnostics = @()
$currentScenario = "unknown scenario"
foreach ($rawLine in Get-Content -Path "$LOG/scenarios.log") {
if ($rawLine.StartsWith('[RUN] ')) {
$currentScenario = $rawLine.Substring(6)
continue
}
$diagnostic = $rawLine.Trim()
if ($diagnostic -cnotmatch '^(?:(?:SCRIPT )?ERROR|WARNING):') { continue }
if (-not (Test-AllowedScenarioDiagnostic $diagnostic)) {
$unexpectedScenarioDiagnostics += "$currentScenario`: $diagnostic"
}
}
if ($unexpectedScenarioDiagnostics.Count -gt 0) {
$scenarioResult = "FAIL"
$ERRORS += "scenario: Godot reported $($unexpectedScenarioDiagnostics.Count) unallowlisted ERROR/WARNING diagnostic(s)"
foreach ($diagnostic in $unexpectedScenarioDiagnostics | Select-Object -First 20) {
$ERRORS += "scenario: $diagnostic"
}
}
$scenarioLoadError = Select-String -Path "$LOG/scenarios.log" -Pattern 'SCRIPT ERROR:|Parse Error:|Failed to load script' -Quiet
if ($scenarioLoadError) {
$scenarioResult = "FAIL"
+61
View File
@@ -26,6 +26,8 @@ CROSS_PLATFORM_PLUGIN_FILES=(
addons/terrain_3d/bin/libterrain.windows.release.x86_64.dll
)
REQUIRED_GODOT_SERIES="4.7"
RUNNING_ON_MACOS=false
[[ "${OSTYPE:-}" == darwin* ]] && RUNNING_ON_MACOS=true
# -- tool detection -----------------------------------------------------------
console_godot_path() {
@@ -143,6 +145,31 @@ contains_element() {
local e; for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done; return 1
}
is_allowed_scenario_diagnostic() {
local diagnostic="$1"
# Godot 4.7 can fail to read the system certificate store on macOS when HOME
# is intentionally isolated. Scenario tests do not perform network access.
if $RUNNING_ON_MACOS &&
[[ "$diagnostic" == 'ERROR: Condition "ret != noErr" is true. Returning: ""' ]]; then
return 0
fi
# Pinned Terrain3D 1.0.2 invokes this Godot 4.7 compatibility method while
# loading its vendored GDExtension. Remove this exception with that vendor fix.
if [[ "$diagnostic" == "WARNING: instance_reset_physics_interpolation() is deprecated." ]]; then
return 0
fi
# Godot 4.7's dummy headless renderer retains exactly one DummyShader RID at
# process teardown. A different RID type or count remains a gate failure.
if [[ "$diagnostic" == "ERROR: 1 RID allocations of type 'N13RendererDummy15MaterialStorage11DummyShaderE' were leaked at exit." ]]; then
return 0
fi
return 1
}
run_with_timeout() {
local seconds="$1"
shift
@@ -380,6 +407,40 @@ for test in tests/*_test.gd; do
ERRORS+=("scenario: $(basename "$test") failed or timed out")
fi
done
compatibility_test="tests/jajce_presentation_quality_test.gd"
compatibility_label="$(basename "$compatibility_test") (gl_compatibility)"
echo "[RUN] $compatibility_label" >> "$LOG/scenarios.log"
if ! run_with_timeout 30 "${GODOT_ENV[@]}" "$GODOT" --headless --rendering-method gl_compatibility --path "$ROOT" --script "res://$compatibility_test" >> "$LOG/scenarios.log" 2>&1; then
scenario_result="FAIL"
ERRORS+=("scenario: $compatibility_label failed or timed out")
fi
unexpected_scenario_diagnostics=()
current_scenario="unknown scenario"
while IFS= read -r raw_line; do
raw_line="${raw_line%$'\r'}"
if [[ "$raw_line" == "[RUN] "* ]]; then
current_scenario="${raw_line#* }"
continue
fi
diagnostic="$raw_line"
diagnostic="${diagnostic#"${diagnostic%%[![:space:]]*}"}"
diagnostic="${diagnostic%"${diagnostic##*[![:space:]]}"}"
if [[ ! "$diagnostic" =~ ^((SCRIPT[[:space:]])?ERROR|WARNING): ]]; then
continue
fi
if ! is_allowed_scenario_diagnostic "$diagnostic"; then
unexpected_scenario_diagnostics+=("$current_scenario: $diagnostic")
fi
done < "$LOG/scenarios.log"
if [[ ${#unexpected_scenario_diagnostics[@]} -gt 0 ]]; then
scenario_result="FAIL"
ERRORS+=(
"scenario: Godot reported ${#unexpected_scenario_diagnostics[@]} unallowlisted ERROR/WARNING diagnostic(s)"
)
for diagnostic in "${unexpected_scenario_diagnostics[@]:0:20}"; do
ERRORS+=("scenario: $diagnostic")
done
fi
if grep -qE "SCRIPT ERROR:|Parse Error:|Failed to load script" "$LOG/scenarios.log"; then
scenario_result="FAIL"
ERRORS+=("scenario: Godot reported a script load or parse error")