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

Fix invalidations by removing unnecessary methods #69

Merged
merged 1 commit into from
Nov 27, 2023

Conversation

jakobjpeters
Copy link
Contributor

There are currently 35 unique methods being invalidated. This PR fixes 31 of these by deleting methods that have pre-existing implementations defined in terms of the remaining methods. I am uncertain of the source of the remaining 4 invalidations. Users and dependents of this package will benefit from decreased latency from needing to recompile up to 31 methods.

Note that I deleted getindex(::LaTeXString, ::Int), which states to resolve a method ambiguity in Julia 0.6. This version was released over 6 years ago and is pre-1.0, so I support having reduced latency for current users over maintaining that support. However, I would be happy to redefine that method upon request.

See also #64.

Before

~> julia --startup-file=no --banner=no
(@v1.9) pkg> activate debug
  Activating project at `~/debug`

julia> using SnoopCompileCore

julia> invalidations = @snoopr using LaTeXStrings;

julia> using SnoopCompile

julia> length(uinvalidated(invalidations))
35

julia> trees = invalidation_trees(invalidations)
6-element Vector{SnoopCompile.MethodInvalidations}:
 inserting firstindex(s::LaTeXString) @ LaTeXStrings ~/.julia/packages/LaTeXStrings/ZtSdh/src/LaTeXStrings.jl:108 invalidated:
   backedges: 1: superseding firstindex(s::AbstractString) @ Base strings/basic.jl:180 with MethodInstance for firstindex(::AbstractString) (1 children)
   7 mt_cache

 inserting eachmatch(re::Regex, s::LaTeXString; overlap) @ LaTeXStrings ~/.julia/packages/LaTeXStrings/ZtSdh/src/LaTeXStrings.jl:134 invalidated:
   backedges: 1: superseding eachmatch(re::Regex, str::AbstractString; overlap) @ Base regex.jl:712 with MethodInstance for eachmatch(::Regex, ::AbstractString) (2 children)

 inserting sizeof(s::LaTeXString) @ LaTeXStrings ~/.julia/packages/LaTeXStrings/ZtSdh/src/LaTeXStrings.jl:127 invalidated:
   backedges: 1: superseding sizeof(s::AbstractString) @ Base strings/basic.jl:179 with MethodInstance for sizeof(::AbstractString) (4 children)

 inserting getindex(s::LaTeXString, i::Int64) @ LaTeXStrings ~/.julia/packages/LaTeXStrings/ZtSdh/src/LaTeXStrings.jl:117 invalidated:
   backedges: 1: superseding getindex(s::AbstractString, i::Integer) @ Base strings/basic.jl:184 with MethodInstance for getindex(::AbstractString, ::Int64) (5 children)

 inserting lastindex(s::LaTeXString) @ LaTeXStrings ~/.julia/packages/LaTeXStrings/ZtSdh/src/LaTeXStrings.jl:109 invalidated:
   backedges: 1: superseding lastindex(s::AbstractString) @ Base strings/basic.jl:181 with MethodInstance for lastindex(::AbstractString) (5 children)

 inserting nextind(s::LaTeXString, i::Int64) @ LaTeXStrings ~/.julia/packages/LaTeXStrings/ZtSdh/src/LaTeXStrings.jl:112 invalidated:
   backedges: 1: superseding nextind(s::AbstractString, i::Int64) @ Base strings/basic.jl:556 with MethodInstance for nextind(::AbstractString, ::Int64) (19 children)

After

~/Documents/Programming/forks/LaTeXStrings.jl> julia --startup-file=no --banner=no
(@v1.9) pkg> activate debug
  Activating project at `~/debug`

(debug) pkg> st
Status `~/debug/Project.toml`
  [b964fa9f] LaTeXStrings v1.3.1 `..`
  [aa65fe97] SnoopCompile v2.10.8
  [e2b509da] SnoopCompileCore v2.10.0

julia> using SnoopCompileCore

julia> invalidations = @snoopr using LaTeXStrings;

julia> using SnoopCompile

julia> length(uinvalidated(invalidations))
4

julia> trees = invalidation_trees(invalidations)
SnoopCompile.MethodInvalidations[]

@jakobjpeters
Copy link
Contributor Author

I just remembered that this could maintain compatability for users of old versions

VERSION <= v"0.6.0" && @eval Base.getindex(s::LaTeXString, i::Int) = getindex(s.s, i)

@stevengj
Copy link
Member

I don't think it's necessary to preserve pre-1.0 support.

@stevengj
Copy link
Member

You will need to rebase to get CI running (via #70).

@codecov-commenter
Copy link

codecov-commenter commented Nov 27, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4b64d70) 90.47% compared to head (b009bf0) 91.07%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #69      +/-   ##
==========================================
+ Coverage   90.47%   91.07%   +0.59%     
==========================================
  Files           1        1              
  Lines          63       56       -7     
==========================================
- Hits           57       51       -6     
+ Misses          6        5       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@stevengj stevengj merged commit c2ad111 into JuliaStrings:master Nov 27, 2023
6 checks passed
@topolarity
Copy link

Would it be possible to get a release with this?

@stevengj
Copy link
Member

JuliaRegistries/General#117305

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.

4 participants