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

[FR] Cut down performance hit of dynamically generating prefix-symbols each time #3763

Closed
BioTurboNick opened this issue Aug 24, 2021 · 4 comments · Fixed by #3775
Closed
Labels
performance speedups and slowdowns

Comments

@BioTurboNick
Copy link
Member

11% of profiler samples in one of my plots are being spent in Symbol(x, y), which constructs a new symbol from two different symbols. Each time this happens, 3 allocations are required.

This code was run 429,042 times, and consuming 72 MiB, in generating my plot. It thus appears to account for 24% of allocations and 23% of allocation amount of generating my plot, between calls to _update_axis and _update_subplot_args.

Can this list of attribute combinations be generated once and then read from, rather than being constructed expensively on the fly?

@BioTurboNick
Copy link
Member Author

BioTurboNick commented Aug 24, 2021

Some possible minor improvements:

# current: Symbol(x...) = Symbol(string(x...))
@btime Symbol(:test, :me)
  111.024 ns (3 allocations: 176 bytes)

Symbol(x::Symbol, y::Symbol) = Symbol(string(x, y))
@btime Symbol(:test, :me)
  110.974 ns (3 allocations: 176 bytes) - no change

Symbol(x::Symbol, y::Symbol) = Symbol(string(x), string(y))
@btime Symbol(:test, :me)
  84.826 ns (3 allocations: 96 bytes) - 25% better in time, 45% better in memory space

Implementing the last one cut plot time by 10%, allocation count by 2%, and allocation amount by 25%, though that's presumably a change that needs to go into Base.

@BioTurboNick
Copy link
Member Author

BioTurboNick commented Aug 26, 2021

Should this be closed? The change in Julia base helps a lot, but there may still be a way to eliminate many of those allocations.

@t-bltg
Copy link
Member

t-bltg commented Aug 26, 2021

Sorry, though it was fixed in https://github.com/JuliaLang/julia.

@BioTurboNick
Copy link
Member Author

Thanks for your help on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance speedups and slowdowns
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants