Skip to content

Conversation

@jkachmar
Copy link
Contributor

description

there are a few places where we use atomicModifyIORef and we already have a transitive dependency on atomic-primops (i'm pretty sure?) and we only support x86_64 & aarch64 architectures so there's no reason not to use the CAS version.

@jkachmar jkachmar requested a review from iand675 November 21, 2025 20:36
readStateVar var = Condition $ do
touchedVars <- ask
modifyIORef' touchedVars (Set.insert var.stateVarId)
liftIO $ atomicModifyIORefCAS_ touchedVars (Set.insert var.stateVarId)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these calls are probably only ever sequenced in the course of workflow execution actually, right? so there's no need to be atomic & this should probably stil be modifyIORef'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is true, workflow execution currently only happens in a single thread.

@jkachmar jkachmar force-pushed the jkachmar/atomic-primops branch from f6d283a to 2468637 Compare November 21, 2025 20:45
Comment on lines -261 to +262
wp <- atomicModifyIORef' w $ \wp -> (throw WorkerAlreadyClosed, wp)
wp <- liftIO $ atomicModifyIORefCAS w $ \wp -> (throw WorkerAlreadyClosed, wp)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, atomicModifyIORefCAS is speculative but this is probably fine because only the computation that produces this is retried which is basically just "swap vars"..?

@jkachmar jkachmar merged commit 9e5fab4 into main Nov 21, 2025
29 of 30 checks passed
@jkachmar jkachmar deleted the jkachmar/atomic-primops branch November 21, 2025 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants