Skip to content

Commit

Permalink
Merge branch 'main' into base_socket_crash
Browse files Browse the repository at this point in the history
  • Loading branch information
rnro authored Oct 29, 2024
2 parents 2873a73 + 411c2c5 commit 7bb69ad
Show file tree
Hide file tree
Showing 121 changed files with 1,649 additions and 605 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ on:
description: "Boolean to enable the Linux nightly main Swift version matrix job. Defaults to true."
default: true

windows_6_0_enabled:
type: boolean
description: "Boolean to enable the Windows 6.0 Swift version matrix job. Defaults to true."
default: false
windows_nightly_6_0_enabled:
type: boolean
description: "Boolean to enable the Windows nightly 6.0 Swift version matrix job. Defaults to true."
default: false
windows_nightly_main_enabled:
type: boolean
description: "Boolean to enable the Windows nightly main Swift version matrix job. Defaults to true."
default: false

jobs:
benchmarks:
name: Benchmarks
Expand All @@ -44,3 +57,6 @@ jobs:
matrix_linux_6_0_enabled: ${{ inputs.linux_6_0_enabled }}
matrix_linux_nightly_6_0_enabled: ${{ inputs.linux_nightly_6_0_enabled }}
matrix_linux_nightly_main_enabled: ${{ inputs.linux_nightly_main_enabled }}
matrix_windows_6_0_enabled: ${{ inputs.windows_6_0_enabled }}
matrix_windows_nightly_6_0_enabled: ${{ inputs.windows_nightly_6_0_enabled }}
matrix_windows_nightly_main_enabled: ${{ inputs.windows_nightly_main_enabled }}
16 changes: 16 additions & 0 deletions .github/workflows/cxx_interop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ on:
description: "Boolean to enable the Linux nightly main Swift version matrix job. Defaults to true."
default: true

windows_6_0_enabled:
type: boolean
description: "Boolean to enable the Windows 6.0 Swift version matrix job. Defaults to true."
default: false
windows_nightly_6_0_enabled:
type: boolean
description: "Boolean to enable the Windows nightly 6.0 Swift version matrix job. Defaults to true."
default: false
windows_nightly_main_enabled:
type: boolean
description: "Boolean to enable the Windows nightly main Swift version matrix job. Defaults to true."
default: false

jobs:
cxx-interop:
name: Cxx interop
Expand All @@ -37,3 +50,6 @@ jobs:
matrix_linux_6_0_enabled: ${{ inputs.linux_6_0_enabled }}
matrix_linux_nightly_6_0_enabled: ${{ inputs.linux_nightly_6_0_enabled }}
matrix_linux_nightly_main_enabled: ${{ inputs.linux_nightly_main_enabled }}
matrix_windows_6_0_enabled: ${{ inputs.windows_6_0_enabled }}
matrix_windows_nightly_6_0_enabled: ${{ inputs.windows_nightly_6_0_enabled }}
matrix_windows_nightly_main_enabled: ${{ inputs.windows_nightly_main_enabled }}
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
with:
linux_5_9_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_5_10_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
with:
linux_5_9_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_5_10_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
with:
linux_5_9_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_5_10_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/swift_6_language_mode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
uses: actions/checkout@v4
with:
persist-credentials: false
submodules: true
- name: Set the language mode
run: swift package tools-version --set 6.0
- name: Build with Swift 6 language mode
Expand Down
87 changes: 87 additions & 0 deletions .github/workflows/swift_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,32 @@ on:
type: string
description: "The command of the nightly main Swift version linux matrix job to execute."

matrix_windows_command:
type: string
description: "The command of the current Swift version windows matrix job to execute."
default: ""
matrix_windows_6_0_enabled:
type: boolean
description: "Boolean to enable the 6.0 Swift version matrix job. Defaults to true."
default: false
matrix_windows_6_0_command_override:
type: string
description: "The command of the 6.0 Swift version windows matrix job to execute."
matrix_windows_nightly_6_0_enabled:
type: boolean
description: "Boolean to enable the nightly 6.0 Swift version matrix job. Defaults to true."
default: false
matrix_windows_nightly_6_0_command_override:
type: string
description: "The command of the nightly 6.0 Swift version windows matrix job to execute."
matrix_windows_nightly_main_enabled:
type: boolean
description: "Boolean to enable the nightly main Swift version matrix job. Defaults to true."
default: false
matrix_windows_nightly_main_command_override:
type: string
description: "The command of the nightly main Swift version windows matrix job to execute."

