-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Conversation
|
||
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
... 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. |
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 |
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 |
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.
Correct.
It does need the surrounding brackets, yes. |
The tone in the additions here is much better than it initially was, the grammar could still use a little bit of revision though. |
I agree, this is a much more pleasant read than before the changes. |
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. |
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. |
Can you squash these commits? I don't mind doing a cleanup on this branch and merging it. |
I think this text is just too long; I prefer the tips to be short and to the point. |
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. |
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. |
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 By the way, does the close of this issue imply that I do not need to work on this issue any more @JeffBezanson ? |
If you would like to squash this, and someone is willing to take a stab at revising it for grammar, try the following steps.
Whoever's willing to revise the grammar could probably do this themselves without too much trouble though. |
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. |
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.
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. |
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!).
maybe something like:
I think that would seem less confrontational, while still getting the message across... |
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. |
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.