Comments (10)
But I do think we should go ahead and bump the major version and change the interface for this Counter lib to return the BEFORE value (and support that behavior across the last 3 GHC versions), what do you think?
Sounds good to me. Sorry about the breakage.
from haskell-lockfree.
Is that how all of the new fetch*IntArray#
functions behave? If so that's good, I think, since e.g. for the fetchAnd
, fetchOr
, etc. we can determine the value after if the value before the atomic op, but not vice versa. And so maybe the naming and behavior of what we have in atomic-primops
should be reconsidered? (obviously we can't just change the functionality of fetchAddByteArray
; that would need a rename).
(sorry to be lazy here; I just got 7.10 installed and have to run; didn't want to forget to comment on this issue)
from haskell-lockfree.
Sorry, I didn't read your comment properly, @rrnewton.
But I do think we should go ahead and bump the major version and change the interface for this Counter lib to return the BEFORE value (and support that behavior across the last 3 GHC versions), what do you think?
Literally just yesterday I made a commit in my lib that got rid of the upper bounds on atomic-primops
... ugh. Can we think of any other names that would be equally good that you can use going forward (with this new behavior), and just deprecate incrCounter
and fetchAddByteArray
(keeping the old behavior there)?
I've been very paranoid about my use of atomic-primops
and my tests can probably detect whatever wonky behavior changes you can throw at me, but I doubt most others have been quite so paranoid. It's not hard to imagine this causing subtle off-by-one errors, and those errors leading to segfaults. And with so many people split on the merits of upper bounds, I just think this is a bad, bad idea.
from haskell-lockfree.
Can we think of any other names that would be equally good that you can use going forward (with this new behavior), and just deprecate incrCounter and fetchAddByteArray (keeping the old behavior there)?
I propose the following; let me know your thoughts:
- Just using the names from
GHC.Prim
for thefetch*
functions.
- So
fetchAddByteArrayInt
would be deprecated, - with CPP conditionals to keep the behavior the same through 7.10.
- While a new wrapper named
fetchAddIntArray
would take its place with the new behavior (again conditionally bringing this NEW behavior to GHC <7.10). Likewise for the new functions (#43). This would avoid breakage, and I think make more sense (e.g. that's what theprimitive
package seems to do).
- Do one of the following:
- Remove all the
Data.Atomic.Counter*
modules; it's trivial to implement the functionality usingprimitive
, the package is calledatomic-primops
, it's not clear to me why those alternate submodules are there, means less code to maintain, etc. - Rewrite
incrCounter
with CPP conditionals to keep the old behavior going forward.
- Remove all the
- Deprecate the new
0.6.1.1
, or adjust thebase
constraint back to<=4.8
from haskell-lockfree.
This sounds like a good plan to me.
My inclination would be to get rid of the Data.Atomic.Counter.*
alternatives, which were just there for benchmarking, but leave the Data.Atomic.Counter
for now. I agree, it should have gone in a separate package. (Moreover, there should be a proper package of several different counter variants, including scalable counters like SNZI, which we've implemented but not factored out of LVish.) But it also does little harm, and as you say we can prevent breakage and retain the old behavior of incrCounter
.
In fact, we could do like C++'s x++
/++x
if we liked and have both incrCounter
and counterIncr
to provide both options.
from haskell-lockfree.
@rrnewton sorry for the delay, I'm just starting on some of this work this evening. I see you moved the counter alternatives to other-modules
; is it okay to remove them and start simplifying the test suite, etc? I'm also planning on adding a benchmark suite, so I can just do a git mv
of those modules there if we only want them as a baseline for benchmarking.
I thought I might do some work that builds on @7315deed31 on master directly, and then submit pull requests for work on #41 and #43. Does that sound good?
from haskell-lockfree.
Sounds good to me, including removing/moving the other counters. Yes, they were mainly there for benchmarking.
It's mentioned somewhere that this separate ./testing/
director was a work-around for cabal/GHC problems (maybe it was haskell/cabal#1284). My takeaway was that foreign primops were not actually used by very many cabal packages and we were stressing corner cases. With new versions of cabal it might work to fold the test-suite back into a normal cabal test suite, and to likewise create a normal cabal benchmark suite.
By the way, we love criterion, but when doing criterion for parallel stuff we tend to do a bit of a hack to make it work well. (You may use the same or a different hack in your code, I'd be interested to hear.)
Basically, if we let criterion run a batch of iterations with the parallelism (forkIO
, runPar
, whatever), launched from inside each iteration. Then we pay that overhead N times, and it dominates running time. So we want parallel threads to be launched once, and then the N iterations to happen in a sequential loop inside each thread. Fortunately, Criterion exposes the Benchmarkable
type constructor, so we get to construct our own Int64 -> IO ()
functions to launch a batch of iterations.
We employ this technique in the simple MicroBench.hs file that's already in there. (As well as in other libraries.)
from haskell-lockfree.
I think at this point (af637d7) if you wanted to do a release we can have a version that works fully with 7.10, while we work on #43. Also @rrnewton can you edit the metadata for 0.6.1.1 so that it reverts the constraint to base (>=4.6.0.0 && <4.8.0.0)
?
from haskell-lockfree.
Sorry, by "edit the metadata" I mean edit the cabal file for that version directly on hackage via the "edit package information" button. That way we don't have a version with different counter/fetchAdd behavior that needs to be blacklisted in other packages.
from haskell-lockfree.
Ok, I adjusted the version constraint and checked that off in the checklist above. I released the new version as "0.7" (following PVP, since it removes modules, even though it doesn't add all the new stuff yet).
I also added you as a maintainer on the hackage package in case I messed anything up or there's anything else you need to do.
from haskell-lockfree.
Related Issues (20)
- Cannot find module "Data.Atomics.Counter.Unboxed" HOT 6
- Are memory barriers compiler reordering barriers? HOT 1
- Various cabal issues.
- Saw a genuine nondeterministic test failure
- atomic-primops: can GC duplication of pure objects screw up Tickets and cause a false negative?
- atomic-primops: ghc 8 support needed HOT 7
- Build fail on armv8
- atomic-primops: Need to make barriers inline primops HOT 3
- Missing load-store barrier HOT 1
- [chaselev-deque] stackage availability HOT 4
- Provide loop wrapper for casArrayElem? HOT 2
- Implement multi-item CAS (CASN) HOT 2
- Cut a new atomic-primops release for GHC 8.2.1 HOT 2
- testing/Fetch.hs missing from Hackage release HOT 1
- Recursion in haddocks of `atomic-primops` HOT 1
- CAS fails with newly created ticket HOT 8
- CAS very rarely fails not due to a race, in GHC >= 8.2
- [lockfree-queue]: GHC 9.4 support HOT 2
- Release chaselev-deque-0.5.0.6 on hackage HOT 1
- No more load_load_barrier in GHC HEAD HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from haskell-lockfree.