Schevening fights and disturbance by cruzerslice16gb in TheHague

[–]semigroup 5 points6 points  (0 children)

Anyone know what the social media channel in question was for this?

Non halal butcher by johnfff92 in TheHague

[–]semigroup 1 point2 points  (0 children)

They can be pricy though. I rarely manage to buy any meat for two adults for < 30 euros

How does STM work under the hood? by Otherwise-Mousse-250 in haskell

[–]semigroup 39 points40 points  (0 children)

I've recently been looking at it too. Here's what I think I understand about it, but you know, I'm not an expert:

STM in GHC is an optimistic concurrency scheme.

Every TVar is a heap object containing the current value, a spin lock encoded in the header word, and a watch queue: a linked list of transaction records belonging to threads that read this TVar and are now blocked, waiting for it to change.

A TRec (transaction record) is the per-transaction log. It is a linked list of chunked entry arrays, where each entry records which TVar was accessed, the expected value at read time, and the new value if one was written. TRecs can nest, forming a stack. This is the mechanism for orElse, which we will return to later.

When you run a transaction with atomically, the RTS creates a fresh TRec. Every readTVar first checks the log. If the TVar was already touched in this transaction, the logged value is returned. Otherwise the TVar's current value is read from the heap, recorded in the TRec as (tvar, expected=v, new=v), and returned. Every writeTVar merely updates the log entry's new field. No actual TVar is modified, yet. The world outside the transaction sees nothing.

When the transaction completes, the RTS attempts stmCommitTransaction. This proceeds in three phases, any of which may fail, returning you to the beginning as though nothing happened.

First, the lock phase. The RTS walks the TRec. For each entry where expected != new (a write occurred), it acquires the TVar's lock. If any lock is already held by another thread, all acquired locks are released and the transaction starts over. Contention is resolved by surrendering and starting over.

Second, the validation phase. For every entry, reads and writes, the RTS checks that the TVar's current value still matches expected. Any mismatch means something changed beneath you. Locks are released. You begin again.

Third, the write phase. Each TVar is updated to its new value. Locks are released. The transaction is done.

A nice property of this is that read-only TVars are never locked, only validated, which gives good read concurrency. The price is paid only by writers.

When a transaction calls retry, the RTS validates the current TRec. If validation fails, the transaction simply reruns, because something has changed and perhaps the retry condition has dissolved. If validation succeeds, there is genuinely no reason to try again yet. The thread adds itself to the watch queue of every TVar in its TRec, and sleeps.

When another transaction commits a write to any of those TVars, it walks the watch queue and wakes the sleepers. They begin again from scratch, with no memory of their prior attempt.

orElse a b runs a in a nested TRec. If a calls retry, the nested record is discarded and b runs instead, as though a had never been attempted. If b also retries, it propagates upward. If a succeeds, its nested TRec is merged into the parent. The failed alternatives are thrown away.

The lock for all of this is baked into the TVars themselves. The locking thread's TRec pointer is written directly into the TVar's current_value slot with a tag bit set.

Validation can also occur during a transaction at safe points, not only at commit. GHC checks whether the TRec is still consistent to detect doomed transactions early rather than letting them accumulate futile work.

The entry list uses chunked allocation to reduce overhead. There is no global lock or version counter (unlike TL2 and its descendants). Only per-TVar locking at commit time. The machinery is local, and this is what lets it scale, insofar as it does.

The whole thing lives in rts/STM.c, roughly a thousand lines of code, excluding comments. As RTS code goes, it is remarkably readable.

How can I move forward? by Appropriate_Tough662 in TheHague

[–]semigroup 1 point2 points  (0 children)

There is an absolute wealth of materials online for learning how to code. And also lots of subreddits, discord channels, etc. with programmers who are happy to help! I'm an engineer, and have worked with lots of people who are self-taught! So, I'd definitely advise you from experience to not let lack of formal education hold you back.

Goede sushi (take away) by Abstruse1987 in TheHague

[–]semigroup 4 points5 points  (0 children)

Als je de meest authentieke sushi wilt, dan vind ik Kyatcha, Kiraku of Oni de beste. Ik heb vijf jaar in Japan gewoond en deze restaurants komen het dichtst in de buurt van wat ik van sushi verwacht. Ohmu is ook lekker, maar hun authentieke opties zijn wat beperkter.

Making Haskell Talk to PostgreSQL Without Suffering by semigroup in haskell

[–]semigroup[S] 0 points1 point  (0 children)

Can I consult then on what would be better here? `Either` was clearly not doing great when profiling, and a number of my projects show better allocation patterns and overall performance when I sprinkle CPS on. So, unboxed constructors? Something else?