# We are cancelling previously triggered workflow runs
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.name }}
Expand Down Expand Up @@ -104,6 +130,7 @@ jobs:
uses: actions/checkout@v4
with:
persist-credentials: false
submodules: true
- name: Mark the workspace as safe
if: ${{ matrix.swift.enabled }}
# https://github.com/actions/checkout/issues/766
Expand All @@ -121,3 +148,63 @@ jobs:
run: |
apt-get -qq update && apt-get -qq -y install curl
curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-matrix-job.sh | bash
windows:
name: Windows (${{ matrix.swift.swift_version }})
runs-on: windows-2022
strategy:
fail-fast: false
matrix:
# We are specifying only the major and minor of the docker images to automatically pick up the latest patch release
swift:
- image: swift:6.0-windowsservercore-ltsc2022
swift_version: "6.0"
enabled: ${{ inputs.matrix_windows_6_0_enabled }}
steps:
- name: Pull Docker image
if: ${{ matrix.swift.enabled }}
run: docker pull ${{ matrix.swift.image }}
- name: Checkout repository
if: ${{ matrix.swift.enabled }}
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Donwload matrix script
if: ${{ matrix.swift.enabled }}
run: curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-matrix-job.ps1 -o __check-matrix-job.ps1
- name: Run matrix job
if: ${{ matrix.swift.enabled }}
run: |
docker run --env SWIFT_VERSION="${{ matrix.swift.swift_version }}" --env COMMAND="${{ inputs.matrix_windows_command }}" --env COMMAND_OVERRIDE_6_0="${{ inputs.matrix_windows_6_0_command_override }}" -v ${{ github.workspace }}:C:\source ${{ matrix.swift.image }} cmd /s /c "swift --version & cd C:\source\ & powershell -File __check-matrix-job.ps1"
windows-nightly:
name: Windows (${{ matrix.swift.swift_version }})
runs-on: windows-2019
strategy:
fail-fast: false
matrix:
# We are specifying only the major and minor of the docker images to automatically pick up the latest patch release
swift:
- image: swiftlang/swift:nightly-6.0-windowsservercore-1809
swift_version: "nightly-6.0"
enabled: ${{ inputs.matrix_windows_nightly_6_0_enabled }}
- image: swiftlang/swift:nightly-main-windowsservercore-1809
swift_version: "nightly-main"
enabled: ${{ inputs.matrix_windows_nightly_main_enabled }}
steps:
- name: Pull Docker image
if: ${{ matrix.swift.enabled }}
run: docker pull ${{ matrix.swift.image }}
- name: Checkout repository
if: ${{ matrix.swift.enabled }}
uses: actions/checkout@v4
with:
persist-credentials: false
submodules: true
- name: Donwload matrix script
if: ${{ matrix.swift.enabled }}
run: curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-matrix-job.ps1 -o __check-matrix-job.ps1
- name: Run matrix job
if: ${{ matrix.swift.enabled }}
run: |
docker run --env SWIFT_VERSION="${{ matrix.swift.swift_version }}" --env COMMAND="${{ inputs.matrix_windows_command }}" --env COMMAND_OVERRIDE_NIGHTLY_6_0="${{ inputs.matrix_windows_nightly_6_0_command_override }}" --env COMMAND_OVERRIDE_NIGHTLY_MAIN="${{ inputs.matrix_windows_nightly_main_command_override }}" -v ${{ github.workspace }}:C:\source ${{ matrix.swift.image }} cmd /s /c "swift --version & cd C:\source\ & powershell -File __check-matrix-job.ps1"
32 changes: 32 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,31 @@ on:
description: "The arguments passed to swift test in the Linux nightly main Swift version matrix job."
default: ""

