malte, to golang

are there best practices regarding in ? I have something like an in-memory database that gets accessed by multiple clients in parallel. The RWMutexes drive me crazy.

jaanus, to random

Just ran into a question on how to implement NotificationCenter long-running listeners with modern AsyncSequence API, and have them torn down correctly. This seems to work.

https://forums.swift.org/t/deinit-not-called-in-certain-scenarios-with-for-await-loop/64198/19

jaanus, (edited ) to swift

#Swift #CoreData #Combine #Concurrency #AsyncSequence #NotificationCenter

Can anyone more familiar with above topics help me understand what’s going on here?

I thought that NotificationCenter Combine-based and AsyncSequence-based API-s behave exactly the same. Now I hit a case where they don’t. Their behavior differs based on whether I give it the sending object or not.

Why?

wrstscrnnm6, to programming
@wrstscrnnm6@mastodon.social avatar

I was getting an error "failed to allocate XXXXXX b"

I copy the number into wolfram alpha to see how much data that really is.

5.3 Zettabytes.

How the hell is this program trying to allocate the equivalent of ... all of the data sent over the internet in a year, five times over?

Somewhere between my terminal and the browser the string of numbers got doubled.

Never have I been so relieved to find out my program was only trying to allocate 53Gb of ram.

wrstscrnnm6,
@wrstscrnnm6@mastodon.social avatar

The CPU intensive part of the job finishes in less than two minutes. It then takes 6-12 additional minutes back on the main thread to handle all the data that those other threads produced.

abcdw, to golang
@abcdw@fosstodon.org avatar

Found a nice talk on concurrency. It has a very brief comparison of different concurrency models, like Erlang's Actors, Hoare's CSP, Go's goroutines, Clojure's core.async, Concurrent ML (aka Fibers in Guile).

Primary focus on Concurrent ML (but examples are in Scheme with type annotations ><).

https://youtu.be/pf4VbP5q3P0

#go #golang #clojure #lisp #guile #scheme #ocaml #concurrency #erlang

jbzfn, (edited ) to rust
@jbzfn@mastodon.social avatar

🤔 How Much Memory Do You Need to Run 1 Million Concurrent Tasks?
➥ Piotr Kołaczkowski


https://pkolaczk.github.io/memory-consumption-of-async/

abcdw, (edited ) to scheme
@abcdw@fosstodon.org avatar

Keep experimenting with fibers and for a good reason I need an operation, which waits until thread is exited.

https://paste.sr.ht/~abcdw/12b2547726c3061f408d3d0f3229408af214cad1

I implemented it and it works, but obviously blows up the memory. I've not finished a "Parallel Concurrent ML" paper and have a very little clue what I do in block-fn, I'll appreaciate if someone can give me a quick solution for now.

janriemer, to rust

Inko - A language for building concurrent software with confidence

https://inko-lang.org/

Looks quite nice! Almost like a mix of and (with 75% Rust and 25% Go).

brightbox, to random
@brightbox@ruby.social avatar
happyborg, to rust
@happyborg@fosstodon.org avatar

Async Rust is a Bad Language by Matt Kline.

Very good intro and thought provoking article on and , and their use in .

It champions 's model of concurrency which takes me back. Back to the time I failed to get funding for a start-up to build an compiler targeting i386. Which was largely a ploy to get the UK government to buy me some neat kit 🤷‍♂️

Anyway, here's the article:
https://bitbashing.io/async-rust.html

jaanus, to random

In this year’s platform release, many CloudKit types, most importantly CKRecord, are now Sendable 🎉

Nice to see in the docs, and confirmed in an Ask Apple session.

I built Canopy with Xcode 15 and was wondering where all the actor boundary crossing warnings had gone.

I still got work to make Canopy completely warning-free, but this is great.

aleks, to Kotlin
@aleks@hachyderm.io avatar

Fixed that pesky bug by… running everything synchronously!

Concurrency is hard, let's go shopping…

chriskrycho, to rust
@chriskrycho@mastodon.social avatar

Fantastic write-up here from Hillel Wayne on what makes so hard: https://buttondown.email/hillelwayne/archive/what-makes-concurrency-so-hard/ – it hits on a bunch of themes I have been mulling on while working on the new async/await chapter for The Programming Language book.

An intuitive-but-worth-saying bit I would add to this, which he touches on but does not elaborate: In most of our programming, we can actually expect things to proceed in order, basically corresponding to the lines of code in our program.

