2024/05/16

Newest at the top

2024-05-16 09:23:57 +0200frumon(~Frumon@user/Frumon)
2024-05-16 09:22:25 +0200 <tomsmeding> write-light, then
2024-05-16 09:22:17 +0200 <tomsmeding> :D
2024-05-16 09:21:41 +0200 <Axman6> actually that's not true, since things were only read when a uses used the webservice, which no one ever did =)
2024-05-16 09:21:39 +0200sawilagar(~sawilagar@user/sawilagar)
2024-05-16 09:21:05 +0200 <Axman6> yeah - which my one use case for this particular design was =)
2024-05-16 09:20:44 +0200 <tomsmeding> also needs a read-heavy workload
2024-05-16 09:20:31 +0200 <tomsmeding> but if that's enough, it's nice
2024-05-16 09:20:27 +0200 <tomsmeding> gets you a limited interface though, to the map
2024-05-16 09:20:20 +0200 <tomsmeding> neat
2024-05-16 09:20:00 +0200 <Axman6> but in the case where the key exists no synchronisation is needed
2024-05-16 09:19:49 +0200 <Axman6> of the threads*
2024-05-16 09:19:46 +0200 <tomsmeding> interesting
2024-05-16 09:19:21 +0200 <Axman6> the code above should handle that fine, since it uses atomicModifyIORef in the update case, only one of the can put their key in
2024-05-16 09:18:42 +0200 <tomsmeding> time-of-check to time-of-use race condition
2024-05-16 09:18:30 +0200 <tomsmeding> oh hm fair
2024-05-16 09:18:10 +0200 <c_wraith> so do I
2024-05-16 09:18:08 +0200 <Axman6> yes
2024-05-16 09:18:03 +0200 <tomsmeding> judging from the getRefForKey code
2024-05-16 09:17:53 +0200 <tomsmeding> c_wraith: I think Axman6 meant `IORef (Map Key (IORef Value))`
2024-05-16 09:17:43 +0200 <c_wraith> It also assumes you never have two threads trying to insert the same key at the same time.
2024-05-16 09:17:14 +0200 <Axman6> this also assumes you never delete keys (use Maybe (IORef Value)) then)
2024-05-16 09:16:46 +0200 <Axman6> oh and the Just case for the first case uses the value returned
2024-05-16 09:16:28 +0200 <Axman6> (missing `old` in the Map.insert but that should work)
2024-05-16 09:15:37 +0200 <c_wraith> I'm not even sure it can be used safely. If you look at the Map and determine you need to insert a new key/value pair, you can't do that from within an atomicModifyIORef
2024-05-16 09:15:20 +0200 <Axman6> getRefForKey outer key = do exists <- Map.lookup key <$> readIORef ref; case exists of Nothing -> do newRef <- newIORef; atomicModifyIORef ref (\old -> case Map.lookup key old of Nothing -> (Map.insert key newRef, newRef); Just race -> (old, race))
2024-05-16 09:13:09 +0200 <Axman6> it can be used safely, you just wrap things in a safe interface
2024-05-16 09:11:56 +0200emmanuelux(~emmanuelu@user/emmanuelux) (Quit: au revoir)
2024-05-16 09:10:14 +0200 <c_wraith> It's begging to introduce race conditions
2024-05-16 09:09:40 +0200 <c_wraith> that last one is dangerous
2024-05-16 09:08:57 +0200kuribas`(~user@2a02:1808:8:dd22:98a8:ccd5:a4c3:db95) (Ping timeout: 256 seconds)
2024-05-16 09:08:08 +0200 <Axman6> yeah definitely, and can also lead to less contention on shared values - the difference between n IORef (Map Key Value) and Map Key (IORef value) (or even IORef (Map Key (IORef Value)) might make significant performance differences.
2024-05-16 09:06:18 +0200euleritian(~euleritia@ip4d16fc38.dynamic.kabel-deutschland.de)
2024-05-16 09:06:00 +0200euleritian(~euleritia@dynamic-176-006-196-153.176.6.pool.telefonica.de) (Read error: Connection reset by peer)
2024-05-16 09:03:05 +0200 <tomsmeding> having transactions sometimes relieves you of a whole lot of trouble in designing your data structures and methods
2024-05-16 09:02:41 +0200sord937(~sord937@gateway/tor-sasl/sord937)
2024-05-16 09:02:13 +0200 <tomsmeding> many concurrent algorithms can be written in a non-blocking way (there's even a theorem that "all" can, in some sense, iirc), but that's not always the most efficient or most understandable way
2024-05-16 09:02:07 +0200kuribas(~user@2a02:1808:2:a50c:ee7a:245e:1a98:7ade) (Ping timeout: 255 seconds)
2024-05-16 09:01:27 +0200 <tomsmeding> in concurrency terminology, atomicModifyIORef is non-blocking, which means a certain progress guarantee for your program (as long as you don't go implementing a lock yourself using atomicModifyIORef, which is possible)
2024-05-16 09:00:37 +0200kuribas`(~user@2a02:1808:8:dd22:98a8:ccd5:a4c3:db95)
2024-05-16 09:00:33 +0200 <tomsmeding> atomicModifyIORef is a great building block for concurrent programs, but sometimes you need more
2024-05-16 09:00:11 +0200 <tomsmeding> the memory model thing with IORefs indeed refers to the methods outside of the atomic* family
2024-05-16 08:58:10 +0200Square(~Square@user/square) (Ping timeout: 246 seconds)
2024-05-16 08:58:09 +0200ft(~ft@p508db8fc.dip0.t-ipconnect.de) (Quit: leaving)
2024-05-16 08:55:51 +0200Square2(~Square4@user/square)
2024-05-16 08:51:28 +0200califax(~califax@user/califx)
2024-05-16 08:50:36 +0200kuribas(~user@2a02:1808:2:a50c:ee7a:245e:1a98:7ade)
2024-05-16 08:49:24 +0200califax(~califax@user/califx) (Read error: Connection reset by peer)
2024-05-16 08:48:29 +0200m1dnight(~christoph@82.146.125.185)
2024-05-16 08:48:13 +0200califax(~califax@user/califx)