windows_6_0_enabled:
type: boolean
description: "Boolean to enable the Windows 6.0 Swift version matrix job. Defaults to true."
default: false
windows_6_0_arguments_override:
type: string
description: "The arguments passed to swift test in the Windows 6.0 Swift version matrix job."
default: ""
windows_nightly_6_0_enabled:
type: boolean
description: "Boolean to enable the Windows nightly 6.0 Swift version matrix job. Defaults to true."
default: false
windows_nightly_6_0_arguments_override:
type: string
description: "The arguments passed to swift test in the Windows nightly 6.0 Swift version matrix job."
default: ""
windows_nightly_main_enabled:
type: boolean
description: "Boolean to enable the Windows nightly main Swift version matrix job. Defaults to true."
default: false
windows_nightly_main_arguments_override:
type: string
description: "The arguments passed to swift test in the Windows nightly main Swift version matrix job."
default: ""

jobs:
unit-tests:
name: Unit tests
Expand All @@ -62,3 +87,10 @@ jobs:
matrix_linux_nightly_6_0_command_override: "swift test ${{ inputs.linux_nightly_6_0_arguments_override }}"
matrix_linux_nightly_main_enabled: ${{ inputs.linux_nightly_main_enabled }}
matrix_linux_nightly_main_command_override: "swift test ${{ inputs.linux_nightly_main_arguments_override }}"
matrix_windows_command: "swift test"
matrix_windows_6_0_enabled: ${{ inputs.windows_6_0_enabled }}
matrix_windows_6_0_command_override: "swift test ${{ inputs.windows_6_0_arguments_override }}"
matrix_windows_nightly_6_0_enabled: ${{ inputs.windows_nightly_6_0_enabled }}
matrix_windows_nightly_6_0_command_override: "swift test ${{ inputs.windows_nightly_6_0_arguments_override }}"
matrix_windows_nightly_main_enabled: ${{ inputs.windows_nightly_main_enabled }}
matrix_windows_nightly_main_command_override: "swift test ${{ inputs.windows_nightly_main_arguments_override }}"
29 changes: 29 additions & 0 deletions Benchmarks/Benchmarks/NIOCoreBenchmarks/Benchmarks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ let benchmarks = {
.mallocCountTotal
]

let leakMetrics: [BenchmarkMetric] = [
.mallocCountTotal,
.memoryLeaked,
]

Benchmark(
"NIOAsyncChannel.init",
configuration: .init(
Expand All @@ -46,4 +51,28 @@ let benchmarks = {
blackHole(asyncChanel)
}
}

Benchmark(
"WaitOnPromise",
configuration: .init(
metrics: leakMetrics,
scalingFactor: .kilo,
maxDuration: .seconds(10_000_000),
maxIterations: 10_000 // need 10k to get a signal
)
) { benchmark in
// Elide the cost of the 'EmbeddedEventLoop'.
let el = EmbeddedEventLoop()

benchmark.startMeasurement()
defer {
benchmark.stopMeasurement()
}

for _ in 0..<benchmark.scaledIterations.count {
let p = el.makePromise(of: Int.self)
p.succeed(0)
do { _ = try! p.futureResult.wait() }
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"mallocCountTotal" : 6000,
"memoryLeaked" : 0
}
3 changes: 0 additions & 3 deletions Benchmarks/Thresholds/5.8/NIOPosixBenchmarks.TCPEcho.p90.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"mallocCountTotal" : 6000,
"memoryLeaked" : 0
}
3 changes: 3 additions & 0 deletions Benchmarks/Thresholds/6.0/NIOPosixBenchmarks.TCPEcho.p90.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"mallocCountTotal" : 548
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"mallocCountTotal" : 164376
}
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ The default policy for taking contributions is “Squash and Merge” - because

### Make sure your patch works for all supported versions of swift

The CI will do this for you, but a project maintainer must kick it off for you. Currently all versions of Swift >= 5.8 are supported.
The CI will do this for you, but a project maintainer must kick it off for you. Currently all versions of Swift >= 5.9 are supported.

