Admittedly, a slight bending of the truth here – we are using embedded Swift, not Embedded Swift, and there's no Swift (yet) in the realtime code. But the vast majority of code is the control plane, which is almost all Swift, save for the UI which is a thin stateless wrapper written in Flutter.
Swift Logging integration with both systemd and Android native logging
More technical details: we are using Swift 6.0.2 built as part of a custom Yocto distribution, on a Raspberry Pi CM4. Realtime processing happens on an XMOS XE232. There is also a Brooklyn 3, Marvell switch chip, a bunch of DACs, op amps, etc...
OK, noting that this is not SLOC, but just wc, and counts new code written by me specifically for this project (i.e. excluding many C and C++ libraries that are wrapped in Swift):
Started to do a bit of profiling on this as, whilst the CM4 is fairly hefty as far as embedded systems are concerned, it's no Apple Silicon.
Biggest performance sink was dealing with metering information coming from other MCUs onboard, which is at a fairly slow rate of 10Hz (well, was 30Hz, but I slowed it down). We are using Codable to implement the serialisation of the control protocol (OCP.1, part of AES70), and Codable is slooooow. More specifically, it's the Swift runtime cost (checking for protocol conformance). This also impacted some other errors where we were, for example, using protocol conformance to check whether a particular event was a metering event or not. Hand-rolling some of the serialisation code and also using more efficient checks elsewhere reduced CPU usage considerably.
The other culprit was malloc() in ContiguousArrayBuffer as used by AsyncChannel. Curtailing the use of AsyncChannel also improved things.
Yeah, another (non-)shout out for Codable. It's very handy but doesn't belong in a hot path like metering. Replacing it with hand-coded serialisation for the PDU encapsulation and metering resulted in an order of magnitude improvement. Thanks, perf!