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

improve printf performance by passing digit buffer around #30373

Merged
merged 1 commit into from
Dec 13, 2018

Conversation

JeffBezanson
Copy link
Sponsor Member

Mostly fixes the regression identified in #30218.
Test script:

using Printf

function printfd(n)
    io = open("/dev/null", "w")
    for i = 1:n
        @printf(io, "%d %d\n", i, i + 1)
    end
    close(io)
end

printfd(10)
@time printfd(10000)

Before:

  0.001573 seconds (14 allocations: 832 bytes)

after:

  0.000897 seconds (14 allocations: 832 bytes)

mostly fixes the regression identified in #30218
@vtjnash
Copy link
Sponsor Member

vtjnash commented Dec 12, 2018

LGTM. I don't think an API change can be back-ported though (perhaps unless no packages have been using or extending this).

@JeffBezanson
Copy link
Sponsor Member Author

I believe they're all internal functions, so we should aim to include this in 1.1 unless we hit a particularly bad problem.

@JeffBezanson JeffBezanson added this to the 1.1 milestone Dec 12, 2018
@KristofferC KristofferC mentioned this pull request Dec 12, 2018
52 tasks
@jmkuhn
Copy link
Contributor

jmkuhn commented Dec 13, 2018

DecFP.jl extends fix_dec() and ini_dec() to allow @sprintf to work.

cc @stevengj

@KristofferC
Copy link
Sponsor Member

Note that DecFP.jl is already broken on master (#30374)

@JeffBezanson
Copy link
Sponsor Member Author

It's very easy to fix after this pr. Just accept digits as the last argument instead of using the global.

@KristofferC KristofferC merged commit e836937 into master Dec 13, 2018
KristofferC pushed a commit that referenced this pull request Dec 13, 2018
mostly fixes the regression identified in #30218

(cherry picked from commit e836937)
@martinholters martinholters deleted the jb/printfbuf branch December 13, 2018 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants