Commit Graph
18 Commits
Author SHA1 Message Date
George Barnett 9b2642c21b Use path based deps in the alloc counter framework (#3355)
The alloc counter framework uses `url` based deps for local
dependencies. They should use `path` instead.
2025-08-22 11:14:33 +01:00
Rick Newton-Rogers 57658e12ff Drop Swift 5.9 (#3228)
Motivation:

Swift 5.9 is no longer supported, we should bump the tools version and
remove it from our CI.

Modifications:

* Bump the Swift tools version to Swift 5.10
* Remove Swift 5.9 jobs where appropriate in main.yml, pull_request.yml

Result:

Code reflects our support window.
2025-05-07 12:24:44 +00:00
Franz Busch c9756e1083 Adopt swift-format (#2794)
* Apply formatting

* Apply no block comments rule

* Apply OmitExplicitReturns

* Apple OnlyOneTrailingClosureArgument

* Apply NoAssignmentInExpressions

* Fix up DontRepeatTypeInStaticProperties lint errors

* Apply `OrderedImports`

* Apply `ReplaceForEachWithForLoop`

* format file

* Enable the formatting pipeline

* Adopt `AmbiguousTrailingClosureOverload`

* Fix license header

* Fix format check

* Fix `EndOfLineComment`

* Fix CI

* Adapt CI script to check if changes when running formatting

* Separate lint and format into to steps

* Fix format

* Adopt `UseEarlyExits`

* Revert "Adopt `UseEarlyExits`"

This reverts commit d1ac5bbe12.
2024-07-19 11:48:17 +02:00
Gregor Milos (Grzegorz Miłoś) fc63f0cf4e Fix memory allocations counters on macOS. (#2673)
Motivation:

Allocation counters are broken on macOS as described [here](https://github.com/apple/swift-nio/issues/2672). This PR fixes it.

Modifications:

`AtomicCounter` library is made `.dynamic`. This deduplicates the two (static) copies that used to exist. One embedded in the main binary, and the other in `HookedFunctions` dylib. This deplication fixes the issue, because there is just one copy of the counters in the process address space.

Result:

All the tests counting allocations and related statistics work on macOS.
2024-03-06 14:46:50 +00:00
Gustavo Cairo 0c648c91c6 Fix broken tests (#2621)
* Update swift-tools-version to 5.7 in integration tests

* Fix flaky test

* Add missing AtomicCounter dependency in generated Package.swift

* Update swift-tools-version in integration test helper Swift projects

* Make test clearer

* Don't run MTELG integration test on Swift 5.11+

It hasn't been properly tested
2024-01-08 10:02:09 +00:00
finagolfin 231902a295 Correct a few Musl additions from #2449 for Android, plus error if libc not found (#2451)
Motivation

Fix build errors on Android

Modifications

- Fix previous Musl modifications that assumed Glibc wasn't imported on Android
- Add errors for all libc imports, so new platform ports error out early

Result

NIO builds natively on Android again, with all the same tests passing
2023-06-26 02:52:18 -07:00
Franz Busch e865f6163f Use #if canImport(Darwin) where possible (#2446) 2023-06-22 10:12:01 +01:00
Cory Benfield fd35cd9e52 Extend the integration test harness to track FDs (#2411)
* Extend the integration test harness to track FDs

Motivation

This patch extends the NIO integration test harness to track
file descriptors, in particular to search for leaks. This
change has been validated on Linux and Darwin, and in both cases
correctly diagnoses FD leaks.

The goal is to enable us to regression test for things like

Modifications

- Add support for hooking socket and close calls.
- Wire up this support into the test harness.
- Extend the test harness to handle the logging.
- Add new regression test for #2047.

Results

We can write regression tests for FD leaks.

* Disable FD checking in most builds.

I'm doing this for speed reasons

* Always print the leaked fds number
2023-04-26 08:38:18 -07:00
Franz BuschandCory Benfield 1abe64c5e6 Add benchmarks for NIOAsyncWriter and NIOAsyncSequenceProducer (#2301)
# Motivation
We landed the async bridge types a while back but never added allocation and performance tests. Since we expect these types to be used performance critical paths we really should cover those with tests.

# Modification
Extends the allocation counter scaffolding to support async tests. Furthermore, add allocations tests for both the writer and producer. Lastly, I a also added a performance test for the producer.

# Result
We now have baseline tests for the `NIOAsyncWriter` and `NIOAsyncSequenceProducer`

Co-authored-by: Cory Benfield <lukasa@apple.com>
2022-10-26 03:51:20 -07:00
Johannes Weiss b021a5a5c6 alloc counters: Use atomic globals instead of thread-locals (#1743)
Motivation:

The alloc counters need to store the pointer to the original libc
implmentations of the hooked functions somewhere. Previously, we would
store them in thread locals. That works fine but creates quite some
overhead (and allocations) per thread (to do dlsym on every thread).

Modifications:

Instead, we now store the libc function pointers in (atomic) globals so
we need to only resolve each function once, no matter how many threads
we use.

Result:

Faster, and more accurate.
2021-02-08 15:28:50 +00:00
Cory Benfield e7880565aa We use main as our development branch now. (#1651) 2020-09-24 18:02:44 +01:00
Johannes WeissandCory Benfield 3a2fc0d39b alloc tests: implement malloc_zone_* (#1569)
Motivation:

The Swift runtime is now using malloc_zone_*, we need to implement
replacements for these too. This is just a first pass, eventually, we
should implement _all_ replacements as `malloc_zone_memalign` which is
powerful enough to implement all others.

Modifications:

Provide new replacements.

Result:

Alloc tests work again on macOS.

Co-authored-by: Cory Benfield <lukasa@apple.com>
2020-06-26 11:04:37 +01:00
Johannes Weiss bf48c2beee make the allocation counter tests more stable (#1476)
Motivation:

The core problem is that we hook the system's allocator (malloc, free,
and friends) to get the most accurate allocation counts. This however
also means that all threads count into our limits which inherently means
we can't be 100% stable always.

Previously, we just waited a fixed 100ms and expected everything to be
as quiesced as it'll get. But we can do better.

Modifications:

- discard runs with negative remaining allocations (clearly bogus,
  quiescing not long enough in a previous run)
- instead of waiting a fixed amount of time, wait until the results
  appear quiesced (stable (for first run) or zero (for subsequent runs)
  remaining allocation counts.

Result:

Allocation counter tests should be much more stable on busier machines.
2020-04-08 14:00:26 +01:00
Johannes Weiss 4a2746cbc8 include clang modularised headers last (#1368)
Motivation:

Clang modules seem to mess with stuff like _GNU_SOURCE as soon as
they're included. We do need _GNU_SOURCE (but don't like the
`#define __USE_GNU` hack).

Modifications:

Include the modularised headers last.

Result:

Alloc counter tests work without `#define __USE_GNU`.
2020-01-29 18:31:21 +00:00
Johannes Weissandtomer doron 7f8e96cf02 fix 5.2 builds (#1366)
motivation: tsan is broken on ubuntu 18.04.use 16.04 so 5.2 build can pass

changes:
* change 5.2 docker setup to use 16.04 instead of 18.04
* add the ability to pipe arguments to the integration tests via the docker setup
* skip tests_02 integration tests suite since it broken on 5.2 (swift-pm issue?)

fake the new limits from #1362

Co-authored-by: tomer doron <tomer@apple.com>
2020-01-29 14:39:28 +00:00
Konrad `ktoso` Malawski 8c0e373bf5 Also collect total bytes allocated in alloc tests (#1116)
Motivation:

It is useful/interesting to have an overview about total bytes
allocated, not only the number of malloc calls.

This is not used to fail tests though, more as an informational thing.

Modifications:

Introduce and hit new counter with allocated size whenever allocations
happen.

Result:

It is possible to inspect the total allocated bytes.
2019-11-27 15:43:19 +00:00
Johannes Weiss bf2598d193 iOS & simulator compatibility (#1037)
Motivation:

We should have better iOS compatibility.

Modifications:

- make all OS-conditional imports the same
- don't check TSI_S_ESTABLISHED (which is unavailable on iOS)
- update availability to reflect the OS versions we actually support
- make sure temporary UDS paths aren't too long

Result:

better iOS compatibility
2019-06-18 10:38:39 +01:00
Johannes Weiss 5d1d59868d new alloc counter tests (#996) 2019-05-09 14:27:29 +01:00