Bug 183277 - MemoryPressureHandler's dispatch_source_set_timer uses s_minimumHoldOffTime as nanoseconds
Summary: MemoryPressureHandler's dispatch_source_set_timer uses s_minimumHoldOffTime a...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on: 182911
Blocks:
  Show dependency treegraph
 
Reported: 2018-03-01 23:00 PST by Yusuke Suzuki
Modified: 2023-08-01 10:26 PDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yusuke Suzuki 2018-03-01 23:00:53 PST
...
Comment 1 Ryan Reno 2023-08-01 10:26:11 PDT
Ran across this FIXME when working on something else. I think this parameter is pretty benign as-is but there might be some risk keeping it.

This is the leeway parameter which is documented below: (https://developer.apple.com/documentation/dispatch/1385606-dispatch_source_set_timer/)

>The leeway parameter is a hint from the application as to the amount of time, in >nanoseconds, up to which the system can defer the timer to align with other system >activity for improved system performance or power consumption. For example, an >application might perform a periodic task every 5 minutes, with a leeway of up to 30 >seconds. Note that some latency is to be expected for all timers, even when a leeway >value of zero is specified.

So we're basically telling the system it can delay firing the timer by an upper limit of 5 ns. Since this is a hold off timer for re-installing the memory pressure handler (presumably to minimize responding to rapid ping-pong between memory pressure states?) I think 5 seconds is far too long of a leeway but 5ns is probably a little on the short side.

All that is to say I think unless we measure that we are responding to memory pressure too slowly and can confirm it is due to leeway parameter we might as well just make it 0 or maybe some other value that doesn't imply we mean for it to be 5 seconds.