Repository navigation
vk: per-step present timers in MALI_FRAME_PROF - #387
Draft
pablogonz12 wants to merge 2 commits into
Draft
pablogonz12 wants to merge 2 commits into
pablogonz12 wants to merge 2 commits into
Conversation
MALI_FRAME_PROF's present_ms is the interval between two present submits (mali_fprof.c:201-212), i.e. 1/fps at a steady frame rate: it says when presents happened, never how long one took. The CMF reading 'present_ms ~41 at 26 fps' is therefore the frame, not a 41 ms present call. Add the times inside the call, one clock read each, only when the env var is set: acquire (mali_wsi.c:1248), the submit-fence wait (:1050), the device->CPU sync of the image (:1021), the full-frame memcpy into the shm segment (:1185), the X request + flush (:1190), and the whole vkQueuePresentKHR body (:1712-1724: the wrapper times the body, which keeps its early returns). Frame lines get 'wsi_us=acquire/wait/sync/copy/put/call', the summary gets wsi_avg_us. The steps are named in M/notes/present-cost.md with their expected cost; the copy of an 8.3 MB 1080p frame from a write-combined mapping (10-40 ms) is the only one that can be the frame by itself.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
|
Owner
Author
|
A detail from the earlier run's own log that sharpens the question (added to
Frames are kicked every 2.29 ms and presented every 41 ms: the app queues ~18 frames per present and the GPU retires each in ~1.7 ms. So the present is the pacing element, and the new
Either way |
Store successful acquire samples with their swapchain images, then consume each sample when that image is presented. Cover out-of-order images, consecutive presents and the reported acquire average with a synthetic host test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft: the numbers come from the CMF run this PR enables. Host-only proof so far (it compiles, the line is printed,
check.shis green apart from a load-bound timing row).Why
The CMF measurement (
9 961 frames, submit_us 81, present_ms ≈ 41 at 26 fps, 68 % kernel) reads as "the present costs the frame". It does not:mali_fprof_present()is called from the present submit (mali_queue.c:717) andpresent_msis the interval between two of those calls (mali_fprof.c:201-212) — 41 ms at 26 fps is exactly1/fps. Nothing inside the present is timed today, so the 68 % kernel time is unattributed.What this adds
Six timers, each one clock read and only when
MALI_FRAME_PROFis set:wsi_common_acquire_next_image2(the image fence, or the gate ring on a shm chain):1248-1250present_wait_submit_fence:dup()+be->fence_wait(fd, 1000):1050-1056present_image_cpu_sync: kbase cache maintenance over the whole image BO:1021-1026memcpyinto the shm segment:1185-1187xcb_shm_put_image+xcb_flush:1190-1223vkQueuePresentKHRbody (wrapper around it, early returns preserved):1712-1724FRAMEPROFlines become... present_ms=41.2 ... wsi_us=a/w/s/c/p/call, the summary line gainswsi_avg_us=.mali_device_fprof()(mali_queue.c:571) is the accessor:struct mali_hwctxis private to mali_queue.c, so mali_wsi.c asks rather than including it.The step list (M/notes/present-cost.md, host read)
The CMF takes the software MIT-SHM path (Xwayland on Mali has no DRI3,
mali_wsi.c:104-109), and the steps are: trace (MALI_WSI_DUMPonly) → shm drain (non-blocking) → wait the app's present semaphores,UINT64_MAX(:1759-1770, this is where a GPU-bound frame's time lands) → per image: fence wait → device→CPU cache maintenance →memcpyof 1920×1080×4 = 8.3 MB from a write-combined mapping (:1186, 10-40 ms at 200-800 MB/s, the only step that can be the frame on its own) →XShmPutImage+ flush (µs, no image bytes on the socket) → release.So the expectation to test on the phone: if
wsi_us'scopyis ~20-40 ms, the fix is to stop copying (dma-buf/DRI3, or a shm segment we render into directly); ifwait+calldominate, the frame is GPU-bound and present is innocent; ifsyncdominates, the cache maintenance per frame is the target.Checks
./check.sh: 241 ok, one failure —wl mock host v10/v13(present_ms max 8.68vs a 5.00 limit) with the laptop at load 13.9 and 25 concurrent build/check processes from other lanes; the same row failed the same way on an unrelated lane and on main's behaviour, and this PR adds no clock read whenMALI_FRAME_PROFis unset.MALI_FRAME_PROF=1printswsi_us=0.0/0.0/0.0/0.0/0.0/0.0on every line (no swapchain in those runs) and the summary line carrieswsi_avg_us.xwsi-host.shskips: no gamescope/Xwayland).