Comments (12)
I can try and put together something quick tonight, similar to the addition test I did earlier.
from oldimmutablearrays.jl.
I ran into a slightly odd thing while writing my performance test. I tried to write just a generic test function, but found that it affects performance really badly in a (to me) unexpected way. Could someone better acquainted with the workings of Julia clarify this to me?
using ImmutableArrays
typealias Vec3 Vector3{Float64}
# Test performance with addition
function test(N::Integer)
a = Vec3( 0.1, 0.5, 1.0)
b = Vec3(-0.1, 0.5, 0.0)
+(a,b)
@elapsed for i = 1:N
c = +(a,b)
end
end
# Test performance with f(a,b)
function test(f::Function, N::Integer)
a = Vec3( 0.1, 0.5, 1.0)
b = Vec3(-0.1, 0.5, 0.0)
f(a,b)
@elapsed for i = 1:N
c = f(a,b)
end
end
Now, the first version, which tests just the +
function, takes 0.133 seconds to run with a million iterations, but if I call the second one using the +
function, it takes twice as long:
julia> test1(1000000)
0.133707178
julia> test2(+, 1000000)
0.226056539
from oldimmutablearrays.jl.
The actual odd thing is that if I do the exact same test except for Julia vectors, a = [0.1, 0.5, 1.0]
etc., there is no difference between those two calls.
from oldimmutablearrays.jl.
@dronir : The latest commit generates a definition for addition equivalent the "explicit" version in your benchmark gist.
from oldimmutablearrays.jl.
Ok, I'll give that a spin.
Also, FWIW, I got some feedback on the Julia IRC channel about that timing difference. The idea is that in my first case the compiler can inline the call to +(a,b)
. For normal Julia Vectors, inlining is not possible because their length is not known a priori.
from oldimmutablearrays.jl.
In my most simplest test (just a loop repeating the same addition of two vectors), we now have a factor of 500 in performance over Julia's Vector. But in most real situations it'll be a lot less. Trying to come up with good realistic tests.
from oldimmutablearrays.jl.
I just added a very crude speed test in 3e82d4b that compares ImmutableArrays
operations relative to native Julia arrays.
Despite not having changed much over the past couple months, it seems ImmutableArrays
is now slower than native arrays. The test blew up on Travis CI for some reason, but locally, I'm seeing the following:
ImmutableArray operation speed relative to native Julia arrays:
+ 6.9845887294827635
* 2.5084415916681846
Either the native arrays got some significant performance gains or there was some kind of regression with respect to structures. Perhaps someone like @JeffBezanson has insight?
from oldimmutablearrays.jl.
I'm guessing the performance penalty is in the Matrix4x4() constructor recently added, which is defined in terms of ntuple, and which I have seen to be a big bottleneck in the past. Unfortunately I don't have time to test this hypothesis right now, but I would tweak test/speed.jl to use the older, more verbose, constructor and re-run.
from oldimmutablearrays.jl.
The constructor theory would also explain why the + number is bigger than the * number: addition is cheaper, so the effect of the constructor overhead would loom larger.
from oldimmutablearrays.jl.
I noticed the slowdown before I added the constructor. Additionally, the
time macro should only be measuring addition or multiplication, not
construction. I acknowledge the constructor is probably sub-optimal, but I
don't think it explains what I'm observing.
from oldimmutablearrays.jl.
As you may have noticed, I wrote that note in the middle of the night/super early in the morning. (I was up with some insomnia.) I realized after the fact that maybe I got that wrong.
Matrix4x4 is the biggest structure currently defined. Maybe it is still faster for smaller structures (like Vector3, say)...
from oldimmutablearrays.jl.
I just tested with an older version of Julia (a7b6dbd) from about 2 months ago. ImmutableArrays in its current state runs much faster with it. I'll probably open up an issue in the Julia repo.
from oldimmutablearrays.jl.
Related Issues (20)
- Add WYSIWYG Matrix constructor HOT 3
- Arrays of rank 3 or higher. HOT 1
- randmatstat benchmark
- construct, convert from native Julia arrays HOT 1
- Ambiguous definitions with MathConst HOT 1
- Error when running PackageEvaluator HOT 1
- inv(Matrix4x4) not working HOT 4
- Ambiguous Definitions in Julia 0.3 HOT 4
- Add Gaussian elimination HOT 1
- unrolled det/inv
- getindex definition HOT 1
- Incorrect type conversion for ImmutableArrays HOT 1
- Matrix4x4 * AbstractVector{Vector4} HOT 4
- Array conversion error HOT 1
- Tag a new version? HOT 2
- Support exponentiation of immutable matrices HOT 3
- Benchmark script is missleading.
- Deprecation? HOT 5
- WARNING: Base.MathConst is deprecated, use Base.Irrational instead HOT 1
- Info about upcoming removal of packages in the General registry
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 oldimmutablearrays.jl.