-
-
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
Minor Array constructor tweaks #14441
Conversation
Previously, `Array{Int}((1,))` would allocate a tuple in order to `ccall` the array constructor, but `Array{Int}(1)` would not. This simplifies the constructors so tuple allocations aren't necessary for either formulation up to 3 dimensions.
This now allows constructs such as `Array{Int,3}(1,2,3)` and `Matrix{Int}((1,2))`.
Ref #14201 |
Hah, thanks, I hadn't seen that. I'd prefer to not implement the 0-argument forms… in fact I almost deprecated them. But I think that should be done separately. |
I don't really like the 0-argument form either but it seems that this PR basically implements what I mentioned in #14201 (comment) ? |
Yes, the second commit here enables all permutations of ( There are still two flavors of constructor that are only supported for
And then there's the old |
Seems ok to me, but I don't fully understand the efficiency issue. Where was the extra tuple getting allocated? The new definitions seem to always need tuples. One hopes they'll usually be inlined away, but this seems to increase the chances a tuple will be allocated. |
|
Whoa, amazing work @jrevels! 😲 💯 https://github.com/JuliaCI/BaseBenchmarkReports/blob/master/f369166/f369166_vs_01df9b1.md It looks like it's comparing my 18-day old branch to the current master tip. Is that the case? Would it re-run if I rebase? Or is there a way to run the benchmarks between master and the result of merging this branch? |
Yeah PR's should probably be fetching the merge commit rather than the branch. See the first few lines of what Travis and AppVeyor do. |
In the meantime, you could also compare against the parent commit (b33c4bd). |
That's some seriously cool stuff @jrevels! |
You'd have to manually submit a new job via a new comment. It would be cool to be able to re-trigger jobs without adding noisey comments, though I'd still want it to be a manual resubmission...
This sounds like a good idea! Can you point me to the script(s) you're mentioning here? I'm assuming it just does a merge in the local clone and builds from that? |
Just the first couple lines of the build log:
|
Ah, that makes sense, thanks! |
Just deployed the change that @tkelman suggested; let's try this again, shall we?
We don't yet have constructor benchmarks in BaseBenchmarks.jl, so in theory the report should show that this PR's performance matches master's. |
Looks like this approach won't work with the array constructors now appearing so early in bootstrap (getindex isn't defined yet, so we can't reference tuple elements). I'm going to close this; I don't particularly feel like fighting my way through the bootstrap issues to update this. |
This removes an unnecessary tuple allocation when constructing 1-3 dimensional arrays with a single tuple argument. Notably, this is the form that ends up getting called by
similar
. Before:After:
While I was there, I also cleaned up the constructor functions themselves a bit, such that the fully-parametrized Array{T,N} was the final endpoint. It makes things simpler and a bit more consistent; before constructs like
Array{Int,3}(1,2,3)
andMatrix{Int}((1,2))
were missing method errors… but you might expect them to work.