Skip to content
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

Update the Performance Tip doc #11077

Closed
wants to merge 1 commit into from
Closed

Conversation

Sisyphuss
Copy link

Current performance tips (TIPS) is not very pedagogical. So I rewrite a part of TIPS to make it more understandable. The change includes rewriting the motivation (at the beginning), adding section "why Julia can be fast", rewrite section "avoid global variables" as "be cautious to the use of global variables, especially in a loop". Numerous examples and intuitions are provided.


julia> x = 1.0
Though a constant-value variable may be a bit restricted -- all we need here is a "constant-type variable", this "constant-type variable", however, is not available currently. Though in the local scope, it is allowed to write ``x::Int = 1`` to restrict the type of a local variable, in the global scope, it is not allowed. The good news is that "constant-type variable" is a planned feature in future Julia version. Needless to say, it will be a powerful tool to improve the speed when using global variables.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to remove the trailing whitespace here, otherwise Travis will fail.

@@ -6,47 +6,126 @@
Performance Tips
******************

In the following sections, we briefly go through a few techniques that
can help make your Julia code run as fast as possible.
Many users are attracted to use Julia mainly because they were told Julia is fast. However, what they were not told is that why Julia is fast. Despite of the lack of this knowledge, they drafted some Julia code in a hurry, and ended up finding that it was even slower than the Python equivalent. Then, they became skeptic and complained it in the [Julia-user](https://groups.google.com/forum/#!forum/julia-users) mailing list. Generally, with the help of Julia team, their doubt got solved quickly.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not include this paragraph.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Seems unhelpful, accusatory, and discouraging.

@stevengj
Copy link
Member

stevengj commented May 1, 2015

It would be more helpful if you did not mix constructive improvements and examples with rants, gripes, and snark.

Why Julia *can* be fast
-----------------

The first thing is to understand why Julia *can* be fast. This is the basic to understand all following sections. Simply put, Julia is fast if and only if the binary generated by Julia compiler is efficient. While there are various compiling techniques to help generate efficient binary, the Julia compiler currently uses only one: *infer the runtime type*. And simply by employing this technique, Julia is already able to achieve nearly C/Fortran speed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inflammatory and inaccurate; there are many optimization techniques employed by Julia and LLVM. Of course, type inference is a crucial one — no performance-critical code in any language can be compiled to efficient machine instructions if types cannot be detected and some point prior to final execution.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're curious, @Sisyphuss, check out #3440. It's worth noting that some boxes not checked are already largely in place.

@Sisyphuss
Copy link
Author

... Someone can tell me why I didn't pass the appveyor check? Is it because I edited it in LibreOffice ant then copy-paste it?

The "Detail" says that "build has been cancelled by user." But I don't remember I have done anything about it.

@tkelman
Copy link
Contributor

tkelman commented May 16, 2015

Someone probably manually cancelled the build. Since this is documentation-only there are no platform differences here and it's not worth wasting 45 minutes of queue time to run on AppVeyor. That's why we ask contributors to add [av skip] somewhere in the commit message for doc-only commits, though it doesn't look like I've written that down in CONTRIBUTING.md yet.

@Sisyphuss
Copy link
Author

So appveyor is to check whether it can run in different platform (Windows, Mac OS, Linux, etc.)? So there isn't any fault on my side?

By the way, if I'd like to add av skip, should I include the blanket []?

@tkelman
Copy link
Contributor

tkelman commented May 17, 2015

So appveyor is to check whether it can run in different platform (Windows, Mac OS, Linux, etc.)?

AppVeyor is for Windows. Travis is for Linux. Travis can test on Mac OS as well but we currently have that disabled because it was timing out frequently.

So there isn't any fault on my side?

Correct.

By the way, if I'd like to add av skip, should I include the blanket []?

It does need the surrounding brackets, yes. [av skip] can be anywhere in the commit message though.

@tkelman
Copy link
Contributor

tkelman commented May 19, 2015

The tone in the additions here is much better than it initially was, the grammar could still use a little bit of revision though.

@KristofferC
Copy link
Member

I agree, this is a much more pleasant read than before the changes.

@timholy
Copy link
Member

timholy commented May 19, 2015

Agreed. With regards to the grammar, I think a native speaker should tackle that; it's not efficient to expect a non-native speaker to produce perfect prose. Either we could merge this as is and then polish it, or someone could submit a PR against his branch.

@Sisyphuss
Copy link
Author

Please feel free to correct my linguistic faults. I am open to listen to different voices. This will also help me to better master the language of Shakespeare. And I will also prove that I live up to your expectations.

@ViralBShah
Copy link
Member

Can you squash these commits? I don't mind doing a cleanup on this branch and merging it.

@ViralBShah ViralBShah added the docs This change adds or pertains to documentation label May 20, 2015
@JeffBezanson
Copy link
Member

I think this text is just too long; I prefer the tips to be short and to the point.

@tkelman
Copy link
Contributor

tkelman commented May 28, 2015

The examples are nice to have here, and if more elaboration on this leads to more people figuring out the common pitfalls on their own without having to go to the mailing list (or giving up before that) then it's a good thing IMO.

@timholy
Copy link
Member

timholy commented May 28, 2015

If "performance tips" isn't the right place, how about putting it in the FAQ and inserting a link from here? Overall, I'd say "too much documentation" is not high on the list of julia's problems.

@Sisyphuss
Copy link
Author

I'm sorry for my lateness. I was too occupied.

Concerning the "squash", I haven't figured out how to do that. My local Julia build's source code is downloaded via the official repo, while this doc improvement obviously has nothing to do with my local build. Therefore, I do not know how to do rebase as various git help docs suggest.

By the way, does the close of this issue imply that I do not need to work on this issue any more @JeffBezanson ?

@tkelman tkelman reopened this Jun 15, 2015
@tkelman
Copy link
Contributor

tkelman commented Jun 15, 2015

If you would like to squash this, and someone is willing to take a stab at revising it for grammar, try the following steps.

# Make a new clone from your fork
git clone https://github.com/Sisyphuss/julia julia-Sisyphuss
cd julia-Sisyphuss
git remote add Sisyphuss https://github.com/Sisyphuss/julia
git remote add JuliaLang https://github.com/JuliaLang/julia
git fetch JuliaLang
git rebase -i JuliaLang/master
# change all commits except the first one to squash
# review `git log`, and `git diff HEAD~ HEAD` carefully
# to ensure you only have one commit with the latest content
# if you like the content, do
git push Sisyphuss +master

Whoever's willing to revise the grammar could probably do this themselves without too much trouble though.

@JeffBezanson
Copy link
Member

Mostly the problem is that the text is too long, and uses unnecessarily loaded and adversarial language, e.g. mentioning "competitors" and "claimed" properties. None of that is relevant. All we need to do here is simply explain what to write and what not to write. This text has numerous problems beyond grammar; the grammar is not so bad.

@tkelman
Copy link
Contributor

tkelman commented Jun 15, 2015

This part of the documentation could really use more elaboration. From the mailing list, stack overflow, and naively written Julia code out in the wild, many performance behaviors remain highly unintuitive and difficult for new users to grasp. That's going to remain the case as long as the documentation stays overly concise.

Current performance tips (TIPS) is not very pedagogical. So I rewrite a part of TIPS to make it more understandable.
The change includes rewriting the motivation (at the beginning), adding section "why Julia can be fast", rewrite section "avoid global variables" as "be cautious to the use of global variables, especially in a loop".
Numerous examples and intuitions are provided.
@Sisyphuss
Copy link
Author

The major problem of the current performance tips is: it looks more like a memo for skillful developers than a help document for new beginners. For the sake of pedagogy, more elaborated paragraphs are needed. Besides, when I rewrote this document, I was always thinking about my target readers--who are likely to read this chapter. Those who care about performance are most likely to turn to Julia simply for its high speed (instead of other innovations), so naturally they will be critical and compare Julia with other languages (at the speed aspect). Therefore, my language is not "loaded and adversarial" as @JeffBezanson mentioned, but just tailored to the potential readers.

@ScottPJones
Copy link
Contributor

I agree with @JeffBezanson that the first paragraph should be reworked a bit, I was exactly one of those newcomers to Julia two months ago, compared it to C and Python, got bad results, but persisted even so, because of the promise I saw in Julia (or because I'm incredibly stubborn, take your pick!).
Instead of

Some users reported that their Julia programs did not run as fast as expected, maybe even slower than their Python counterparts, contrast to the high performance claimed of Julia project. However, this inefficiency is largely due to the failure of conformity with the Julia programming norm. To help users better benefit from the high performance of Julia, this page presents some tips, by following which, users may see a significant speed-up (around 100x ~ 1000x) in their programs.

maybe something like:

In order to achieve the high performance which is possible in Julia, achieving the speed of C and Fortran code, with much less code, it is often necessary to change the way things are coded compared to other languages, to take advantage of the type inference analysis and multiple dispatch features of Julia.
This page presents a number of tips, which when followed, can often help users achieve many orders of magnitude improvement in the speed of their programs.

I think that would seem less confrontational, while still getting the message across...

@quinnj
Copy link
Member

quinnj commented May 9, 2016

Stale Doc PR; seems like there's some consensus around cleaning up the performance tips a bit, but with the goal of still keeping the language simple and to the point.

@quinnj quinnj closed this May 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.