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

fix #23107, ensure Array constructor always makes new arrays #23490

Merged
merged 1 commit into from
Aug 30, 2017

Conversation

JeffBezanson
Copy link
Sponsor Member

@JeffBezanson JeffBezanson commented Aug 28, 2017

Fix #23107.

@JeffBezanson JeffBezanson added arrays [a, r, r, a, y, s] breaking This change will break code collections Data structures holding multiple items, e.g. sets labels Aug 28, 2017
@fredrikekre
Copy link
Member

@nanosoldier runbenchmarks(ALL, vs=":master")

@nanosoldier
Copy link
Collaborator

Something went wrong when running your job:

NanosoldierError: failed to run benchmarks against primary commit: failed process: Process(`sudo cset shield -e su nanosoldier -- -c ./benchscript.sh`, ProcessExited(1)) [1]

Logs and partial data can be found here
cc @ararslan

@JeffBezanson
Copy link
Sponsor Member Author

@nanosoldier runbenchmarks(ALL, vs=":master")

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

@carlobaldassi
Copy link
Member

We should have the same change applied to BitArrays too, for consistency.
(Currently, BitArray(::BitArray) just falls back to convert, here.)

@@ -563,6 +563,12 @@ convert(::Type{Array{T,n}}, x::AbstractArray{S,n}) where {T,n,S} = copy!(Array{T

promote_rule(a::Type{Array{T,n}}, b::Type{Array{S,n}}) where {T,n,S} = el_same(promote_type(T,S), a, b)

# constructors should make copies
Copy link
Member

@nalimilan nalimilan Aug 29, 2017

Choose a reason for hiding this comment

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

Is this documented somewhere? This is something I wondered when writing CategoricalArrays contructors. Since one-argument constructors fall back to convert, by default they do not make copies. I agree it would make sense for convertnot to make a copy and for constructors to make a copy, but this should be stated clearly in the manual. Then we should review other types in Base (and in our packages) to check that this rule is followed consistently (not only for arrays).

EDIT: Sorry, I had missed the discussion at #23107. I agree with the conclusion there, so this is just a request to document this behavior instead of just silently doing it. :-)

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

I'll re-do the manual entries on convert and construct as part of #15120. In progress in #23273.

@JeffBezanson
Copy link
Sponsor Member Author

I looked into the apparent memory increase in the remotecall benchmarks, but that code doesn't seem to hit the new methods here.

@JeffBezanson JeffBezanson merged commit 9c6e496 into master Aug 30, 2017
@JeffBezanson JeffBezanson deleted the jb/Arrayctor branch August 30, 2017 20:29
@JeffBezanson
Copy link
Sponsor Member Author

There are possible remaining cases for SharedArray and IOBuffer here. However, there aren't any constructors and conversions for SharedArray(::SharedArray) currently, so the only matching method is the fallback identity conversion (unlike for Arrays, where whether a copy was made depended on whether the type was different). That will be removed with #15120, and then we can separately decide whether those types should have copy constructors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrays [a, r, r, a, y, s] breaking This change will break code collections Data structures holding multiple items, e.g. sets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants