-
-
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
RFC: Speed up partitions(n), partitions(n,m) iteration #4136
Conversation
* Reuse output array * Specialize IntegerPartitions, FixedPartitions based on whether or not to copy * Specialize collect() to always copy * Reduce memory allocation
I should allow Bools as type parameters. I think the |
@JeffBezanson, this was somewhat in response to @StefanKarpinski's comment in https://groups.google.com/forum/#!searchin/julia-users/counter$20collect/julia-users/b_W8Do8PxJw/nK-nNoYVDDUJ, regarding the comparison of the Counter
Okay, Is it really possible to improve the GC so that explicitly allocating an iteration array each iteration (which the current code does) is as fast as modifying the same array, as is done in this patch? |
Matlab's JIT does often manage to do just that (the pressure to do this in Matlab is much greater since you can't mutate arrays in place except by dropping into C). I believe the plan is to use a bit in the type tag to do approximate reference counting, coupled with some escape analysis to determine in many cases that memory can be reused safely. See #261. |
I would say mutating the iteration state is somewhat ok, but not an array
|
I've renamed the functions. What do you recommend with this patch, then? Some options include
I'm fine with any of these. |
Unfortunately 3 is the only option. If we did 1, we would have to specialize untold other functions as well. |
@kmsquire, sorry if I egged you on in an unproductive direction. |
No worries! There are actually a couple of small optimizations that I discovered while doing this that still work with the current behavior. I'll submit those separately. |
Stdlib: Pkg URL: https://github.com/JuliaLang/Pkg.jl.git Stdlib branch: master Julia branch: master Old commit: bc9fb21b1 New commit: 6091533bc Julia version: 1.12.0-DEV Pkg version: 1.12.0 Bump invoked by: @KristofferC Powered by: [BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl) Diff: JuliaLang/Pkg.jl@bc9fb21...6091533 ``` $ git log --oneline bc9fb21b1..6091533bc 6091533bc fix ambiguity in apps `rm` (#4144) ecdf6aa38 rename rot13 app in test to avoid name conflicts on systems where such a binary is already installed (#4143) a3626bf29 add `PREV_ENV_PATH` to globals getting reset and move the reset to before precompilation is finished instead of `__init__` (#4142) 938e9b24e app support in Pkg (#3772) df1931a93 Use copy_test_packages in some places, and ensure that the copied test package is user writable. This allows running the Pkg tests as part of Base.runtests of an installed Julia installation, where sources might be readonly. (#4136) 2609a9411 don't set up callbacks if using cli git (#4128) ``` Co-authored-by: KristofferC <1282691+KristofferC@users.noreply.github.com>
IntegerPartitions
,FixedPartitions
based on whether or not to copycollect()
to always copyThe speed of
collect()
hasn't changed much, and iterating withfor
is about 4x as fast as usingcollect()
I was wondering if I could specialize types using
Bools
directly (you can't), so I'm specializing using