Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Cache] Use sub-second accuracy for internal expiry calculations #27031

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

Merged
merged 1 commit into from
Jun 11, 2018

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Apr 24, 2018

Q A
Branch? master
Bug fix? no
New feature? not really
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

Embeds #26929, #27009 and #27028, let's focus on the 4th commit for now.

This is my last significant PR in the Cache series :)

By using integer expiries internally, our current implementations are sensitive to abrupt transitions when time() goes to next second: $s = time(); sleep(1); echo time() - $s; can display 2 from time to time.
This means that we do expire items earlier than required by the expiration settings on items.
This also means that there is no way to have a sub-second expiry. For remote backends, that's fine, but for ArrayAdapter, that's a limitation we can remove.

This PR replaces calls to time() by microtime(true), providing more accurate timing measurements internally.

@fabpot
Copy link
Member

fabpot commented May 30, 2018

LGTM

@nicolas-grekas nicolas-grekas force-pushed the cache-microtime branch 2 times, most recently from 8282767 to b734ea5 Compare May 30, 2018 09:48
@nicolas-grekas nicolas-grekas force-pushed the cache-microtime branch 2 times, most recently from 129023a to bee7d41 Compare June 11, 2018 12:10
@nicolas-grekas
Copy link
Member Author

PR rebased.

Status: needs review

@fabpot
Copy link
Member

fabpot commented Jun 11, 2018

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 08554ea into symfony:master Jun 11, 2018
fabpot added a commit that referenced this pull request Jun 11, 2018
…lculations (nicolas-grekas)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[Cache] Use sub-second accuracy for internal expiry calculations

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | not really
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Embeds #26929, #27009 and #27028, let's focus on the 4th commit for now.

This is my last significant PR in the Cache series :)

By using integer expiries internally, our current implementations are sensitive to abrupt transitions when time() goes to next second: `$s = time(); sleep(1); echo time() - $s;` *can* display 2 from time to time.
This means that we do expire items earlier than required by the expiration settings on items.
This also means that there is no way to have a sub-second expiry. For remote backends, that's fine, but for ArrayAdapter, that's a limitation we can remove.

This PR replaces calls to `time()` by `microtime(true)`, providing more accurate timing measurements internally.

Commits
-------

08554ea [Cache] Use sub-second accuracy for internal expiry calculations
@nicolas-grekas nicolas-grekas deleted the cache-microtime branch June 11, 2018 13:25
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.2 Nov 1, 2018
This was referenced Nov 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants