J
Joe Duffy
bluebytesoftware.com · Personal blog · on HN since 2009
Joe Duffy, a Microsoft engineer, writes about concurrency, transactional memory, type systems and performance in C# and related languages.
What HN saysCommenters call his transactional memory retrospective one of the best write-ups on building STM, and recommend it in discussions of parallelism and Python's GIL.
26HN people shared it
14linked it in comments
14stories submitted
166story points
14 years agolast shared
2009people per year2026
Most-shared posts
- 1A (brief) retrospective on transactional memory10 people · 15 points · first shared 2010 · 2 comments on HN
- 2Volatile is Evil2 people · 70 points · first shared 2011 · 20 comments on HN
- 3Misunderstanding the Knuth premature optimization quote2 people · 34 points · first shared 2010 · 8 comments on HN
- 4On (Haskell) Type Classes and (C#) Interfaces2 people · 5 points · first shared 2010 · discussion on HN
- 5Thoughts on immutability and concurrency2 people · 2 points · first shared 2010 · discussion on HN
- 6Default2 people · first shared 2010
- 7Imperative + Functional == :-)1 people · 33 points · first shared 2012 · 22 comments on HN
- 8More Thoughts on Transactional Memory1 people · 3 points · first shared 2010 · discussion on HN
- 9A brief note on object mortality1 people · 1 points · first shared 2011 · discussion on HN
- 10A brief note on .NET object mortality1 people · 1 points · first shared 2011 · discussion on HN
- 11Beware the string1 people · 1 points · first shared 2012 · discussion on HN
- 12A scalable reader/writer scheme with optimistic retry1 people · 1 points · first shared 2009 · discussion on HN
- 13BuildingACus...1 people · first shared 2010
- 14Default1 people · first shared 2009
- 15PermaLink,guid,4db70333 295b 441f 80f9 21b90bd442871 people · first shared 2010
What HN people wrote when they linked it
enigmo · 2013-01-22
Type-inference doesn't provide anything related to parallel maps, though Haskell's type system can verify that they're safe. Switching an arbitrary loop to a parallel one in C#, Scala, Java, whatever, is certainly a crapshoot.
The real benefit to purity and laziness (imo) is the STM. The type system (and pure functions) allow rerunning transactions arbitrarily without worry about side effects, and laziness by default minimizes lock contention by deferring most code execution outside of the transaction block. Joe Duffy has a pretty good writeup a few years ago outlining the difficulty of writing an STM for languages without such guarantees, it's definitely worth a read: http://www.bluebytesoftware.com/blog/2010/01/03/ABriefRetrospectiveOnT…
kenjackson · 2011-11-30
Joe Duffy wrote one of the best posts on experiences building STM. Well worth a read if you found Hichey's post interesting:
http://www.bluebytesoftware.com/blog/2010/01/03/ABriefRetrospectiveOnT…
surrealize · 2011-08-24
There's a great, very detailed retrospective on Microsoft's STM implementation efforts here:
http://www.bluebytesoftware.com/blog/2010/01/03/ABriefRetrospectiveOnT…
sharkbot · 2011-06-29
I'm not clear on the desired result of this project. Is it to make currently-unsafe Python code automatically correct? Or is it to keep the GIL semantics, but make it faster?
If it is the former, then I worry. Software transaction memory is hard to get right in languages without explicit and trustworthy annotations for side-effecting code (ie, types) [1].
1) http://www.bluebytesoftware.com/blog/2010/01/03/ABriefRetrospectiveOnT… (currently down, but Google has a cached copy)
safetytrick · 2010-09-10
this article on when to use algorithms is great: http://www.bluebytesoftware.com/blog/PermaLink,guid,4db70333-295b-441f…
hairsupply · 2009-03-10
The people who I work with whom I regard as great hackers work almost exclusively in the real time embedded space (industrial automation systems) and don't have web notoriety.
Slightly more prominent individuals could include Ted Neward (http://blogs.tedneward.com), Joe Duffy (http://www.bluebytesoftware.com/blog/default.aspx), James Devlin(http://www.codingthewheel.com/archives/how-i-built-a-working-poker-bot… and Dustin Campbell (http://diditwith.net)
sedachv · 2010-07-09
"What makes you think that a thread pool dispatching events would use a lock? No modern efficient thread pool implementation dispatching work items is serialized by a single lock, to my knowledge."
Are you talking about thread-safe queues implemented using atomic instructions? Those aren't free - how do you think they're implemented at the hardware level? The main advantage of atomic instructions over locks is removing the possibility of waiting on a preempted thread holding the lock (lock-freedom). They also have lower overhead than making system calls to provide locking. But the equivalent mutual exclusion logic (and contention penalties) just get moved down to the chipset level - now instead of waiting on other threads, you're waiting on other cores/CPUs.
"What you ought to have is multiple async accept calls outstanding, and as they complete they are entered into work queues. Worker threads (i.e. the thread pool) pulling work of those queues should steal work from other queues when their own queue is empty.
See e.g. http://www.bluebytesoftware.com/blog/2008/09/17/BuildingACus...
That article is horrible. Please do not follow the author's advice.
Besides the fact that the code deadlocks (see the first comment on the article), it's also easy to see that if one thread starts generating all the work the "solution" is going to become a single global queue (the "local work stealing queue" of that thread), with all the other threads looping through the global queue and then…
fiatmoney · 2012-06-10
Microsoft's experiment with STM ended up not going so well [1] [2]. Does anyone know how the PyPy implementation differs, and if it might overcome these problems? Is it just laying the groundwork for leveraging hardware transactional memory support, or is the thesis that this will eventually become usable directly?
[1]http://www.infoq.com/news/2010/05/STM-Dropped
[2]http://www.bluebytesoftware.com/blog/2010/01/03/ABriefRetrospectiveOnT…
Jach · 2011-09-30
It may be a good question, but asking it and then ignoring it by not throwing out ideas for discussion is almost as useless as not asking it at all. e.g. regarding volatile: http://www.bluebytesoftware.com/blog/2010/12/04/SayonaraVolatile.aspx
pragmatic · 2011-06-20
2 things:
1):
Most projects that I've used c# for just aren't performance constrained. What's more important for us is the productivity dimension. We have _lots_ of hardware. We have a few programmers.
I've actually just finished the _only_ c# program that had a performance aspect. It was/is an in-house search engine. I profiled it, fixed the hotspots and it's fast enough.
2:
MSFT Marketing. Linq|dynamic are heavily sold by Microsoft. You'll have to read Joe Duffy's blog for actual performance advice: http://www.bluebytesoftware.com/blog/2010/09/06/ThePrematureOptimizati…
cageface · 2010-08-03
Interesting that he's so gung-ho about STM when the Microsoft paper sounds so pessimistic:
http://www.bluebytesoftware.com/blog/2010/01/03/ABriefRetrospectiveOnT…
The more I read about these new approaches to concurrency the more I suspect that there's going to be no free lunch. Concurrent programs are going to require careful, bottom-up design with concurrency in mind and concurrent design is going to remain a difficult thing.
gtani · 2010-07-26
tehse 2 posts were useful in thinking about taxonomies/how to categorize concurrent/ threaded (and data parallel) tasks
http://blog.ezyang.com/2010/07/graphs-not-grids/
http://www.bluebytesoftware.com/blog/2010/07/12/ThoughtsOnImmutability…
barrkel · 2010-07-09
What makes you think that a thread pool dispatching events would use a lock? No modern efficient thread pool implementation dispatching work items is serialized by a single lock, to my knowledge.
What you ought to have is multiple async accept calls outstanding, and as they complete they are entered into work queues. Worker threads (i.e. the thread pool) pulling work of those queues should steal work from other queues when their own queue is empty.
See e.g. http://www.bluebytesoftware.com/blog/2008/09/17/BuildingACustomThreadP…
Pulling items off a queue, either by its associated worker thread or another worker thread stealing its work should be lock-free.
As I mentioned elsewhere, GC is not necessarily (or even often) the most efficient approach for request / response style servers. A more optimal approach is a heap associated with the request which can be freed in a single go when the request is done with, with all allocations associated with that request (i.e. that don't need to persist between requests) coming out of that heap.
You can even design a GC around this principle: have one GC heap per worker thread, and collect it after every request has been processed. There should be little or no roots for this heap associated with the worker itself, which should be (very) low down in its call stack after it is done with the request. If you have write barriers for any mutations to inter-request (shared) state, you can…