Add opt-in performance group with STM-avoidance hints#1690
Open
mgajda wants to merge 1 commit intondmitchell:masterfrom
Open
Add opt-in performance group with STM-avoidance hints#1690mgajda wants to merge 1 commit intondmitchell:masterfrom
mgajda wants to merge 1 commit intondmitchell:masterfrom
Conversation
New group (enabled: false) flags single-primitive uses of STM where a non-transactional primitive from IORef/MVar/Chan/QSem gives the same operation at a fraction of the cost: the transaction log, commit-time validation, and retry machinery are pure overhead when a transaction touches a single variable and needs no composition. Hints cover TVar, TMVar, TChan, TQueue, and TSem. Multi-variable transactions correctly do not match (no false positives on genuinely composable STM). Activate with `--with-group=performance`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a new
performancegroup (disabled by default) that flags single-primitive uses of STM where a non-transactional primitive fromData.IORef/Control.Concurrent.MVar/Control.Concurrent.Chan/Control.Concurrent.QSemgives the same operation at a fraction of the cost.The transaction log, commit-time validation, and retry machinery are pure overhead when a transaction touches a single variable and needs no composition. Students toggle the group off (the default); users who care about per-access overhead opt in with
--with-group=performance.What's covered
atomically (readTVar/writeTVar/modifyTVar/modifyTVar'/swapTVar/stateTVar v),readTVarIO,newTVarIO→readIORef/atomicWriteIORef/atomicModifyIORef'/newIORef.takeTMVar/putTMVar/readTMVar/tryTakeTMVar/tryPutTMVar/tryReadTMVar/swapTMVar/isEmptyTMVar/newTMVarIO/newEmptyTMVarIOfamily →MVarequivalents.readTChan/writeTChan/dupTChan/newTChanIO→Chanequivalents.readTQueue/writeTQueue/newTQueueIO→Chanequivalents.waitTSem/signalTSem/newTSem→QSemequivalents.What's deliberately not covered
atomically $ do { ... }transactions.retry/orElse/check.Tests done
hlint --test— 965 tests pass.tests/flag-with-group-performance.testexercises three hints (writeTVar/takeTMVar/writeTChan) under--with-group=performance.readTVarIO/newTVarIOhints fire (no new noise).