-
Notifications
You must be signed in to change notification settings - Fork 9
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
Algebra in core #254
Merged
Merged
Algebra in core #254
Changes from 9 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
3d2bede
port Add to tl algebra
erikerlandson db7cf20
port Sub to tl algebra
erikerlandson 2296aff
port Mul to tl algebra
erikerlandson fe55800
Div with TruncatedDivision is failing
erikerlandson e78652a
/ and tquot
erikerlandson da94832
neg
erikerlandson 746798b
pow and tpow
erikerlandson 79993dd
remove algebra.scala
erikerlandson ec6d576
explicit truncating conversions
erikerlandson 540299e
populate some coulomb.ops.algebra instances
erikerlandson b30eae2
refactor use of algebras
erikerlandson a72a408
scala.math.Ordering -> cats.kernel.Order
erikerlandson 1ee822f
refactor si, si.prefixes, mks, mksa to use export
erikerlandson c39fc91
tweak directories
erikerlandson 15b3dd5
refactor algebra to use export
erikerlandson 3b56b9d
factor value-specific optimizations to separate import
erikerlandson 6d2c43c
unit test optimized operations
erikerlandson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is a bikeshed for another issue/PR, but I'm concerned that
inline
combined withnew ...
is sub-optimal and can lead to a proliferation of anonymous classes in the jar. It depends on whether the compiler will automatically recognize this is a SAM and useinvokedynamic
instead. It might be better to implement this as a lambda e.g.v => num.toLong(v)
to encourage this optimization.I'm less familiar with Scala.js internals but this could be especially bad for JavaScript actually.
See typelevel/cats#3871 for a discussion of this topic.
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.
Actually, it's not obvious to me why
inline
is needed here?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.
Do not assume I'm using these only when they are needed 😁
I'm still working out my intuitions about when
inline
andtransparent inline
are necessary. Situations where a typeclass involved dependent typing seem unambiguous - they needtransparent inline
. Others are less obvious (to me).Some places I am definitely using
inline
for efficiency gains, but other places it may be a bad tradeAt any rate, if
inline
is problematic, I'm happy to clean all that up where it is not needed. Having some decent unit test coverage should make this a bit easier now. If something introduces a compile error, it ought to show up pretty fast.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.
Yes, I would use
inline
where needed only for its compile-time semantics.For runtime performance, both the JVM and the Scala.js linker backend do a fantastic job of inlining themselves.
We can always revisit
inline
opportunities in the future with a benchmark suite.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.
We have had bad experiences with macro generated classes in the past. When defining boopickle generated serialized it was very easy to endup generating thousands of instances that would bloat the resulting js size. It wasn't really noticeable on the jvm thus it was quite hard to spot
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.
overall I expect scala-3 coulomb to be better in this regard. I am using metaprogramming in multiple places where I was using intermediate typeclasses, and so these intermediate typeclasses should no longer appear in byte code. However, some of this may be offset by use of
transparent inline
, so it will definitely be helpful to remove any unimportant usages ofinline