[swift-evolution] Open Issues Affecting Standard Library API Stability

Dmitri Gribenko gribozavr at gmail.com
Wed Jul 6 20:26:02 CDT 2016


On Wed, Jul 6, 2016 at 6:15 PM, Karl <razielim at gmail.com> wrote:
>
> On 7 Jul 2016, at 02:06, Dmitri Gribenko <gribozavr at gmail.com> wrote:
>
> On Wed, Jul 6, 2016 at 4:21 AM, Karl <razielim at gmail.com> wrote:
>
> I had a PR open for this which added a Collection specialisation, but you
> said this could be handled in a more general way which allows for more
> optimised mutations. I’m curious how this would work; how does
> `RangeReplaceableCollection.replaceSubrange<S:Sequence>(range:, with: S)`
> call a more optimised implementation if S also conforms to Collection, if
> not by adding a specialisation?
>
>
> The RRC can call into S.someCustomizationPoint(), which will
> initialize a region of memory in the most efficient way possible,
> since it has complete knowledge about the memory layout of S.
>
> Dmitri
>
> --
> main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
> (j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
>
>
> Sorry, it’s been a little while since I looked at it
> (https://github.com/apple/swift/pull/3067). Actually, the issue is with the
> append() function specifically - it only has a Sequence specialisation.
> That’s the point; we were losing type information and not calling the more
> optimised replaceSubrange — which is exactly the specialisation point you
> are talking about, Dmitry (I think everything funnels down in to
> replaceSubrange).

I'm talking about a different customization point.  RRC.append() calls
RRC.replaceSubrange(), which, in our thinking, would call
S._copyContents(initializing: RRC.getInnerPointer()).  _copyContents()
is the customization point on the argument that would initialize
memory with the contents of the sequence.

> I must have misunderstood what you were saying at the time. I’ll have to
> test, but I think it’s still an issue. I thought there was some more general
> work on RRC planned, so when I saw the bullet I thought maybe that was it.

I will be sending a draft proposal soon that will indirectly fix this
performance issue.

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/


More information about the swift-evolution mailing list