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

Optimize import time #8

Merged
merged 1 commit into from
Mar 23, 2022
Merged

Optimize import time #8

merged 1 commit into from
Mar 23, 2022

Conversation

tkf
Copy link
Owner

@tkf tkf commented Mar 23, 2022

#6 makes loading MIMEFileExtensions (v0.1.1) slow:

$ rm ~/.julia/compiled/v1.7/MIMEFileExtensions/*.ji
$ julia -e '@time using MIMEFileExtensions'
  1.088552 seconds (506.06 k allocations: 29.272 MiB, 36.05% compilation time)
$ ls -lh ~/.julia/compiled/v1.7/MIMEFileExtensions
total 208K
-rw-rw-r-- 1 arakaki arakaki 206K Mar 22 21:47 0i4jm_ydM5K.ji
$ julia -e '@time using MIMEFileExtensions'
  0.425975 seconds (478.77 k allocations: 27.534 MiB, 90.62% compilation time)
$ julia -e '@time using MIMEFileExtensions'
  0.425975 seconds (478.77 k allocations: 27.534 MiB, 90.57% compilation time)

It looks like the main reason is that Tuple{Vararg{String}} is not a terrible type to represent variable-length content.

Using Vector{String}:

$ rm ~/.julia/compiled/v1.7/MIMEFileExtensions/*.ji
$ julia -e '@time using MIMEFileExtensions'
  0.443467 seconds (118.20 k allocations: 8.624 MiB, 19.87% compilation time)
$ ls -lh ~/.julia/compiled/v1.7/MIMEFileExtensions
total 208K
-rw-rw-r-- 1 arakaki arakaki 207K Mar 22 21:16 0i4jm_ydM5K.ji
$ julia -e '@time using MIMEFileExtensions'
  0.097309 seconds (90.92 k allocations: 6.949 MiB, 75.95% compilation time)
$ julia -e '@time using MIMEFileExtensions'
  0.097159 seconds (90.91 k allocations: 6.887 MiB, 75.86% compilation time)

Using Vector{Symbol} (this PR):

$ rm ~/.julia/compiled/v1.7/MIMEFileExtensions/*.ji
$ julia -e '@time using MIMEFileExtensions'
  0.438848 seconds (112.58 k allocations: 8.364 MiB, 18.68% compilation time)
$ ls -lh ~/.julia/compiled/v1.7/MIMEFileExtensions
total 196K
-rw-rw-r-- 1 arakaki arakaki 193K Mar 22 21:15 0i4jm_ydM5K.ji
$ julia -e '@time using MIMEFileExtensions'
  0.091745 seconds (85.30 k allocations: 6.627 MiB, 74.87% compilation time)
$ julia -e '@time using MIMEFileExtensions'
  0.091200 seconds (85.30 k allocations: 6.627 MiB, 75.03% compilation time)

Vector{Symbol} is slightly faster and produces a smaller cache.

@tkf tkf enabled auto-merge (squash) March 23, 2022 01:49
@codecov
Copy link

codecov bot commented Mar 23, 2022

Codecov Report

Merging #8 (917160f) into main (2a0a4b1) will increase coverage by 1.02%.
The diff coverage is 66.66%.

@@            Coverage Diff             @@
##             main       #8      +/-   ##
==========================================
+ Coverage   48.97%   50.00%   +1.02%     
==========================================
  Files           1        1              
  Lines          49       54       +5     
==========================================
+ Hits           24       27       +3     
- Misses         25       27       +2     
Flag Coverage Δ
Pkg.test 50.00% <66.66%> (+1.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/MIMEFileExtensions.jl 50.00% <66.66%> (+1.02%) ⬆️

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@tkf tkf merged commit aab21a8 into main Mar 23, 2022
@tkf tkf deleted the opt branch March 23, 2022 01:51
@tkf tkf mentioned this pull request Mar 25, 2022
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.

1 participant