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

Avoid calling clock::now in the common case. #1862

Closed
wants to merge 1 commit into from
Closed

Avoid calling clock::now in the common case. #1862

wants to merge 1 commit into from

Conversation

nadavrot
Copy link
Contributor

Summary:
Avoid calling clock::now in the common case.

Clock::now() can be an expensive call (a call to libc's __clock_gettime). PGO
data shows that the first check almost always succeeds, which makes the call to
Clock::now redundant. This patch peels one iteration that calls f() before
calling clock::now(). Notice that a very common use of this API is a function
that performs a single load in the function, so timing is not a major concern.

Differential Revision: D39611860

Summary:
Avoid calling clock::now in the common case.

Clock::now() can be an expensive call (a call to libc's __clock_gettime). PGO
data shows that the first check almost always succeeds, which makes the call to
Clock::now redundant. This patch peels one iteration that calls f() before
calling clock::now(). Notice that a very common use of this API is a function
that performs a single load in the function, so timing is not a major concern.

Differential Revision: D39611860

fbshipit-source-id: 105ce07995bdc96627aa8b3011dc565645a498c6
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D39611860

facebook-github-bot pushed a commit to facebook/hhvm that referenced this pull request Sep 20, 2022
Summary:
X-link: facebook/folly#1862

Avoid calling clock::now in the common case.

Clock::now() can be an expensive call (a call to libc's __clock_gettime). PGO
data shows that the first check almost always succeeds, which makes the call to
Clock::now redundant. This patch peels one iteration that calls f() before
calling clock::now(). Notice that a very common use of this API is a function
that performs a single load in the function, so timing is not a major concern.

Reviewed By: magedm

Differential Revision: D39611860

fbshipit-source-id: 8c7affc83f1e86fe3c8b2401391e1159d08a99ec
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.

None yet

2 participants