# Swift vs Rust on a single Lambda

**URL:** <https://forums.swift.org/t/swift-vs-rust-on-a-single-lambda/87039>\
**Category:** Server\
**Tags:** benchmarks, lambda\
**Created:** [June 2, 2026, 10:11am UTC](https://forums.swift.org/t/swift-vs-rust-on-a-single-lambda/87039 "2026-06-02T10:11:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebsto](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/sebsto/32/27165_2.png) [@sebsto](https://forums.swift.org/u/sebsto)\
**Post date:** [June 2, 2026, 10:11am UTC](https://forums.swift.org/t/swift-vs-rust-on-a-single-lambda/87039/1 "2026-06-02T10:11:47Z")

</div>

I wrote a Swift 6 Lambda that zips 15 GB of S3 objects in one invocation, streaming end to end on 512 MB arm64. [It was a challenge posted by Jérémie Rodon (RustyServerless) who built the Rust reference implementation](https://rustysl.com/en/blog/s3-on-demand-archive).

The Swift contender lands at 1.04x Rust on median (219 s vs 211 s). Three-stage pipeline with TaskGroups, actors, and AsyncStreams. Pure Swift CRC32 (slicing-by-8), hand-rolled ZIP64 encoder, Soto for the S3 layer.

A few findings relevant to this community:

1. Soto vs aws-sdk-swift: same app code, same pipeline. Soto finishes in 250 s. The official SDK hits the 600 s timeout. The gap is uploadPart latency: 200 ms (AsyncHTTPClient) vs 680 ms (aws-crt-swift) per 10 MiB part.

2. ByteBuffer vs Data: switching the upload path from Data to ByteBuffer eliminated ~15 GB of copies per run. Data's per-append reallocation and the SDK's internal flattening are the culprits.

3. Pure-Swift CRC32 vs ARM \_\_crc32d: the intrinsic has a serial dependency chain. Slicing-by-8 issues 8 parallel table lookups. On a 0.29 vCPU allocation, memory-level parallelism wins: 4 ms vs 76 ms per 5 MB file.

Code: [demo-s3-archiving/contenders/swift at main · RustyServerless/demo-s3-archiving · GitHub](https://github.com/RustyServerless/demo-s3-archiving/tree/main/contenders/swift)

PR: [Add Swift contender (sebsto-soto): pure-Swift, ~1.04× Rust by sebsto · Pull Request #1 · RustyServerless/demo-s3-archiving · GitHub](https://github.com/RustyServerless/demo-s3-archiving/pull/1)

Blog post with full context: [Can Swift Match Rust on a Lambda Micro-Benchmark? Almost. | Seb in the ☁️](https://stormacq.com/2026/06/02/can-swift-match-rust-on-a-lambda-micro-benchmark-almost./)

I'm calling on the Swift community here: I'm sure I missed something. The code is about 1,200 lines of Swift 6 strict concurrency. If you spot inefficiencies in how I use TaskGroups, AsyncStreams, actor isolation, or ByteBuffer management, I'd genuinely appreciate the feedback. Same if you see a way to reduce the cold-start variance (9 s sigma vs Rust's 0.5 s at 512 MB).

A few specific questions I still have:

- Is there a better pattern for the producer/consumer handoff than an actor with manual slot counting?

- Could the download stage benefit from a custom AsyncSequence instead of collecting into a pre-sized ByteBuffer?

- Any known pitfalls with AsyncHTTPClient connection pooling on very low vCPU (0.29)?

The STATS=1 instrumentation is left in the code so anyone investigating can get per-stage timings from a single run. PRs and issues welcome.

---

<div class="post-metadata">

**Author:** ![BoseSj](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/bosesj/32/35018_2.png) [@BoseSj](https://forums.swift.org/u/BoseSj)\
**Post date:** [June 2, 2026, 10:14am UTC](https://forums.swift.org/t/swift-vs-rust-on-a-single-lambda/87039/2 "2026-06-02T10:14:28Z")

</div>

> Blog post with full context: [https://stormacq.com/2026/06/02/swift-vs-rust-s3-challenge/](https://stormacq.com/2026/06/02/swift-vs-rust-s3-challenge/)

error loading the blog post

---

<div class="post-metadata">

**Author:** ![sebsto](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/sebsto/32/27165_2.png) [@sebsto](https://forums.swift.org/u/sebsto)\
**Post date:** [June 2, 2026, 10:15am UTC](https://forums.swift.org/t/swift-vs-rust-on-a-single-lambda/87039/3 "2026-06-02T10:15:13Z")

</div>

Fixed [Can Swift Match Rust on a Lambda Micro-Benchmark? Almost. | Seb in the ☁️](https://stormacq.com/2026/06/02/can-swift-match-rust-on-a-lambda-micro-benchmark-almost./)

---

<div class="post-metadata">

**Author:** ![mikaelacaron](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/mikaelacaron/32/16601_2.png) [@mikaelacaron](https://forums.swift.org/u/mikaelacaron)\
**Post date:** [June 3, 2026, 2:44pm UTC](https://forums.swift.org/t/swift-vs-rust-on-a-single-lambda/87039/4 "2026-06-03T14:44:48Z")

</div>

I love this Sébastien!