pixel, to swift
@pixel@social.pixels.pizza avatar
pixel, to programming
@pixel@social.pixels.pizza avatar

The Deadlock Empire: Slay dragons, learn concurrency!


https://deadlockempire.github.io/

pixel, to programming
@pixel@social.pixels.pizza avatar

“SwiftNIO is Apple non-blocking networking library. It can be used to write either client libraries or server frameworks and works on macOS, iOS and Linux.”


https://www.process-one.net/blog/swiftnio-futures-and-promises/

hywan, to rust
@hywan@fosstodon.org avatar

Tasks are the wrong abstraction, https://blog.yoshuawuyts.com/tasks-are-the-wrong-abstraction/.

Another excellent article by @yosh. I still need to digest it; I reckon it contains many (great) ideas I agree with.

alvinashcraft, to dotnet
@alvinashcraft@hachyderm.io avatar
brennansv, to random
@brennansv@sfba.social avatar

Heard of function coloring? It is about async code.

cy, to programming
@cy@fedicy.us.to avatar

OK so for each database row I check if the IP address is being used too much. If it is, I skip the row. If not I'm considered a user of that address, and can process the row. Every "processing" should eliminate the row it comes from in future queries, so the next time I search, once something is finished, the skipped rows will come up again. I can't LIMIT the query though, since I don't know how many rows will be skipped.

And to check how much an address is in use is a network round trip, so I queue up addresses to query for that, and batch send the queries, to get a reply for how many times I can use that address. So first I go through all rows to see what addresses are needed, then send that address-use query. Once I get a reply, I go through all the rows again to see which I can get rid of based on that reply, until I've started enough parallel requests to different addresses.

Except I can't predict how many rows I can get rid of in the second query, so the first query has to iterate over every single database row every time just in case. Not only can it not have a LIMIT, I can't stop queueing up address-use requests until the first query stops returning rows.

But... this query is in theory... not a lot of rows. It's just supposed to search for database records with holes, missing fields that could only be gotten by requesting a specific webpage from a given address. In theory that could mean 7 million user profiles who all failed to load properly because I tried to view them before downloading the avatar image and profile page, but when am I going to look at 7 million profiles at once? It should be like, 10 profiles per page or something, and the address-use query is over the local network so it should happen faster than I can click the "next" button to add on 10 more rows. But I can't guarantee that. Ugh...

konstantin, to swift
@konstantin@social.headbright.eu avatar

Hey friends, do your future selves a favour and turn this on 😍

konstantin, to iOS
@konstantin@social.headbright.eu avatar

Good morning friends! ☕️

SwiftyFlags has been updated with all the new Swift 5.10 goodies and some extra links for (by far the most popular flag) StrictConcurrency!

If you have thoughts or comments, feel free to share them via the website widget, GitHub issue or just reply below. Happy thread-isolated coding 🤭!

https://flags.swiftythemes.com/language-features/5.10.html#StrictConcurrency

janriemer, to rust

This is wild! 🤯

HappyLock: Deadlock Free Mutexes

https://github.com/botahamec/happylock

rhonabwy.com, to swift
@rhonabwy.com@rhonabwy.com avatar

This weekend I was frustrated with my debugging, and just not up to digging in and carefully, meticulously analyzing what was happening. So … I took a left turn (at Alburquerque) and decided to explore an older idea to see if it was interesting and/or useful. My challenging debugging was all about network code, for a collaborative, peer to peer sharing thing; more about that effort some other time.

A bit of back story

A number of years ago when I was working with a solar energy manufacturer, I was living and breathing events, APIs, and running very distributed, sometimes over crap network connections, systems. One of the experiments I did (that worked out extremely well) was to enable distributed tracing across the all the software components, collecting and analyzing traces to support integration testing. Distributed tracing, and the now-popular CNCF OpenTelemetry project weren’t a big thing, but they were around – kind of getting started. The folks (Yuri Shkuro, at least) at Uber had released Jaeger, an open-source trace collector with web-based visualization, which was enough to get started. I wrote about that work back in 2019 (that post still gets some recurring traffic from search engines, although it’s pretty dated now and not entirely useful).

