Comments (12)
I will run some benchmarks right now to try to quantify what the cost (if any) is, and will report back here with the results.
(Your argument makes sense -- I believe in "trust but verify".)
from algebra.
So I just modified one of the Spire benchmarks we use to test specialization (spire.benchmark.AddBenchmarks
) which is not normally specialized for Byte
. I compared the cost of a direct implementation, a non-specialized implementation, and an implementation that was specialized on Byte
.
The results were:
[info] benchmark us linear runtime
[info] AddBytesDirect 117.5 =
[info] AddBytesGeneric 850.7 ====
[info] AddBytesFullspec 118.2 =
This appears to indicate an 8x slowdown for bytes. This doesn't prove that instances are being allocated: it's possible that this is the cost of using a lookup table. However it does indicate a penalty that we will pay for removing specialization.
I'm still open to discussing whether this is worth it or not.
from algebra.
So, my personal opinion is that I don't see a ton of value in specializing below Int
. Namely, I propose sticking with Int
, Long
, Float
, and Double
unless we have a compelling case otherwise. The cost of specialization especially blows up when classes have 2 or more specialized parameters. Scala's Function1
and Function2
don't go beyond these types either.
from algebra.
How about using miniboxing to achieve specialization? I feel it's reasonably stable now, and with the 0.4
release it should address all the quirks of specialization (quirks metabug here), allowing you to simplify the code. And it would certainly reduce the bytecode size, as benchmarks have shown.
Also, if you need any help or bugfixes to make it work, I'd be glad to lend a hand. ;)
from algebra.
Hi @VladUreche! I have been waiting for you to recommend something like this! That's great news!
I think as a first step I might publish an alternate miniboxed jar in addition to the "standard" one. Do you think that makes sense? That way, users could choose whether they wanted to introduce miniboxing into their build or not.
from algebra.
Hrmm... @non I think I'll take a stab at that idea... Don't think it'll be too bad.
from algebra.
@tixxit Awesome, thanks!
from algebra.
I think as a first step I might publish an alternate miniboxed jar in addition to the "standard" one. Do you think that makes sense? That way, users could choose whether they wanted to introduce miniboxing into their build or not.
@non: Yep, that sounds very good! Having released jars built with miniboxing and specialization side by side will not only provide choice to the users, but will also allow us to benchmark them side by side and iron out any performance regressions that may occur. So yes, let's do that!
@tixxit: Awesome! Please let me know if you encounter any issues, I will fix them asap.
from algebra.
See #30
from algebra.
After a quick poll of Spire users (at least those who are on the ML and responded) it seems like no one is really relying on Byte
or Short
.
My concrete proposal to move forward would be to use @sp(Int, Long, Float, Double)
in all cases except for Eq
, PartialOrder
, and Order
. I'd like to leave those alone since they are much more general.
What do you think?
from algebra.
👍
from algebra.
+1
from algebra.
Related Issues (20)
- add Kleene Algebra HOT 1
- fromInt and Ring-like structures.
- ConicMonoid: when values are always increasing. HOT 10
- Publish a version for cats 0.8.0 HOT 1
- cast class exception using algebra with algebird HOT 1
- Annihilator -- Structure with element that "annihilates" any other element of the set HOT 3
- Add tests for the functions in companion objects of the types. HOT 1
- Publish 0.7.0 to address binary incompatibility HOT 1
- Algebra Syntax (was #78 Symbolic Infix Operators)
- link to docs is broken HOT 5
- Why don't we move Spire's Module/VectorSpace/MetricSpace/etc. here? HOT 3
- Possible compatibility breaking change in cats-kernel HOT 1
- Upgrade to Cats RC1 HOT 2
- Law testing guidelines HOT 1
- Broken links in README.md HOT 2
- Integrating cats.kernel.Semigroup and friends HOT 30
- publish for Scala 2.13.0-M5 HOT 26
- publish for Scala 2.13 HOT 1
- Integrate intermediate steps between `CommutativeRing` and `Field` HOT 1
- Archive this repo? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from algebra.