# Do rules for good problems for benchmarking Julia exists?

**URL:** https://discourse.julialang.org/t/do-rules-for-good-problems-for-benchmarking-julia-exists/35900
**Category:** Performance
**Created:** [March 12, 2020, 8:48pm UTC](https://discourse.julialang.org/t/do-rules-for-good-problems-for-benchmarking-julia-exists/35900 "2020-03-12T20:48:24Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![KZiemian](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kziemian/32/9020_2.png) [@KZiemian](https://discourse.julialang.org/u/KZiemian)
#### Post date: [March 12, 2020, 8:48pm UTC](https://discourse.julialang.org/t/do-rules-for-good-problems-for-benchmarking-julia-exists/35900/1 "2020-03-12T20:48:24Z")

</div>

Few times I read discussions here, where someone try to check Julia speed, but take problem that was ill-suited for that. Two examples. Some times ago one person post examples in which `for` loop compute sum of arithmetic series of integers 1 + 2 + \ldots + 1 000 000 (or some other big number), unaware that compilator replace this loop by \frac{ 1000000 \cdot ( 1000000 + 1 ) }{ 2 } = 500000500000. To be honest, to this point I also didn’t know this is properties of decent compiler. Recently, one person was berchmanking multiplying matrices by running code

```julia
function foo1()
    temp = Array[]
    for i = 1:1000
        push!(temp, randn(400,400)*randn(400,1000))
    end
end

function foo2()
    for i = 1:1000
        randn(400,400)*randn(400,1000)
    end
end

```

As was pointed, in reality this check speed of `randn(...)` function. And have few additional problems.

Since some people struggle with that, is it possible to give some rules on how to find good problems for testing Julia speed? Even if its not, we can write down dozen of such tests, so maybe collecting them for newcomers can be beneficial? I don’t know and I will be glad to hear your opinions.

Documentation already have a good section on “Performance Tips”, but it is about how to write fast code independent of problem. This is of course one of most important rule for good benchmark: write it code according to “Performance Tips”. Not how to recognize that example is ill-suited for speed test. And of course there is great example of summing 10000000 random Float64’s in [Julia is fast](https://github.com/JuliaComputing/JuliaBoxTutorials/blob/master/introductory-tutorials/intro-to-julia/09.%20Julia%20is%20fast.ipynb) part of official tutorial, which I use time and again as illustration of Julia speed.

---

<div class="post-metadata">

### Author: ![bernhard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bernhard/32/2619_2.png) [@bernhard](https://discourse.julialang.org/u/bernhard)
#### Post date: [March 12, 2020, 9:20pm UTC](https://discourse.julialang.org/t/do-rules-for-good-problems-for-benchmarking-julia-exists/35900/2 "2020-03-12T21:20:04Z")

</div>

I think quite often, real problems (tasks or challenges) are well suited for benchmarking. So, just take what your are currently working on (maybe simplify it, or carve out a few parts).

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [March 13, 2020, 9:11am UTC](https://discourse.julialang.org/t/do-rules-for-good-problems-for-benchmarking-julia-exists/35900/3 "2020-03-13T09:11:02Z")

</div>

> [@KZiemian](#):
>
> someone try to check Julia speed, but take problem that was ill-suited for that

I would suggest that the whole concept of “checking” Julia is not a meaningful exercise.

Julia _is_ fast. You can easily get within a factor 2 of C with little effort _once you know the language_. This is by construction, since it compiles down to LLVM. That’s not where the magic is.

Users “checking” Julia are effectively _checking their understanding of programming_ Julia. This leads to surprises when they attribute differences in speed to “the language”.

Instead, new users should be _evaluating_ Julia with the following question in mind: once I learn the language, will it make it _convenient_ for me to write fast code? How much effort will generic constructs and composability save for me in the long run? But this is a project that takes about a week even for an experienced programmer, and much more difficult to quantify.

---

<div class="post-metadata">

### Author: ![jonathanBieler](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jonathanBieler](https://discourse.julialang.org/u/jonathanBieler)
#### Post date: [March 13, 2020, 10:37am UTC](https://discourse.julialang.org/t/do-rules-for-good-problems-for-benchmarking-julia-exists/35900/4 "2020-03-13T10:37:45Z")

</div>

I think what people care about in the end is the performances when doing concrete, standard or custom analysis one would do one a daily basis when doing data exploration, scientific computing, etc.

I made a [small package](https://github.com/jonathanBieler/ScientificComputingBenchmarks.jl) last year that tried to benchmark some of these use cases, but it doesn’t cover much.

---

<div class="post-metadata">

### Author: ![KZiemian](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kziemian/32/9020_2.png) [@KZiemian](https://discourse.julialang.org/u/KZiemian)
#### Post date: [March 14, 2020, 10:46pm UTC](https://discourse.julialang.org/t/do-rules-for-good-problems-for-benchmarking-julia-exists/35900/5 "2020-03-14T22:46:55Z")

</div>

> [@Tamas\_Papp](#):
>
> Julia _is_ fast. You can easily get within a factor 2 of C with little effort _once you know the language_ . This is by construction, since it compiles down to LLVM. That’s not where the magic is.

I agree, but I want to point few additional things.

If Julia was as C or C++, language which speed is well known and unquestionable, I would not open such discusion. But, judging from my experience, it is not, people must test its speed to believe. This is specially true in my country, Poland, which is unreasonable technological conservative in areas. And because very small difference in Julia code can produce factor 30 in speed, newcomers can check few programs, which are written in bad way, see that they are not very fast, say “This high-performance is just BS” and go somewhere else.

Fact that people still putting on this forum topics such “Julia is slower than Python” or analysis of ill-suited testes proves to me, that it is still much work to do in making people aware of this problem.

If Julia became standard, well recognized language for scientific computing (I hope that this happen soon, but I’m not a prophet), newcomers will not be put of by not-to-great performance of they first program. But until this time, Julia community have a lot work to do.

This is at list how I see this and I can be wrong.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [March 15, 2020, 8:12am UTC](https://discourse.julialang.org/t/do-rules-for-good-problems-for-benchmarking-julia-exists/35900/6 "2020-03-15T08:12:09Z")

</div>

> [@KZiemian](#):
>
> people must test its speed to believe

The problem is that they need to learn _something_ to be able to “test” Julia.

> [@KZiemian](#):
>
> newcomers can check few programs, which are written in bad way, see that they are not very fast, say “This high-performance is just BS” and go somewhere else.

I fail to see the problem with that. I can walk into the hardware store, buy the finest jigsaw and start using it without learning the basics, chop my fingers off, and blame the jigsaw. That will be my problem, and not someone else’s.

“Getting people on board” is a common fallacy of language evangelism. There is a benefit to having a larger community of _contributors_, but people who are superficial enough to make judgements like this may be a net liability anyway. The Julia language community is now large enough to be self-sustaining and produce high-quality packages on a natural, organic growth path.

> [@KZiemian](#):
>
> still much work to do in making people aware of this problem

To quote the [**second paragraph**](https://docs.julialang.org/en/v1/) of the manual,

> Because Julia’s compiler is different from the interpreters used for languages like Python or R, you may find that Julia’s performance is unintuitive at first. If you find that something is slow, we highly recommend reading through the [Performance Tips](https://docs.julialang.org/en/v1/manual/performance-tips/#man-performance-tips-1) section before trying anything else. Once you understand how Julia works, it’s easy to write code that’s nearly as fast as C.

I am not sure what else could be done. This may be one of those “you can lead a horse to water” problems, diminishing returns to effort are kicking in.

Members of the Julia community have a lot of cool things to work on at this point, so I am not sure that harping on this will be a priority. In fact, I am somewhat surprised that one can still trigger experts into what is effectively a free consulting/code optimization session just by making zero investment at learning the language and then claiming that “Julia is slow”. I am kind of wistfully looking forward to the day when “so go use Python” will be the standard answer to “Python is faster than Julia”.

---

<div class="post-metadata">

### Author: ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)
#### Post date: [March 15, 2020, 11:52am UTC](https://discourse.julialang.org/t/do-rules-for-good-problems-for-benchmarking-julia-exists/35900/7 "2020-03-15T11:52:55Z")

</div>

I would like to contribute my opinion as an HPC engineer here.  
Quite often I see microbenchmarkw discussed here - tight benchmarks with loops or individual functions.  
I agree with @tamaspass that real world application benchmarks are more relevant.  
(OK - optimisation of real codes comes down to finding those crucial loops or functions and optimising them)

The classic HPC cluster benchmark is HPL, which is a synthetic benchmark  
[https://www.netlib.org/benchmark/hpl/](https://www.netlib.org/benchmark/hpl/)  
The HPC community agree this is not a good predictor of real world performance, but it is what is used for Top500 comparisons and is generally a good method for stress/heat testign a system and weeding out faulty components.

Another popular benchmark suite is the NAS Parallel Benchmarks

> **[NAS Parallel Benchmarks](https://www.nas.nasa.gov/software/npb.html)**
>
> The NAS Parallel Benchmarks, or NPB, are a small set of programs designed to help evaluate the performance of parallel supercomputers. Developed by NAS Division experts, the benchmarks are used by high-performance computer manufacturers and HPC...

I guess no-one is going to recode benchmarks like this in Julia.  
I wonder though should there be a set of Julia codes which can be run to benchmark a clustered system?

---

<div class="post-metadata">

### Author: ![lungben](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lungben/32/12314_2.png) [@lungben](https://discourse.julialang.org/u/lungben)
#### Post date: [March 16, 2020, 7:39am UTC](https://discourse.julialang.org/t/do-rules-for-good-problems-for-benchmarking-julia-exists/35900/8 "2020-03-16T07:39:13Z")

</div>

I really like the benchmark used in this talk:

[![](https://global.discourse-cdn.com/julialang/original/3X/9/1/91a51b1e2124bae89f4e7b0350238ef403044102.jpeg "First steps with Julia for numerical computing - Bogumił Kamiński") ](https://www.youtube.com/watch?v=gaJorAU644o)

@bkamins uses an Asian option monte-carlo pricer for comparison of multiple languages. It is close to a micro-benchmark, but still a practically relevant use-case.

---

<div class="post-metadata">

### Author: ![KZiemian](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kziemian/32/9020_2.png) [@KZiemian](https://discourse.julialang.org/u/KZiemian)
#### Post date: [March 19, 2020, 2:21pm UTC](https://discourse.julialang.org/t/do-rules-for-good-problems-for-benchmarking-julia-exists/35900/9 "2020-03-19T14:21:40Z")

</div>

> [@Tamas\_Papp](#):
>
> In fact, I am somewhat surprised that one can still trigger experts into what is effectively a free consulting/code optimization session just by making zero investment at learning the language and then claiming that “Julia is slow”.

Yes, this is mind boggling that you can past "Julia is slow’’ here and you, Steven G. Johnson, etc., will respond in no time and for free. You are awesome, this is only explanation that I can found.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [March 19, 2020, 2:54pm UTC](https://discourse.julialang.org/t/do-rules-for-good-problems-for-benchmarking-julia-exists/35900/10 "2020-03-19T14:54:40Z")

</div>

Thanks for your kind words, but actually recently I have been staying away from the “Julia is slow because I didn’t read the manual” topics (especially ones which don’t strike the right tone) for the reasons explained above.
