cfbolz changed the topic of #pypy to: #pypy PyPy, the flexible snake https://pypy.org | IRC logs: https://quodlibet.duckdns.org/irc/pypy/latest.log.html#irc-end and https://libera.irclog.whitequark.org/pypy | insert pithy quote here
fotis has quit [Ping timeout: 268 seconds]
fotis has joined #pypy
fotis has quit [Ping timeout: 268 seconds]
fotis has joined #pypy
fotis has quit [Ping timeout: 265 seconds]
yizawa has quit [Quit: Connection closed for inactivity]
rindolf has joined #pypy
fotis has joined #pypy
yizawa has joined #pypy
fotis has quit [Ping timeout: 252 seconds]
<arigato> ctismer: hi! I'm debugging a test using stackless, so it's good that you're here :-)
<arigato> somebody is having stacklet objects and calling their .run() method repeatedly. Is that an expected use case? In PyPy it leaks because it keeps adding the same tasklet object in the internal list _squeue, where it ends up several times
<arigato> never mind, reading the docs now
<arigato> seems like a pypy bug
<ctismer> arigato: Hi Armin, nice to meet you. The stackless.run method is usually started from the main taslet and serves as event loop, as I remember. For sure, run is not meant to be called more than once. In CPython stackless, I think it would be even forbidden.
<ctismer> arigato: But I actually have to look it up, did not care for ten years.
<ctismer> If PyPy allows more than one call of run, I guess this should be fixed, yes :-)
<arigato> nice to meet you again, indeed!
<arigato> no, I'm talking about tasklet.run() to run a specific tasklet
<arigato> and if you're interested, https://foss.heptapod.net/pypy/pypy/-/issues/3556 is the issue, where the stackless issue shows up even without cffi embedding
fotis has joined #pypy
fotis has quit [Ping timeout: 268 seconds]
<ctismer> arigato: ah, sorry. Still in bed. Will read that. I think that stuff comes from the time where I had not implemented channels. The anonymous usage of tasklets via channels is much more elegant. Tasklet.run often used shows that someone should rewrite/think his code. (whow, people still use stachless)
<arigato> ah, I see. Yes, maybe we can poke the author of that issue in a different direction
<arigato> I think he wants embedding of Python into his C++ and he also wants the chunks of Python to be runnable concurrently (but cooperatively) to each other
<arigato> so more microthreads than real stackless-with-channels style
Atque has quit [Quit: ...]
<arigato> unsure what to suggest to him---maybe greenlets? or something else like using "yield"?
<ctismer> Ah! And since it‘s embedding in C++, it is most probably not cooperative multitasking. Yes, I guess greenlets do it better. And PyPy switches no stacks at all, right? So I‘d expect very many frames piling up.
<arigato> there's no soft-switching at all in pypy, if that's the question
otisolsen70 has joined #pypy
<ctismer> Yes, and if that is called from C++, how does he get back into the caller? He must return to the call site, or use hard switching. Does this work in PyPy?
<arigato> yes, it should, by always using hard-switching
<arigato> so the whole call stack should be correct at all points
<arigato> at least for the currently running tasklet
<ctismer> And PyPy uses the greenlet switching in principle? Well, imoressive.
<ctismer> Hmm. Now I lost the reason why that should not work. Has the guy tried his code with Stackless itself before using PyPy? (waking up…)
yizawa has quit [Quit: Connection closed for inactivity]
<arigato> I don't think so
<arigato> according to the documentation, though, it should not leak
greedom has joined #pypy
<ctismer> As I remember, Stackless has the circular list, and tasklet.run rotates the list only, so the tasklet comes next. If it‘s inserted multiple times in PyPy, that may be wrong.
<arigato> yes
<arigato> also it seems that tasklet.run(), tasklet.kill(), and other related methods have a complexity that is linear in the number of tasklets
<arigato> at least that's the case in pypy
<arigato> maybe Stackless Python was more clever and used a doubly-linked list which can be updated in constant time?
<arigato> pypy just uses a deque()
<arigato> and searches inside it with operator.indexOf()
<ctismer> Stackless used a double linked circle, methinks.
<arigato> OK, thanks. I don't think anyone really used stackless.py from pypy for anything serious, otherwise these bogus complexities would show up
<ctismer> The tasklets themselves have fore and back pointers. There was no list involved at all.
<arigato> makes sense
<ctismer> Yes, this is a rare case 🙂
greedom has quit [Remote host closed the connection]
greedom has joined #pypy
<ctismer> Actually, these fore and back pointers also built the channels. I carefully tried to make all operations as fast as possible.
<ctismer> Probably PyPy mostly kept the code the way as Stephan Diehl had written it. As CPython grows all its async stuff, there is probably no point in pushing PyPy.Stackless any further. (although I still think they should not build async on top of generators)
<arigato> yes, I think so too
* ctismer proposes linked tasklet lists as basic chains for PyPy, too. A tasklet can then never be in more that one chain by construction.
<ctismer> cfbolz: Yes, that was very interesting! I always had the impression that handling code by function is a somewhat arbitrary decision, but there could be other criteria as well to separate code chunks. (admittedly, it would be hard to invent new names for them)
<ctismer> cfbolz: (talking about your blog post about huge functions)
greedom has quit [Remote host closed the connection]
greedom has joined #pypy
greedom has quit [Remote host closed the connection]
greedom has joined #pypy
greedom has quit [Client Quit]
fotis has joined #pypy
greedom has joined #pypy
fotis has quit [Ping timeout: 265 seconds]
lritter has joined #pypy
<cfbolz> ctismer: you are correct
<cfbolz> That's a simplification of the blog post
<cfbolz> It's indeed not a function that I mark as huge
<cfbolz> But a 'tracing entry point'
lritter has quit [Ping timeout: 252 seconds]
<ctismer> cfbolz: ah, ok
fotis has joined #pypy
fotis has quit [Ping timeout: 260 seconds]
<ctismer> ronan: Back to the weirdness, there is sth. wrong in the type display.
<ctismer> This time not running it, since we know it crashes. https://www.irccloud.com/pastebin/nPefgoSV/pypy_crash.py
<ctismer> ronan: In short: Both PyPy and Python have a distinction between the `__new__` functions. But PyPy claims that the type is always the same! That must be a lie, and I'm working on that with lldb on lldebug.
<ctismer> ronan: the code never reaches pypy_g_PyType_FromSpecWithBases
otisolsen70_ has joined #pypy
otisolsen70 has quit [Ping timeout: 252 seconds]
ronan has quit [Ping timeout: 268 seconds]
otisolsen70_ has quit [Quit: Leaving]
ronan has joined #pypy
fotis has joined #pypy
fotis has quit [Ping timeout: 252 seconds]
Atque has joined #pypy
lritter has joined #pypy
greedom has quit [Remote host closed the connection]
Atque has quit [Quit: ...]
Atque has joined #pypy
greedom has joined #pypy
greedom has quit [Remote host closed the connection]
Atque has quit [Quit: ...]
greedom has joined #pypy
greedom has quit [Remote host closed the connection]
lritter has quit [Ping timeout: 265 seconds]
Julian has joined #pypy
greedom has joined #pypy
greedom has quit [Remote host closed the connection]
Julian has quit [Ping timeout: 268 seconds]
Julian has joined #pypy
tos9_ has joined #pypy
Julian has quit [Ping timeout: 260 seconds]
<ctismer> ronan: mattip: I found it! `PyObject_SetAttr` has in PyPy the side effect to call `PyType_Ready`. It still breaks, but at least the right `__new__` gets called 😜🥂
Atque has joined #pypy
tos9_ is now known as Julian
rindolf has quit [Ping timeout: 265 seconds]
Julian has quit [Quit: leaving]
Julian has joined #pypy
Atque has quit [Quit: ...]
lritter has joined #pypy
Julian has quit [Quit: leaving]
otisolsen70 has joined #pypy
lritter has quit [Quit: Leaving]
otisolsen70 has quit [Quit: Leaving]
rindolf has joined #pypy