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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize colormap #509

Merged
merged 7 commits into from
Sep 25, 2021
Merged

Conversation

kimikage
Copy link
Collaborator

@kimikage kimikage commented Aug 2, 2021

This uses Tuple instead of Vector for the colormap parameters. (cf. ddfe8d5)
This also unifies the type of preset values to Float64.

However, at present, there is no speed improvement. 馃槶
I will make some more tweaks and add some tests.
This is more of a compilation time issue than a runtime performance issue. I am guessing that there is some relation between the precompilation problem with colormap and #496.

before

julia> using Colors

julia> @time colormap("RdBu", 100);
  0.356729 seconds (1.47 M allocations: 87.943 MiB, 8.93% gc time, 99.93% compilation time)

julia> @time colormap("RdBu", 100);
  0.000067 seconds (916 allocations: 39.406 KiB)

julia> @time colormap("Blues", 100);
  0.000056 seconds (656 allocations: 25.875 KiB)

julia> @time colormap("RdBu", 100, logscale=true);
  0.009631 seconds (55.90 k allocations: 3.555 MiB, 99.07% compilation time)

julia> @time colormap("RdBu", 100, mid=0.7);
  0.000111 seconds (916 allocations: 41.219 KiB)

after (w/o PR #511)

julia> using Colors

julia> @time colormap("RdBu", 100);
  0.069386 seconds (605.76 k allocations: 38.593 MiB, 17.43% gc time, 99.91% compilation time)

julia> @time colormap("RdBu", 100);
  0.000025 seconds (30 allocations: 6.031 KiB)

julia> @time colormap("Blues", 100);
  0.000021 seconds (16 allocations: 3.000 KiB)

julia> @time colormap("RdBu", 100, logscale=true);
  0.012442 seconds (55.02 k allocations: 3.522 MiB, 99.67% compilation time)

julia> @time colormap("RdBu", 100, mid=0.7);
  0.000029 seconds (30 allocations: 6.016 KiB)

after (w/ PR #511)

julia> using Colors

julia> @time colormap("RdBu", 100);
  0.000042 seconds (6 allocations: 5.281 KiB)

julia> @time colormap("Blues", 100);
  0.000019 seconds (4 allocations: 2.625 KiB)

julia> @time colormap("RdBu", 100, logscale=true);
  0.008044 seconds (54.99 k allocations: 3.521 MiB, 99.62% compilation time)

julia> @time colormap("RdBu", 100, mid=0.7);
  0.000032 seconds (6 allocations: 5.266 KiB)

This also fixes the problem with hue interpolation.
colormap_hue

@kimikage kimikage marked this pull request as draft August 2, 2021 14:04
@codecov
Copy link

codecov bot commented Aug 2, 2021

Codecov Report

Merging #509 (2466f17) into master (2b553ad) will decrease coverage by 0.05%.
The diff coverage is 94.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #509      +/-   ##
==========================================
- Coverage   94.07%   94.01%   -0.06%     
==========================================
  Files           9        9              
  Lines        1249     1270      +21     
==========================================
+ Hits         1175     1194      +19     
- Misses         74       76       +2     
Impacted Files Coverage 螖
src/precompile.jl 0.00% <0.00%> (酶)
src/utilities.jl 95.23% <50.00%> (-0.37%) 猬囷笍
src/colormaps.jl 96.85% <94.93%> (+2.06%) 猬嗭笍
src/algorithms.jl 75.00% <100.00%> (-0.48%) 猬囷笍
src/conversions.jl 99.42% <100.00%> (+<0.01%) 猬嗭笍

Continue to review full report at Codecov.

Legend - Click here to learn more
螖 = absolute <relative> (impact), 酶 = not affected, ? = missing data
Powered by Codecov. Last update 2b553ad...2466f17. Read the comment docs.

@kimikage kimikage force-pushed the optimize_colormap branch 3 times, most recently from 204a31b to ceda821 Compare August 3, 2021 09:58
src/colormaps.jl Show resolved Hide resolved
src/colormaps.jl Show resolved Hide resolved
src/colormaps.jl Outdated Show resolved Hide resolved
src/colormaps.jl Outdated Show resolved Hide resolved
@kimikage
Copy link
Collaborator Author

kimikage commented Aug 31, 2021

Remaining problems:

  • Precompilation of RGB-->LCH conversion (PR Work around #496 for Luv, Lab聽#511 can fix this) Edit: Merged
  • Over-specialization with keyword arguments
  • Precompilation of vcat in _diverging_palette Edit: Fixed

These can be tackled in separate PRs, though.

@kimikage kimikage marked this pull request as ready for review September 20, 2021 03:45
@kimikage kimikage changed the title [WIP] Optimize colormap Optimize colormap Sep 20, 2021
@kimikage kimikage merged commit 6bb0d5c into JuliaGraphics:master Sep 25, 2021
@kimikage kimikage deleted the optimize_colormap branch September 25, 2021 10:57
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.

None yet

2 participants