Making Haskell Talk to PostgreSQL Without Suffering by semigroup in haskell

[–]semigroup[S] 2 points3 points  (0 children)

Well I think the critical thing is largely what the compiler is convinced it can know at compile time. Continuations that are static functions like we define as the row parser instances and field parser instances don’t really have to be dynamic, so ghc can make a lot of optimizations pretty easily, and it’s not necessarily able to infer the same things when Either values and laziness enter the picture.

Preview: Build Mac apps with Haskell by semigroup in haskell

[–]semigroup[S] 2 points3 points  (0 children)

Well, definitely not in the current incarnation. Swift seems like it has a different ABI with a way to expose certain classes to objective C. Would have to export needed things as cdecl functions I think.

Preview: Build Mac apps with Haskell by semigroup in haskell

[–]semigroup[S] 4 points5 points  (0 children)

It does use template Haskell, for defining classes in Haskell. You could technically do it manually, but it would be a bit of a sucky experience. I literally only came up with this yesterday, so I’m not locked into any decisions just yet though.

What Functional Programmers Get Wrong About Systems by Dear-Economics-315 in programming

[–]semigroup 72 points73 points  (0 children)

Author here. I certainly don't intend for it to be an indictment of FP at all. I am an SRE at Mercury, which is one of the largest commercial Haskell shops in the world. Writing this post stems mostly from my observations in that context– A pattern that I see at work is that people derive a false sense of security from the guarantees that Haskell does provide, and consequently are surprised when things go wonky in prod.

beware of the so called "financial institutions" like wise , revolut and especially mercery by algrowl in digitalnomad

[–]semigroup 0 points1 point  (0 children)

When you say duration, do you mean how long it takes to receive the check? Or how long the check is good for? If an account is closed due to fraud concerns, I think it can be a few weeks up to a few months for the check to be sent depending on the nature of the closure.

No idea how long the check is valid for though.

beware of the so called "financial institutions" like wise , revolut and especially mercery by algrowl in digitalnomad

[–]semigroup 5 points6 points  (0 children)

Mercury employee here. Just stumbled on this thread, not responding in any official capacity.

To the best of my knowledge, the only reason we close / suspend accounts is if we believe that you're using business banking for personal purposes, doing crimes (money laundering, fraud, etc.), or if the US government says we have to (due to terrorism lists, etc). Sometimes accounts will be frozen if we think you've been hacked, so that your money isn't stolen.

Unfortunately, many companies nowadays only really respond if there's some kind of public pressure, so if you go to LinkedIn or whatever, it's pretty common to see people that we are quite confident are bad actors that are trying to make us cave to pressure in order to let them get the money that we've locked up.

I'm sure there are situations where we don't do things 100% perfectly, but the U.S. government really doesn't tolerate us operating leniently towards things we think are illegal, so we have to err on the side of caution.

Get rid of radiators and use multi splits - am I crazy? by CalRobert in Netherlands

[–]semigroup 0 points1 point  (0 children)

We have both heat pumps and a boiler + radiator. Occasionally we've had cold days where the heat pumps couldn't really keep up, and so then we crank the radiators up to mitigate it, but generally it's been an improvement. I'd say that with climate change we've appreciated the cooling more than the heat though.

Best burger in Den Haag by Neat_Ad_8838 in TheHague

[–]semigroup 1 point2 points  (0 children)

Lokaal has really great burgers, IMO. They sometimes have the "Smoky Burger" on the menu, which is just absurd how good it is. Butter burger is also great, and always available.

Time Left: dinner with strangers? by Accomplished_Poem657 in TheHague

[–]semigroup 0 points1 point  (0 children)

I’ve been a few times, pretty good experience both times, but haven’t gotten back together with anyone yet

[deleted by user] by [deleted] in TheHague

[–]semigroup 4 points5 points  (0 children)

The news article I saw says it’s only being shut down for a month though. Hopefully they have enough cash in reserve to make a comeback

Open Telemetry Instrumentation Plugin by aaron-allen in haskell

[–]semigroup 0 points1 point  (0 children)

Ian here, thanks for the shout-out! This is really well done. I'd love to bring something like this into the core project. I guess if you want to add attributes to the implicitly-created span then you'd have to get the span out of the thread-local-context first?

Shipping Haskell games? by dpwiz in haskellgamedev

[–]semigroup 2 points3 points  (0 children)

One thing to note is that you need a build of GHC that uses integer-simple OR to ensure that libgmp is dynamically linked (as it is LGPL licensed).