Skip to content

InputMultispan and OutputMultispan + basic adoption in RigidArray and UniqueArray#579

Open
Catfish-Man wants to merge 38 commits intoapple:mainfrom
Catfish-Man:leeloo-dallas-multispan
Open

InputMultispan and OutputMultispan + basic adoption in RigidArray and UniqueArray#579
Catfish-Man wants to merge 38 commits intoapple:mainfrom
Catfish-Man:leeloo-dallas-multispan

Conversation

@Catfish-Man
Copy link
Copy Markdown
Member

@Catfish-Man Catfish-Man commented Feb 24, 2026

This gets us the core "asynchronously create a unique/rigid array with a multi output span"

Co-authored-by: Guillaume Lessard <glessard@tffenterprises.com>
@safe
@frozen
@available(SwiftStdlib 5.0, *)
public struct OutputMultispan<Element: ~Copyable>: ~Copyable, ~Escapable {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would be interesting to see if we could add a conversion method that vends you an io_vec from this safely

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ooh that would be nice

@Catfish-Man Catfish-Man changed the title WIP OutputMultispan + basic adoption in RigidArray and UniqueArray WIP InputMultispan and OutputMultispan + basic adoption in RigidArray and UniqueArray Feb 26, 2026
@Catfish-Man Catfish-Man changed the title WIP InputMultispan and OutputMultispan + basic adoption in RigidArray and UniqueArray InputMultispan and OutputMultispan + basic adoption in RigidArray and UniqueArray Mar 11, 2026
@Catfish-Man Catfish-Man marked this pull request as ready for review March 13, 2026 20:50
@Catfish-Man
Copy link
Copy Markdown
Member Author

I'll take a look at any CI failures, the tests pass locally so they're probably just forgetting to update one of the other build systems


// Shift elements after the subrange if necessary
let shiftDistance = addedCount
if shiftDistance != 0 && subrange.upperBound < count {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It looks like this code accounts for the possibility of multiple inline elements, but line 145 above assumes the presence of only a single inline element. Should they be made consistent?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I really want to generalize the rest of it to support multiple inline elements, but I haven't decided how practical that is. Picking one option definitely seems good though.

#endif

@frozen @usableFromInline
internal struct MultispanBuffer<Element: ~Copyable> {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

NIT: Do you want to keep these shared internal types in this file our should we move them into a separate file?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think if they grow any further functionality they should probably move, but for the moment I'm fine with leaving them there

@Catfish-Man
Copy link
Copy Markdown
Member Author

Windows failures are a CI issue:

failed to connect to the docker API at npipe:////./pipe/docker_engine; check if the path is correct and if the daemon is running: open //./pipe/docker_engine: The system cannot find the file specified.

@lorentey
Copy link
Copy Markdown
Member

The Windows failures are there to gently remind us that we exist to serve CI, not the other way around -- rerunning the failing jobs usually makes them pass. ¯\_(ツ)_/¯

- Move the multispan types to the BasicContainers module, as they currently depend on UniqueArray
- Underscore MultispanBuffer and SmallBufferPointerArray
- @Lifetime → @_lifetime
- Stop using @testable
@lorentey
Copy link
Copy Markdown
Member

I added a commit to make the PR build in package form -- however, the tests are crashing right now.

@Catfish-Man
Copy link
Copy Markdown
Member Author

This looks unrelated to my change…

~/swift-collections[leeloo-dallas-multispan]> swift build -Xswiftc -DCOLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
[1/1] Planning build
Building for debugging...
/Users/david/swift-collections/Sources/ContainersPreview/Protocols/Container/RangeReplaceableContainer.swift:398:13: error: lifetime-dependent variable 'items' escapes its scope
396 |   @inlinable
397 |   public mutating func append(
398 |     copying items: Span<Element>
    |             |- error: lifetime-dependent variable 'items' escapes its scope
    |             `- note: it depends on the lifetime of argument 'items'
399 |   ) {
400 |     guard !items.isEmpty else { return }
401 |     var items = items
    |                 `- note: this use causes the lifetime-dependent value to escape

@Catfish-Man
Copy link
Copy Markdown
Member Author

aaaand trying to test locally crashes swift test

[229/242] Compiling _RopeModule Rope+MutatingForEach.swift
error: fatalError

@Catfish-Man
Copy link
Copy Markdown
Member Author

Run xcrun swift --version
xcrun: error: missing DEVELOPER_DIR path: /Applications/Xcode_26.4.b2.app
Error: Process completed with exit code 1.

So helpful

@shahmishal
Copy link
Copy Markdown
Member

@Catfish-Man You will need to rebase your change to pull in #615

@Catfish-Man
Copy link
Copy Markdown
Member Author

Android failure is

/home/runner/.config/swiftpm/swift-sdks/swift-DEVELOPMENT-SNAPSHOT-2026-04-01-a_android.artifactbundle/swift-android/swift-resources/usr/lib/swift-aarch64/clang/include/module.modulemap:10:8: error: redefinition of module '_Builtin_intrinsics'

Windows is

failed to connect to the docker API at npipe:////./pipe/docker_engine; check if the path is correct and if the daemon is running: open //./pipe/docker_engine: The system cannot find the file specified.

Linux hashed containers is

error: SwiftCompile normal x86_64 /__w/swift-collections/swift-collections/Sources/HashTreeCollections/HashNode/_AncestorHashSlots.swift failed with a nonzero exit code. Command line:     cd /__w/swift-collections
    builtin-SwiftPerFileCompile _AncestorHashSlots.swift

etc…

Linux containers is

error: SwiftCompile normal x86_64 /__w/swift-collections/swift-collections/Sources/HeapModule/Heap+Invariants.swift failed with a nonzero exit code. Command line:     cd /__w/swift-collections

etc…

@lorentey lorentey added this to the 1.4.2 milestone Apr 4, 2026
@lorentey lorentey force-pushed the leeloo-dallas-multispan branch from e9f8d83 to 2e1f550 Compare April 7, 2026 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants