• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Swift and Threads
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Swift and Threads


  • Subject: Re: Swift and Threads
  • From: Jens Alfke <email@hidden>
  • Date: Mon, 12 Sep 2016 21:29:31 -0700

> On Sep 12, 2016, at 9:21 PM, Gerriet M. Denkmann <email@hidden> wrote:
>
> READ of size 1776 at 0x61c0000e68a0 thread T0
>    #0 0x1000516f3 in wrap_memcpy (libclang_rt.asan_osx_dynamic.dylib+0x406f3)
>    #1 0x100f85a88 in __swift_memcpy_array1_1 (libswiftCore.dylib+0x1dea88)
>    #2 0x100dd9a3e in _TZFSa11_copyBufferfRGVs12_ArrayBufferx_T_ (libswiftCore.dylib+0x32a3e)
>    #3 0x100dd7495 in _TFSaap9subscriptFSix (libswiftCore.dylib+0x30495)

One of the writes is copying the array buffer, while presumably a bunch of other threads are trying to write to that buffer. Bad news.

Swift arrays are not thread-safe.

> When I use a [Bool] of size 1,000,000,000, the memory footprint goes up by more than 1 GB. Looks like Swift uses only one bit per byte.

The Bool type is one byte in size.

C++ has a specialization for std::vector<bool> that makes it a true bit array, but I’m not sure if Swift’s generic system is powerful enough to be able to entirely switch out the implementation based on the parameter type.

—Jens
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Swift and Threads
      • From: Alastair Houghton <email@hidden>
References: 
 >Swift and Threads (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: Swift and Threads (From: Jens Alfke <email@hidden>)
 >Re: Swift and Threads (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: Re: Swift and Threads
  • Next by Date: Re: Swift and Threads
  • Previous by thread: Re: Swift and Threads
  • Next by thread: Re: Swift and Threads
  • Index(es):
    • Date
    • Thread