luv

Workshop wiki

benchmark.lisp

luvcraft/benchmark.lisp

system luvcraft/core · 7 definitions · on GitHub

Repeatable demand-driven benchmarks of a fully resident luvcraft world.

in-package#:luvcraft
defunbenchmark-metal-device-name
device
#-darwin
declare
ignoredevice
#+darwin (luv.objective-c:objective-c-string (luv.metal:device-name (luv::metal-native-object device)))#-darwin
error"The Metal benchmark is only available on Darwin."
defunrun-luvcraft-benchmark-frame
session&optionalsample
request-canvas-frame
luvcraft-session-canvassession
lambda
timestamp
defunluvcraft-benchmark-streaming-settled-p
session
let
desired
hash-table-count
luvcraft-session-desired-chunkssession
and
=desired
length
resident-world-chunks
luvcraft-session-worldsession
hash-table-count
luvcraft-session-chunk-productssession
zerop
production-system-pending-count
luvcraft-session-production-systemsession
zerop
hash-table-count
luvcraft-session-outstanding-productionsession
zerop
hash-table-count
luvcraft-session-staged-chunk-productssession
defunluvcraft-benchmark-desired-keys
session
loopforkeybeingthehash-keysof
luvcraft-session-desired-chunkssession
collectkey
defunbegin-luvcraft-benchmark-scenario
scenariosession

Begin scenario and return the desired keys immediately before it.

let
casescenario
:steady
:streaming
let*
world
luvcraft-session-worldsession
shape
voxel-space-chunk-shape
block-world-spaceworld
player
luvcraft-session-playersession
incf
player-xplayer
chunk-shape-widthshape
sync-camera-to-player
luvcraft-session-camerasession
player
otherwise
error"Unknown luvcraft benchmark scenario ~S."scenario
before
defuncount-luvcraft-benchmark-entering-chunks
beforesession
count-if
lambda
key
not
memberkeybefore:test#'equal
defunbenchmark-luvcraft-frame-performance
&key
frame-count120
warmup-count30
camera
make-instance'fly-camera
scenario:steady
high-pixel-density-pnil
csv-pathname
stream*standard-output*

Measure steady or streaming world frames through the real Metal path.

The streaming scenario moves one chunk in +X after warmup and records the entire asynchronous load, mesh, and owner-publication transition. #887PO7

The hidden demand-clock canvas avoids the application's 60 Hz scheduler, but CAMetalLayer may still pace drawable availability. All desired chunk products arrive before warmup, then frame-count consecutive frames reuse the same world, pipelines, attachments, and drawable pool. Per-frame values measure CPU orchestration and encoding. Completion throughput includes final shared-event drainage and is intentionally not labelled as GPU time.

check-typeframe-count
integer1
check-typewarmup-count
integer0
check-typewidth
integer1
check-typeheight
integer1
check-typescenario
member:steady:streaming
check-typehigh-pixel-density-pboolean
let
sessionnil
samples
make-arrayframe-count
provider
make-instance'metal-gpu-provider
unwind-protect
progn
setfsession
start-luvcraft:title"luvcraft Metal frame benchmark":widthwidth:heightheight:visible-pnil:frames-per-secondnil

width and height remain the logical scene controls. The Retina benchmark deliberately lets SDL make the drawable denser, then records both extents below so the physical post-pass cost cannot disappear behind the input size.

:high-pixel-density-phigh-pixel-density-p:providerprovider:worldworld:cameracamera:sky-clock
make-instance'sky-clock:pinned-day-fraction0.5
let
desired
hash-table-count
luvcraft-session-desired-chunkssession
wait-for-luvcraft-productssession:minimumdesired:timeout30d0
looprepeatwarmup-countdo
let
queue
device-queue
luvcraft-session-devicesession
let
entering0
settled-framenil
batch-start
get-internal-real-time
dotimes
indexframe-count
let
sample
make-luvcraft-frame-sample
setf
arefsamplesindex
sample
when
and
eqscenario:streaming
zeropindex
when
and
eqscenario:streaming
nullsettled-frame
setfsettled-frameindex
let
drain-start
get-internal-real-time
let*
finished
get-internal-real-time
units
coerceinternal-time-units-per-second'double-float
trace
make-cpu-trace:label"representative frame"
render-extent
presentation-extent
benchmark
make-luvcraft-frame-benchmark:backend:metal:scenarioscenario:device
benchmark-metal-device-name
luvcraft-session-devicesession
:width
firstrender-extent
:height
secondrender-extent
:presentation-width
firstpresentation-extent
:presentation-height
secondpresentation-extent
:warmup-countwarmup-count:samplessamples:completion-seconds
/
-finishedbatch-start
units
:drain-seconds
/
-finisheddrain-start
units
:desired-chunk-countdesired:entering-chunk-countentering:settled-framesettled-frame

Warm the reusable zone buffer, then capture one extra frame after the measured batch so detailed zones and their first-use allocation cannot perturb its metrics.

formatstream"~%"
print-cpu-tracetracestream
whencsv-pathname
formatstream" samples: ~A~%"
namestring
truenamecsv-pathname
benchmark
whensession