We spun up our services, enabled tracing, and ran integration tests on the whole system. After which, we had the traces available for visual review. It was useful enough that we ended up evolving it so that a single developer could stand up most of their pieces locally (with a sufficiently beefy machine), and capture and view the traces locally. That provided a great feedback loop as they could see performance and flows in the system while they were developing fixes, updates and features. I wanted to see, this time with an iOS/macOS focused library, how far I could get trying to replicate that idea (time boxed to the weekend).

The Experiment!

I’ve been loosely following the server-side swift distributed tracing efforts since it started, and it looked pretty clear that I could use it directly. Moritz Lang publishes swift-otel, which is a Swift native, concurrency supported library. With his examples, it was super quick to hack into my test setup. The library is set up to run with service-lifecycle pieces over SwiftNIO, so there’s a pile of dependencies that come in with it. To add to my library, I’d be a little hesitant, but an integration test thing, I’m totally good with that. There were some quirks to using it with XCTest, most of which I hacked around by shoving the tracer setup into a global actor and exposing an idempotent bootstrap call. With that in place, I added explicit traces into my tests, and then started adding more and more, including into my library, and could see the results in a locally running instance of Jaeger (running Jaeger using Docker).

Some Results

The following image is an overview of the traces generated by a single test (testCreate):

https://josephheck.files.wordpress.com/2024/04/trace_overview.pngThe code I’m working with is all pushing events over web sockets, so inside of the individual spans (which are async closures in my test) I’ve dropped in some span events, one of which is shown in detail below:

https://josephheck.files.wordpress.com/2024/04/trace_with_detail.pngIn a lot of respects, this is akin to dropping in os_signposts that you might view in Instruments, but it’s external to Xcode infrastructure. Don’t get me wrong, I love Instruments and what it does – it’s been amazing and really the gold standard in tooling for me for years – but I was curious how far this approach would get me.

Choices and Challenges

Using something like this in production – with live-running iOS or macOS apps – would be another great end-to-end scenario. More so if the infrastructure your app was working from also used tracing. There’s a separate tracing project at CNCF – OpenTelemetry Swift – that looks oriented towards doing just that. I seriously considered using it, but I didn’t see a way to use that package to instrument my library and not bring in the whole pile of dependencies. With the swift-distributed-tracing library, it’s an easy (and small) dependency add – and you only need to take the hit of the extra dependencies when you want to use the tracing.

And I’ll just “casually” mention that if you pair this with server-side swift efforts, the Hummingbird project has support for distributed tracing currently built in. I expect Vapor support isn’t too far off, and it’s a continued focus to add more distributed tracing support for a number of prevalent server-side swift libraries over this coming summer.

See for Yourself (under construction/YMMV/etc)

I’ve tossed up my hack-job of a wrapper for tracing during testing with iOS and macOS – DistributedTracer, if you want to experiment with this kind of thing yourself. Feel free to use it, although if you’re amazed with the results – ALL credit should go to Moritz, the contributors to his package and the contributors to swift-distributed-tracing, since they did the heavy lifting. The swift-otel library itself is undergoing some major API surface changes – so if you go looking, I worked from the current main branch rather than the latest release. Moritz shared with me that while the API was not completely solid yet, this is more of the pattern he wants to expose for an upcoming 1.0 release.

Onward from here

I might push the DistributedTracer package further in the future. I think there’s real potential there, but it is not without pitfalls. Some of the challenges stem from constantly exporting data from an iOS app, so there’s a privacy (and privacy manifest) bit that needs to be seriously considered. There are also challenges with collecting enough data (but not too much), related choices in sampling so that it aligns with traces generated from infrastructure, as well as how to reliably transfer it from device to an endpoint. Nothing that can’t be overcome, but it’s not a small amount of work either.

Weekend hacking complete, I’m calling this a successful experiment. Okay, now back to actually debugging my library…

https://rhonabwy.com/2024/04/02/distributed-tracing-with-testing-on-ios-and-macos/

image/png

ctietze, to swift
@ctietze@mastodon.social avatar

Dynamic Actor Isolation in Can Help During the Transitional Phase https://christiantietze.de/posts/2024/04/dynamic-actor-isolation-help-transition/

On your way to static actor isolation, adopt dynamic isolation practices to ease into the change.

via @mattiem

  • All
  • Subscribed
  • Moderated
  • Favorites
  • megavids
  • thenastyranch
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • ngwrru68w68
  • provamag3
  • magazineikmin
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • anitta
  • Leos
  • tester
  • JUstTest
  • All magazines