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

Don't double-count inference time #48033

Merged
merged 3 commits into from
Dec 29, 2022
Merged

Don't double-count inference time #48033

merged 3 commits into from
Dec 29, 2022

Conversation

pchintalapudi
Copy link
Member

Fixes #48024

During #46825, the timing code was updated to use task-local state instead of unsynchronized globals. Unfortunately, one of the pieces of timing code ended up using a different state tracker than the other timers, which led to the overcounting in #48024. That is fixed here + a test.

@pchintalapudi pchintalapudi added the backport 1.9 Change should be backported to release-1.9 label Dec 29, 2022
@IanButterworth
Copy link
Sponsor Member

Nice! The added tests are great, but I wonder whether we should also explicitly test the string output of @time given that @time comes with particular expectations for how code is compiled that might change if the macro changes. So parse the first percentage in the string etc.

Something like this perhaps

fname = tempname()
open(fname, "w") do
    redirect_stdout(f) do
        @time foo()
    end
end
buf = read(fname)
matches = collect(eachmatch(r"(\d+(\.\d+)?%)", buf))
@test parse(Float64, split(matches[1].match, "%")[1]) <= 100 # comp
@test parse(Float64, split(matches[2].match, "%")[1]) <= 100 # recomp

@pchintalapudi pchintalapudi added the status:merge me PR is reviewed. Merge when all tests are passing label Dec 29, 2022
@vchuravy vchuravy modified the milestones: 1.10, 1.9 Dec 29, 2022
@giordano giordano merged commit 1fda4bb into master Dec 29, 2022
@giordano giordano deleted the pc/reentrant-timer-fix branch December 29, 2022 06:52
@giordano giordano removed the status:merge me PR is reviewed. Merge when all tests are passing label Dec 29, 2022
KristofferC pushed a commit that referenced this pull request Jan 2, 2023
* Use the same timing reentrancy counter for both inference and codegen

* Add some timing tests

* Add macro-based timer test

(cherry picked from commit 1fda4bb)
@KristofferC KristofferC mentioned this pull request Jan 2, 2023
41 tasks
@KristofferC KristofferC removed the backport 1.9 Change should be backported to release-1.9 label Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@time seems to report incorrect "compilation time" percentage since the pkgimage merge
5 participants