Skip to content

Commit

Permalink
Merge branch 'main' into too-many-bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasa authored Aug 27, 2024
2 parents f065562 + 65db2db commit 7d885a4
Show file tree
Hide file tree
Showing 35 changed files with 238 additions and 98 deletions.
23 changes: 0 additions & 23 deletions .PrivacyInfo.xcprivacy

This file was deleted.

8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
4 changes: 3 additions & 1 deletion .github/workflows/pull_request_label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: PR label

on:
pull_request:
types: [labeled, unlabeled]
types: [labeled, unlabeled, opened, reopened, synchronize]

jobs:
semver-label-check:
Expand All @@ -12,5 +12,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Check for Semantic Version label
uses: ./.github/actions/pull_request_semver_label_checker/
13 changes: 13 additions & 0 deletions .github/workflows/soundness.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ jobs:
with:
# We need to fetch everything otherwise only the head commit will be fetched.
fetch-depth: 0
persist-credentials: false
- name: Mark the workspace as safe
# https://github.com/actions/checkout/issues/766
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
Expand All @@ -75,6 +76,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Run documentation check
run: |
apt-get -qq update && apt-get -qq -y install curl yq
Expand All @@ -88,6 +91,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Run unacceptable language check
env:
UNACCEPTABLE_WORD_LIST: ${{ inputs.unacceptable_language_check_word_list}}
Expand All @@ -101,6 +106,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Run license header check
env:
PROJECT_NAME: ${{ inputs.license_header_check_project_name }}
Expand All @@ -114,6 +121,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Run broken symlinks check
run: curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-broken-symlinks.sh | bash

