Skip to content
HomeVideosBooksBlogs
AllTop postsTopics
Podcasts
HistoryListsWatch laterLiked videosFollowing

The videos, books, blogs and podcasts Hacker News keeps recommending, all in one place.

VideosBooksBlogsPodcastsAboutPrivacySettings

Data from Hacker News, HackerTube, HackerBooks, HackerBlogs and Open Library. Credits · Not affiliated with Y Combinator.

HomeVideosBooksBlogsPodcasts
Ctrl K
    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.

    Visit blogHN submissions
    ProgrammingSystems & PerformanceLanguages & Compilers
    What HN says

    Commenters 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.

    Stats for nerds
    26HN people shared it
    14linked in comments
    166story points
    Jan 2013last shared
    2009people per year2013

    Top posts on HN

    1. 1
      Volatile is Evil
      2 people · 70 points · first shared 2011 · 20 comments on HN
    2. 2
      Misunderstanding the Knuth premature optimization quote
      2 people · 34 points · first shared 2010 · 8 comments on HN
    3. 3
      Imperative + Functional == :-)
      1 person · 33 points · first shared 2012 · 22 comments on HN
    4. 4
      A (brief) retrospective on transactional memory
      10 people · 15 points · first shared 2010 · 2 comments on HN
    5. 5
      On (Haskell) Type Classes and (C#) Interfaces
      2 people · 5 points · first shared 2010 · Discussion on HN
    6. 6
      More Thoughts on Transactional Memory
      1 person · 3 points · first shared 2010 · Discussion on HN
    7. 7
      Thoughts on immutability and concurrency
      2 people · 2 points · first shared 2010 · Discussion on HN
    8. 8
      Beware the string
      1 person · 1 points · first shared 2012 · Discussion on HN
    9. 9
      A brief note on .NET object mortality
      1 person · 1 points · first shared 2011 · Discussion on HN
    10. 10
      A brief note on object mortality
      1 person · 1 points · first shared 2011 · Discussion on HN

    What HN people wrote when they linked it

    • sedachvJul 2010

      "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…

    • barrkelJul 2010

      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/BuildingACustomThreadPoolSeriesPart3IncorporatingWorkStealingQueues.aspx

      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…

    • enigmoJan 2013

      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/ABriefRetrospectiveOnTransactionalMemory.aspx

    • pragmaticJun 2011

      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/ThePrematureOptimizationIsEvilMyth.aspx

    • sharkbotJun 2011

      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/ABriefRetrospectiveOnTransactionalMemory.aspx (currently down, but Google has a cached copy)

    • fiatmoneyJun 2012

      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/ABriefRetrospectiveOnTransactionalMemory.aspx

    Related

    Jon Skeetmsmvps.com44 people

    OMG Ponies (Aka Humanity: Epic Fail)

    Jon Skeet
    Personal · last shared 2014
    Flying Frog Blogflyingfrogblog.blogspot.com30 people

    Disadvantages of purely functional programming

    Flying Frog Blog
    Personal · last shared 2019
    Existential Typeexistentialtype.wordpress.com157 people

    Haskell Is Exceptionally Unsafe (2012)

    Existential Type
    Personal · last shared 2026
    Probably Danceprobablydance.com74 people

    Fibonacci Hashing: The Optimization That the World Forgot

    Probably Dance
    Personal · last shared 2026
    Herb Suttergotw.ca84 people

    Ritchie, Stroustrup, and Gosling interview

    Herb Sutter
    Personal · last shared 2026
    composition.alcomposition.al45 people

    My first fifteen compilers

    composition.al
    Personal · last shared 2022
    Paul Khuongpvk.ca106 people

    SBCL: The Ultimate Assembly Code Breadboard

    Paul Khuong
    Personal · last shared 2026
    Bryan O'Sullivanserpentine.com49 people

    Github is making me feel stupid(er)

    Bryan O'Sullivan
    Personal · last shared 2021