-
Notifications
You must be signed in to change notification settings - Fork 37
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
Add Base.hash(::Quaternion, ::UInt)
#136
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #136 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 2 2
Lines 162 175 +13
=========================================
+ Hits 162 175 +13 ☔ View full report in Codecov by Sentry. |
Hmm, not sure why the Invalidation test failed.. https://github.com/JuliaGeometry/Quaternions.jl/actions/runs/6814371318/job/18531083622?pr=136 |
@@ -236,6 +236,17 @@ function Base.isequal(q::Quaternion, w::Quaternion) | |||
isequal(q.s, w.s) & isequal(q.v1, w.v1) & isequal(q.v2, w.v2) & isequal(q.v3, w.v3) | |||
end | |||
|
|||
if UInt === UInt64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this be better?
if UInt === UInt64 | |
@static if UInt === UInt64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @static
macro brings better performance if it is used inside a function, but this case is not, so it seems there would not be better performance here.
julia> f() = @static Sys.iswindows() ? 1 : 2
f (generic function with 1 method)
julia> @code_lowered f()
CodeInfo(
1 ─ return 2
)
julia> g() = Sys.iswindows() ? 1 : 2
g (generic function with 1 method)
julia> @code_lowered g()
CodeInfo(
1 ─ %1 = Base.Sys.iswindows
│ %2 = (%1)()
└── goto #3 if not %2
2 ─ return 1
3 ─ return 2
)
@ranocha Do you know why the Invalidation check failed? |
The invalidation failure was because the number of Before this PR julia> using SnoopCompile, SnoopCompileCore
julia> invalidations = @snoopr begin using Quaternions end;
julia> uinvalidated(invalidations)
Set{Core.MethodInstance} with 1 element:
MethodInstance for promote_rule(::Type, ::Type)
julia> inv_owned = length(filtermod(Quaternions, invalidation_trees(invalidations)))
0 After this PR julia> using SnoopCompile, SnoopCompileCore
julia> invalidations = @snoopr begin using Quaternions end;
julia> uinvalidated(invalidations)
Set{Core.MethodInstance} with 2 elements:
MethodInstance for hash(::Any, ::UInt64)
MethodInstance for promote_rule(::Type, ::Type)
julia> inv_owned = length(filtermod(Quaternions, invalidation_trees(invalidations)))
0 But it seems this is not problematic because (The above code are from https://github.com/julia-actions/julia-invalidations/blob/main/action.yml.) |
Based on your results above, it looks like there are some new invalidations caused by the new specialization. You don't invalidate your own functions but something that's using |
I see. Thank you for the detailed explanation! |
I'll merge this PR in a few days if there are no objections. |
This PR fixes #135.
Before this PR
After this PR