Expand All @@ -127,6 +136,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Mark the workspace as safe
# https://github.com/actions/checkout/issues/766
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
Expand All @@ -143,6 +154,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Mark the workspace as safe
# https://github.com/actions/checkout/issues/766
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/swift_6_language_mode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set the language mode
run: swift package tools-version --set 6.0
- name: Build with Swift 6 language mode
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/swift_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Mark the workspace as safe
# https://github.com/actions/checkout/issues/766
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
- name: Run matrix job
if: ${{ matrix.swift.enabled }}
env:
Expand Down
1 change: 1 addition & 0 deletions .licenseignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
.mailmap
.spi.yml
.swift-format
.editorconfig
.github/*
*.md
*.txt
Expand Down
7 changes: 6 additions & 1 deletion Benchmarks/Benchmarks/NIOCoreBenchmarks/Benchmarks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ let benchmarks = {

Benchmark(
"NIOAsyncChannel.init",
configuration: Benchmark.Configuration(metrics: defaultMetrics)
configuration: .init(
metrics: defaultMetrics,
scalingFactor: .kilo,
maxDuration: .seconds(10_000_000),
maxIterations: 10
)
) { benchmark in
// Elide the cost of the 'EmbeddedChannel'. It's only used for its pipeline.
var channels: [EmbeddedChannel] = []
Expand Down
8 changes: 5 additions & 3 deletions Benchmarks/Benchmarks/NIOPosixBenchmarks/Benchmarks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ let benchmarks = {
"TCPEcho",
configuration: .init(
metrics: defaultMetrics,
timeUnits: .milliseconds,
scalingFactor: .mega
scalingFactor: .mega,
maxDuration: .seconds(10_000_000),
maxIterations: 5
)
) { benchmark in
try runTCPEcho(
Expand All @@ -43,8 +44,9 @@ let benchmarks = {
"TCPEchoAsyncChannel",
configuration: .init(
metrics: defaultMetrics,
timeUnits: .milliseconds,
scalingFactor: .mega,
maxDuration: .seconds(10_000_000),
maxIterations: 5,
// We are expecting a bit of allocation variance due to an allocation
// in the Concurrency runtime which happens when resuming a continuation.
thresholds: [.mallocCountTotal: .init(absolute: [.p90: 2000])],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 8
}
"mallocCountTotal" : 8000
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 108
"mallocCountTotal" : 555
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 165000
}
"mallocCountTotal" : 164375
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 8
}
"mallocCountTotal" : 8000
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 110
"mallocCountTotal" : 556
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 8
}
"mallocCountTotal" : 8000
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 110
"mallocCountTotal" : 556
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 164000
}
"mallocCountTotal" : 164381
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 8
}
"mallocCountTotal" : 8000
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 108
"mallocCountTotal" : 548
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 165000
}
"mallocCountTotal" : 164376
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 8
}
"mallocCountTotal" : 8000
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 108
"mallocCountTotal" : 548
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 165000
}
"mallocCountTotal" : 164371
}
40 changes: 34 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@

import PackageDescription

// Used only for environment variables, does not make its way
// into the product code.
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(
Expand All @@ -23,6 +27,24 @@ let swiftSystem: PackageDescription.Target.Dependency = .product(
condition: .when(platforms: [.macOS, .iOS, .tvOS, .watchOS, .linux, .android])
)

let strictConcurrencyDevelopment = false

let strictConcurrencySettings: [SwiftSetting] = {
var initialSettings: [SwiftSetting] = []
initialSettings.append(contentsOf: [
.enableUpcomingFeature("StrictConcurrency"),
.enableUpcomingFeature("InferSendableFromCaptures"),
])

if strictConcurrencyDevelopment {
// -warnings-as-errors here is a workaround so that IDE-based development can
// get tripped up on -require-explicit-sendable.
initialSettings.append(.unsafeFlags(["-require-explicit-sendable", "-warnings-as-errors"]))
}

return initialSettings
}()

// This doesn't work when cross-compiling: the privacy manifest will be included in the Bundle and
// Foundation will be linked. This is, however, strictly better than unconditionally adding the
// resource.
Expand Down Expand Up @@ -66,10 +88,12 @@ let package = Package(
]
),
.target(
name: "_NIODataStructures"
name: "_NIODataStructures",
swiftSettings: strictConcurrencySettings
),
.target(
name: "_NIOBase64"
name: "_NIOBase64",
swiftSettings: strictConcurrencySettings
),
.target(
name: "NIOEmbedded",
Expand Down Expand Up @@ -150,7 +174,8 @@ let package = Package(
name: "NIOConcurrencyHelpers",
dependencies: [
"CNIOAtomics"
]
],
swiftSettings: strictConcurrencySettings
),
.target(
name: "NIOHTTP1",
Expand Down Expand Up @@ -415,15 +440,18 @@ let package = Package(
dependencies: [
"NIOConcurrencyHelpers",
"NIOCore",
]
],
swiftSettings: strictConcurrencySettings
),
.testTarget(
name: "NIODataStructuresTests",
dependencies: ["_NIODataStructures"]
dependencies: ["_NIODataStructures"],
swiftSettings: strictConcurrencySettings
),
.testTarget(
name: "NIOBase64Tests",
dependencies: ["_NIOBase64"]
dependencies: ["_NIOBase64"],
swiftSettings: strictConcurrencySettings
),
.testTarget(
name: "NIOHTTP1Tests",
Expand Down
18 changes: 18 additions & 0 deletions Sources/NIOConcurrencyHelpers/NIOAtomic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@ import CNIOAtomics
/// **Do not add conformance to this protocol for arbitrary types**. Only a small range
/// of types have appropriate atomic operations supported by the CPU, and those types
/// already have conformances implemented.
#if compiler(>=6.0)
@preconcurrency
public protocol NIOAtomicPrimitive {
associatedtype AtomicWrapper
static var nio_atomic_create_with_existing_storage: @Sendable (UnsafeMutablePointer<AtomicWrapper>, Self) -> Void {
get
}
static var nio_atomic_compare_and_exchange: @Sendable (UnsafeMutablePointer<AtomicWrapper>, Self, Self) -> Bool {
get
}
static var nio_atomic_add: @Sendable (UnsafeMutablePointer<AtomicWrapper>, Self) -> Self { get }
static var nio_atomic_sub: @Sendable (UnsafeMutablePointer<AtomicWrapper>, Self) -> Self { get }
static var nio_atomic_exchange: @Sendable (UnsafeMutablePointer<AtomicWrapper>, Self) -> Self { get }
static var nio_atomic_load: @Sendable (UnsafeMutablePointer<AtomicWrapper>) -> Self { get }
static var nio_atomic_store: @Sendable (UnsafeMutablePointer<AtomicWrapper>, Self) -> Void { get }
}
#else
public protocol NIOAtomicPrimitive {
associatedtype AtomicWrapper
static var nio_atomic_create_with_existing_storage: (UnsafeMutablePointer<AtomicWrapper>, Self) -> Void { get }
Expand All @@ -29,6 +46,7 @@ public protocol NIOAtomicPrimitive {
static var nio_atomic_load: (UnsafeMutablePointer<AtomicWrapper>) -> Self { get }
static var nio_atomic_store: (UnsafeMutablePointer<AtomicWrapper>, Self) -> Void { get }
}
#endif

extension Bool: NIOAtomicPrimitive {
public typealias AtomicWrapper = catmc_nio_atomic__Bool
Expand Down
Loading

0 comments on commit 7d885a4

Please sign in to comment.