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 | Matti: I made a bit of progress, the tests now only segfault towards the end
jinsun has quit [Read error: Connection reset by peer]
epony has quit [Ping timeout: 252 seconds]
epony has joined #pypy
epony has quit [Ping timeout: 252 seconds]
epony has joined #pypy
jcea has quit [Ping timeout: 246 seconds]
EWDurbin has quit [Read error: Connection reset by peer]
graingert has quit [Read error: Connection reset by peer]
EWDurbin has joined #pypy
graingert has joined #pypy
jean-paul[m] has quit [Ping timeout: 246 seconds]
jevinskie[m] has quit [Ping timeout: 246 seconds]
Atque has joined #pypy
jean-paul[m] has joined #pypy
jevinskie[m] has joined #pypy
epony has quit [Ping timeout: 252 seconds]
epony has joined #pypy
chromebittin has joined #pypy
chromebittin has joined #pypy
chromebittin has quit [Changing host]
chromebittin has left #pypy [#pypy]
otisolsen70 has joined #pypy
otisolsen70 has quit [Remote host closed the connection]
otisolsen70 has joined #pypy
epony has quit [Quit: QUIT]
epony has joined #pypy
epony has quit [Remote host closed the connection]
epony has joined #pypy
dmalcolm has joined #pypy
dmalcolm__ has quit [Ping timeout: 248 seconds]
otisolsen70 has quit [Quit: Leaving]
otisolsen70 has joined #pypy
otisolsen70 has quit [Remote host closed the connection]
otisolsen70 has joined #pypy
<antocuni> CPython 3.12 will support perf
<antocuni> and you'll get flamegraphs with Python + C frames
<cfbolz> Yeah, they use jit maps
<antocuni> yes but how do they distinguish the various calls to PyEval_EvalFrame? Do they generate a small trampoline for every code object?
<antocuni> ah, it seems so, it's briefly explained here: https://docs.python.org/pl/dev/howto/perf_profiling.html
<cfbolz> antocuni: did you find the code yet? Does it mean they have a tiny jit? ;-)
<antocuni> according to this tweet, yes: https://twitter.com/pyblogsal/status/1587178352976269313
<antocuni> I remember I wanted to try something like that for vmprof, but I think I never tidd
<antocuni> *did
<antocuni> in particular, I think that a JIT is not necessarily needed: in theory, all these trampolines are the same, so you could just compile a "template" C trampoline and memcpy it around, I *think*
<cfbolz> antocuni: yes but that depends on a huge amount of details too
<cfbolz> antocuni: why would that help for vmprof, btw?
<antocuni> yes; for example, it's easy to find the start of a function, but it's hard to find its end :)
<antocuni> cfbolz: the original implementation of vmprof used a hack to determine the python code object from the C stack frame: IIRC, the first argument of PyEval_EvalFrame was a PyFrameObject*, so we walked it until we found the name of the python function
<cfbolz> antocuni: ah, for the cpython version
<antocuni> like, doing f->f_code->co_name or something along those lines
<antocuni> yes
<antocuni> but if you have a trampoline, you can basically kill vmprof and use perf :). As they did now
<antocuni> I guess that at the time having a JIT inside CPython was considered a heresy. Things change :)
<cfbolz> Perf stack maps are quite a hack, fwiw
<cfbolz> They aren't easy to use for 'proper' jits
<antocuni> ah, according to this comment they to exactly what I described above: Notice that for this to work, there must be a unique copied of the trampoline
<antocuni> per Python code object even if the code in the trampoline is the same. To
<antocuni> achieve this we have a assembly template in Objects/asm_trampiline.S that is
<antocuni> compiled into the Python executable/shared library. This template generates a
<antocuni> symbol that maps the start of the assembly code and another that marks the end
<antocuni> of the assembly code for the trampoline. Then, every time we need a unique
<antocuni> trampoline for a Python code object, we copy the assembly code into a mmaped
<antocuni> area that has executable permissions and we return the start of that area as
<antocuni> our trampoline function.
<antocuni> ops sorry, I wanted to copy the link and not the full text :(
<antocuni> with the difference that they write the trampoline in assembler instead of C
<antocuni> ah, I see. By writing it in assembler they can put a global symbol which marks the *end* of the function, which was exactly the problem which I stumbled upon too\
dmalcolm_ has joined #pypy
<cfbolz> antocuni: you can get that in C too with some tricks
<cfbolz> But yes, all somewhat messy
<cfbolz> antocuni: I suppose the trampolines leak in cpython?
dmalcolm has quit [Ping timeout: 252 seconds]
<cfbolz> antocuni: I think they have to, perf jit maps don't support reusing an address for a different function later
<antocuni> I suppose that in theory they could free trampolines when they are not needed and try to remember the address to avoid reusing it. But they are allocated in big arena blocks, so in practice I guess they will always survive and leak (but didn't look at the actual implementation)
<cfbolz> It's a tiny amount of bytes only of course
derpydoo has joined #pypy
jcea has joined #pypy
derpydoo has quit [Ping timeout: 268 seconds]
glyph has quit [Quit: End of line.]
glyph has joined #pypy
[m]alice is now known as alice
<cfbolz> mattip: wow, bpnn.py
<cfbolz> That takes me back
<cfbolz> That was really before the AI resurgence :-)
<mattip> someone on stack overflow asked about python ./rpython/translator/goal/translate.py program.py
<mattip> which got me to try to find where in the documentation we mention that
<mattip> bpnn was the only place I found
<mattip> and it isn't even part of the html documentation
derpydoo has joined #pypy
derpydoo has quit [Ping timeout: 255 seconds]
derpydoo has joined #pypy
antocuni[m] has joined #pypy
glyph_ has joined #pypy
glyph has quit [Ping timeout: 252 seconds]
glyph_ is now known as glyph
otisolsen70_ has joined #pypy
otisolsen70_ has quit [Remote host closed the connection]
otisolsen70 has quit [Ping timeout: 272 seconds]
derpydoo has quit [Ping timeout: 255 seconds]
derpydoo has joined #pypy
epony has quit [Quit: QUIT]
epony has joined #pypy
dustinm has quit [Quit: Leaving]
dustinm has joined #pypy
jinsun has joined #pypy
derpydoo has quit [Ping timeout: 255 seconds]