Skip to content
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

Adopt refresh_delays as cache sources TTL #2334

Closed
wants to merge 1 commit into from

Conversation

lifenjoiner
Copy link
Member

refresh_delay was limited to [1, 168], while source.prefetchDelay is 24 which controlled downloading.

That makes refresh_delay less effective.
[1, 24) triggers reparsing cache sources but no downloading, (24, 168] is defeated by source.prefetchDelay but says still fresh. In other words, value which is non-integer times of 24 is ceiled, and downloading always happen every 24h if there is no failure triggers retry.

The process flow was complicated and puzzling. Plus there could be multiple refresh_delays.

Now, both downloading and reparsing are ruled by refresh_delay, prefetchDelay is obsoleted. It gives user sense of mastery, with tutelage.


More explains:

The delay algorithm of source downloading and reparsing is very complicated and puzzling.
Here are my understandings:
Workflow
delay
Delay
sleep

Different refresh_delays of sources make things more complicated. Here are some key rules:

  1. prefetchDelay always controls the downloading, if no failure. At startup, refresh_delay doesn’t determine delay at all. If the cache expired, then the delay depends on the downloading result. If the cache isn’t expired, delay = source.prefetchDelay - elapsed.
  2. refresh_delay is only effective at startup or on out-of-step sources, when it < prefetchDelay and the cache is expired at startup. When it > prefetchDelay, source.prefetchDelay - elapsed is smaller. So, if the cache elapsed between them, program will say the cache is fresh but still is going to download the files, and then sleep depending on the result. refresh_delay doesn’t produce the delay too, when the flow starts from PrefetchSources.
  3. Any cache delay remain time is ceiled to prefetchDelay. Those refresh_delay > prefetchDelay, but is not N * prefetchDelay, the refresh_delay % prefetchDelay will be ceiled to prefetchDelay. And refresh_delay < prefetchDelay too. It makes refresh_delay slightly meaningless. And, at startup, the worst case delay is approximately 2 * prefetchDelay.

In summary, refresh_delay is less effective and makes things puzzling. Adopting refresh_delay as the real delay will make things simple and give user sense of mastery.

`refresh_delay` was limited to `[1, 168]`, while `source.prefetchDelay` is 24
which controlled downloading.

That makes `refresh_delay` less effective.
`[1, 24)` triggers reparsing cache sources but no downloading,
`(24, 168]` is defeated by `source.prefetchDelay` but says still fresh.
In other words, value which is non-integer times of 24 is ceiled, and
downloading always happen every 24h if there is no failure triggers retry.

The process flow was complicated and puzzling. Plus there could be multiple
`refresh_delay`s.

Now, both downloading and reparsing are ruled by `refresh_delay`,
`prefetchDelay` is obsoleted. It gives user sense of mastery, with tutelage.
@DNSCrypt DNSCrypt deleted a comment May 14, 2023
@jedisct1 jedisct1 closed this in 2675d73 Aug 10, 2023
jedisct1 added a commit that referenced this pull request Aug 11, 2023
I'm not sure I follow, but I trust @lifenjoiner

Fixes #2334
jedisct1 added a commit that referenced this pull request Aug 11, 2023
d3cim added a commit to d3cim/dnscrypt-proxy-android that referenced this pull request Aug 12, 2023
@lifenjoiner lifenjoiner deleted the PrefetchDelay branch August 27, 2023 12:05
@DNSCrypt DNSCrypt locked and limited conversation to collaborators Sep 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant