Discussion
Loading...

Post

  • About
  • Code of conduct
  • Privacy
  • About Bonfire
Glyph
@glyph@mastodon.social  ·  activity timestamp 13 hours ago

I am simultaneously excited for the implementation techniques that #python free threading is going to open up for framework authors and deeply concerned about the way I see discussions going around it, as it seems application authors will be speedrunning the “you can fit so many untestable data races in here” to “you can fit so many intractable mutex deadlocks in here” pipeline that java previewed for us all in the early aughts

  • Copy link
  • Flag this post
  • Block
Tim Lavoie
@tim_lavoie@cosocial.ca replied  ·  activity timestamp 6 hours ago

@glyph I wonder if there are any applicable lessons that could be taken from #ocaml, whichhas implemented multi-core in recent years?

  • Copy link
  • Flag this comment
  • Block
craterm🎃🎃n
@cratermoon@zirk.us replied  ·  activity timestamp 9 hours ago

@glyph Why Threads Are A Bad Idea (for most purposes), John Ousterhout: https://www.cc.gatech.edu/classes/AY2010/cs4210_fall/papers/ousterhout-threads.pdf and https://ieeexplore.ieee.org/document/1631937

The problem with threads

For concurrent programming to become mainstream, we must discard threads as a programming model. Nondeterminism should be judiciously and carefully introduced where needed, and it should be explicit in programs. In general-purpose software engineering practice, we have reached a point where one approach to concurrent programming dominates all others namely, threads, sequential processes that share memory. They represent a key concurrency model supported by modern computers, programming languages, and operating systems. In scientific computing, where performance requirements have long demanded concurrent programming, data-parallel language extensions and message-passing libraries such as PVM, MPI, and OpenMP dominate over threads for concurrent programming. Computer architectures intended for scientific computing often differ significantly from so-called general-purpose architectures.
View (PDF)
  • Copy link
  • Flag this comment
  • Block
Glyph
@glyph@mastodon.social replied  ·  activity timestamp 9 hours ago

@cratermoon I am … familiar. I have probably cited this article 1000 times. most recently, https://mastodon.social/@glyph/115345123317563644

  • Copy link
  • Flag this comment
  • Block
James Henstridge
@jamesh@aus.social replied  ·  activity timestamp 11 hours ago

@glyph Does it make that much of a difference for pure Python code? You might not hit the performance wall that'd push you towards a multi-process solution as quickly, but you already needed to deal with execution in other threads being interleaved with your own thread.

I think a bigger problem might end up being updated versions of extensions claiming to support nogil but not quite getting it right (either not locking their own data structures, or incorrectly relying on a borrowed reference to some PyObject).

  • Copy link
  • Flag this comment
  • Block
Glyph
@glyph@mastodon.social replied  ·  activity timestamp 10 hours ago

@jamesh code that was wrong before will still be wrong, code that was correct before will still be correct. but a lot of wrong code will probably have been working most of the time in prod, only occasionally behaving a bit weird, and the huge explosion of potential switch points will reveal plenty of bugs that were accidentally, stochastically protected by the GIL’s accidental block-of-bytecode boundaries

  • Copy link
  • Flag this comment
  • Block
James Henstridge
@jamesh@aus.social replied  ·  activity timestamp 6 hours ago

@glyph I would have thought there were enough opportunities for thread switches for that it would be hard to rely on the GIL from pure Python code.

That seems quite different to extensions, where they would traditionally know that no other thread could be touching the interpreter, and exactly where that lock would be released.

  • Copy link
  • Flag this comment
  • Block
Glyph
@glyph@mastodon.social replied  ·  activity timestamp 8 hours ago

@jamesh basically I think that the same problems apply in C and in Python, but in C the consequences are probably a lot more immediate and dramatic (segfaults, etc)

  • Copy link
  • Flag this comment
  • Block
Glyph
@glyph@mastodon.social replied  ·  activity timestamp 12 hours ago
the "it is 1985" comic from Watchmen, with the three panels captioned:

"It is 2000. I'm having a conversation about how it is impossible to debug shared-state multi-threaded code in Java."

"It is 2005. I'm having a conversation about how it is impossible to debug shared-state multi-threaded code in C++."

"It is 2025. I'm having a conversation about how it's impossible to debug shared-state multi-threaded code in Python"
the "it is 1985" comic from Watchmen, with the three panels captioned: "It is 2000. I'm having a conversation about how it is impossible to debug shared-state multi-threaded code in Java." "It is 2005. I'm having a conversation about how it is impossible to debug shared-state multi-threaded code in C++." "It is 2025. I'm having a conversation about how it's impossible to debug shared-state multi-threaded code in Python"
the "it is 1985" comic from Watchmen, with the three panels captioned: "It is 2000. I'm having a conversation about how it is impossible to debug shared-state multi-threaded code in Java." "It is 2005. I'm having a conversation about how it is impossible to debug shared-state multi-threaded code in C++." "It is 2025. I'm having a conversation about how it's impossible to debug shared-state multi-threaded code in Python"
  • Copy link
  • Flag this comment
  • Block
Joff
@joffotron@aus.social replied  ·  activity timestamp 2 hours ago

@glyph It's 1986 and the Erlang folks are like... you don't have to do it like that

It's 2025 and the Elixir people are still absolutely insufferable about it

(it's me, I'm being insufferable about it)

  • Copy link
  • Flag this comment
  • Block
Delphi
@Delphi@mastodon.scot replied  ·  activity timestamp 3 hours ago

@glyph
Prequel
It's 1999 and I'm kicking myself for not keeping practiced on COBOL

  • Copy link
  • Flag this comment
  • Block
Robert Brewer
@fumanchu@fosstodon.org replied  ·  activity timestamp 11 hours ago

@glyph this might be a good time to remind folks of https://pypi.org/project/diagnose/ whose Breakpoints allow you to pause and resume threads from some other thread.

Client Challenge

  • Copy link
  • Flag this comment
  • Block
Aaron Sawdey, Ph.D.
@acsawdey@fosstodon.org replied  ·  activity timestamp 12 hours ago

@glyph 😂 … I think in 1994 I was having conversations about how it was impossible to debug multithreaded shared-state code in FORTRAN.

  • Copy link
  • Flag this comment
  • Block
Glyph
@glyph@mastodon.social replied  ·  activity timestamp 12 hours ago

@acsawdey I'm tired of these languages, their programs. I'm tired of being caught in the tangle of their threads of execution

  • Copy link
  • Flag this comment
  • Block
Aaron Sawdey, Ph.D.
@acsawdey@fosstodon.org replied  ·  activity timestamp 12 hours ago

@glyph Parallel programming only works if you have an infinite supply of poorly paid grad students.

  • Copy link
  • Flag this comment
  • Block
Log in

Bonfire Dinteg Labs

This is a bonfire demo instance for testing purposes. This is not a production site. There are no backups for now. Data, including profiles may be wiped without notice. No service or other guarantees expressed or implied.

Bonfire Dinteg Labs: About · Code of conduct · Privacy ·
Bonfire social · 1.0.0-rc.3.15 no JS en
Automatic federation enabled
  • Explore
  • About
  • Code of Conduct
Home
Login