If you wish to test this locally you have two options [act](https://github.com/nektos/act) and Docker Compose files.

Expand Down
13 changes: 5 additions & 8 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.8
// swift-tools-version:5.9
//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftNIO open source project
Expand All @@ -21,11 +21,7 @@ import class Foundation.ProcessInfo

let swiftAtomics: PackageDescription.Target.Dependency = .product(name: "Atomics", package: "swift-atomics")
let swiftCollections: PackageDescription.Target.Dependency = .product(name: "DequeModule", package: "swift-collections")
let swiftSystem: PackageDescription.Target.Dependency = .product(
name: "SystemPackage",
package: "swift-system",
condition: .when(platforms: [.macOS, .iOS, .tvOS, .watchOS, .linux, .android])
)
let swiftSystem: PackageDescription.Target.Dependency = .product(name: "SystemPackage", package: "swift-system")

// These platforms require a depdency on `NIOPosix` from `NIOHTTP1` to maintain backward
// compatibility with previous NIO versions.
Expand Down Expand Up @@ -259,7 +255,8 @@ let package = Package(
.target(
name: "_NIOFileSystemFoundationCompat",
dependencies: [
"_NIOFileSystem"
"_NIOFileSystem",
"NIOFoundationCompat",
],
path: "Sources/NIOFileSystemFoundationCompat"
),
Expand Down Expand Up @@ -557,7 +554,7 @@ if Context.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
package.dependencies += [
.package(url: "https://github.com/apple/swift-atomics.git", from: "1.1.0"),
.package(url: "https://github.com/apple/swift-collections.git", from: "1.0.2"),
.package(url: "https://github.com/apple/swift-system.git", from: "1.2.0"),
.package(url: "https://github.com/apple/swift-system.git", from: "1.4.0"),
]
} else {
package.dependencies += [
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ This is the current version of SwiftNIO and will be supported for the foreseeabl
### Swift Versions

We commit to support the most recently released swift version (currently 5.10) and the last two minor releases before that unless this is impossible to do in one codebase.
In addition checks are run against the latest beta release (if any) as well as the nightly swift builds and the intent is that these should pass.
In addition checks are run against the latest beta release (if any) as well as the nightly swift builds and the intent is that these should pass.

The most recent versions of SwiftNIO support Swift 5.8 and newer. The minimum Swift version supported by SwiftNIO releases are detailed below:
The most recent versions of SwiftNIO support Swift 5.9 and newer. The minimum Swift version supported by SwiftNIO releases are detailed below:

SwiftNIO | Minimum Swift Version
--------------------|----------------------
Expand All @@ -86,7 +86,8 @@ SwiftNIO | Minimum Swift Version
`2.43.0 ..< 2.51.0` | 5.5.2
`2.51.0 ..< 2.60.0` | 5.6
`2.60.0 ..< 2.65.0` | 5.7
`2.65.0 ...` | 5.8
`2.65.0 ..< 2.76.0 | 5.8
`2.76.0 ...` | 5.9

### SwiftNIO 1
SwiftNIO 1 is considered end of life - it is strongly recommended that you move to a newer version. The Core NIO team does not actively work on this version. No new features will be added to this version but PRs which fix bugs or security vulnerabilities will be accepted until the end of May 2022.
Expand Down
11 changes: 4 additions & 7 deletions Sources/NIOConcurrencyHelpers/lock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -229,20 +229,17 @@ public final class ConditionLock<T: Equatable> {
}

let dwWaitStart = timeGetTime()
if !SleepConditionVariableSRW(
self.cond,
self.mutex._storage.mutex,
dwMilliseconds,
0
) {
let result = self.mutex.withLockPrimitive { mutex in
SleepConditionVariableSRW(self.cond, mutex, dwMilliseconds, 0)
}
if !result {
let dwError = GetLastError()
if dwError == ERROR_TIMEOUT {
self.unlock()
return false
}
fatalError("SleepConditionVariableSRW: \(dwError)")
}

// NOTE: this may be a spurious wakeup, adjust the timeout accordingly
dwMilliseconds = dwMilliseconds - (timeGetTime() - dwWaitStart)
}
Expand Down
Loading

0 comments on commit 7bb69ad

Please sign in to comment.