-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
msSinceInput reports incorrectly #194
Comments
Hi, thanks for the report and sorry for the delay. The main cause of the discrepancy here is that PresentMon is computing datetime differently than WPA. This is a PresentMon bug and I'll work on a fix, but for now this means that the msSinceInput delta is OK but you can't compare datetime's between PresentMon and WPA. Note that there is another slight difference because PresentMon doesn't use the interrupt time, but the Win32K InputDeviceRead event which occurs slightly later (~100us later in a test I just ran). |
This commit has two changes to improve --datetime: 1) When processing an ETL, use full precision for the trace start time (previously was only using milliseconds). This will result in the same present time for WPA and PresentMon when using --datetime and --etl_file. 2) When collecting in realtime with --datetime, this changes the ETW timestamp from QPC to SYSTEMTIME. This ensures PresentMon's reported present start time will be the correct datetime, however it will not exactly match WPA. WPA converts QPC into datetimes, but PresentMon cannot match that during realtime collection without using the same trace start time, which I can't find a way to query. See issue #194
I was able to fix a few things, but I couldn't find a way to make your above methodology work (capturing PresentMon and ETL at the same time). With the latest change the datetime in PresentMon and WPA should be closer, but the only way to get them to match would be to:
You can use the Tools\start_etl_collection.cmd and Tools\stop_etl_collection.cmd scripts to ensure that all the events PresentMon needs will be collected. |
Thanks for looking into this, I appreciate it!
I can confirm that this works, and using the cmd scripts, I get Win32K InputDeviceRead 20us after ISR.
I was wondering how do we know that Win32K InputDeviceRead is associatiated with the right frame? Is it just guessing based on the timing of the event and then associated to the next frame, or how does it work? Thanks again, take care! |
I've seen WPA do that as well occasionally in different contexts. I'm not sure why or how to get around it, sorry. Sometimes it will eventually complete, so you could try waiting, but usually I'll recapture and hope it doesn't happen the next time 🤷. I use the Win32k RetrieveInputMessage to associate the InputDeviceRead with a frame. This is when the input is available in the target processes' message queue, though it does make a couple assumptions:
AFAIK those are reasonable assumptions. At some point in the future we can investigate using the ISR event instead to get a better measure. However, that requires a kernel trace session which is less flexible, and filtering all the interrupts will have more capture overhead so it's a trade off we'll have to evaluate. |
I narrowed the problem down to the win32k provider flag. If you change it from 0x8400000440c01000 to 0x4000000402E2000, WPA opens fine even when the trace was made while running fullscreen and it still gives you RetrieveInputMessage and InputDeviceRead messages. But for some reason using that flag makes PM unable to output a csv.
How does PM determine the sample point/actual cpu frame start? With some framelimiters the game doesn't sample input right after present ends, but stalls and collects input at a later point. Thank you for the help and insight, appreciate it! |
Interesting; thanks! I'll look into those keyword changes. PresentMon assumes that the cpu frame start is the the time that the previous frame's Present() call returned, which is a good default assumption. To do better we need an API for applications to tell PresentMon their own timing, which we're planning for a future version. msSinceInput is not relative to the cpu frame start though, it is relative to the start of this frame's Present() call. The ClickToPhotonLatency metric in v2.0 is the time between input and the frame being displayed (msSinceInput + msUntilDisplayed in v1.* metrics). |
I wanted to see the latency between ISR of USB and when the game registers input, so I ran a wpr trace and presentmon trace at the same time.
It seems that msSinceInput reports input as happening well before the USB ISR even ran.
Presentmon:
By substracting msSinceInput from TimeInSeconds we get 2024-1-17 13:49:56.8100508
WPR:
You can see that there is a fragment every 1s while there was no input and then every 1 ms when I moved the mouse as expected.
So the first ISR caused by input happened at 2024.01.17 13:49:56.8108321.
Thats 0.7813ms AFTER what presentmon reports.
To recreate:
-run presentmon with -track_input and -date_time
-run wpr like this
The text was updated successfully, but these errors were encountered: