-
Notifications
You must be signed in to change notification settings - Fork 3
reboot - use of @inline #2
Comments
i7-3840QM @ 2.8 GHz Inline almost never won, but Noinline always got to go second. Microbenchmarking is hard. |
I have updated the benchmark suite so its more accurate, it now uses the Here are my latest results They seem to be neck and neck, in some cases inline won, in other cases inline didn't win. In each case, the margin is around 0.5-5%. This is probably more expected, since |
Hmm, it seems that due to scalameter/scalameter#143, I can't test how effective the |
jmh is a tool many people like for microbenchmarking. My results on fce35fb, for whatever they're worth: https://gist.github.com/rossabaker/f66ca9c2e265215bdc2b I'm not closing the door on this, but my default position is that this annotation is not necessary. The JVM does a reasonable job of optimizing this, and most people find, as we are, that it's hard to measure an improvement being explicit. |
+1 on not using @inline. |
Removing inline now |
@rossabaker Has understandable issues in regards to using
@inline
for the AST, since it makes the API quite brittle (see http://stackoverflow.com/questions/4593710/when-should-i-and-should-i-not-use-scalas-inline-annotation)Due to this, I have implemented benchmarks to see if
@inline
is worth it, using https://github.com/scalameter/scalameter (which is a testing framework, that also automatically deals for things likeJVM
warmup). Long story short,@inline
does provide significant performance improvements, which vary depending on which methods are called.As an example, Method "D" in https://github.com/mdedetrich/json4s-ast/blob/reboot/jvm/src/test/scala/InlineTest.scala,
@inline
has a performance increase of 38% (which is huge)Here is a Gist of my latest run (you can just run
sbt test
to run the test suite) to provide results for your machine. My one is the most powerful version of Macbook Pro from one year ago, so interested to see results on weaker machines.https://gist.github.com/mdedetrich/86887d2bfa7a3c28e0b9
As it stands, my current position is to leave
@inline
in there. It actually makes more sense for something likejson-ast
, since it will be updated incredibly rarely, so brittle API breakage isn't an issue for a library that updates for something like once a year.Would also be handy to add more tests for less trivial methods, I am sure there are other examples where
@inline
makes a big impact.The text was updated successfully, but these errors were encountered: