GianlucaRizzo has quit [Remote host closed the connection]
GianlucaRizzo has joined #hpy
GianlucaRizzo has quit [Ping timeout: 256 seconds]
GianlucaRizzo has joined #hpy
Techcable has quit [Remote host closed the connection]
Techcable has joined #hpy
GianlucaRizzo has quit [Ping timeout: 248 seconds]
GianlucaRizzo has joined #hpy
GianlucaRizzo has quit [Ping timeout: 260 seconds]
GianlucaRizzo has joined #hpy
GianlucaRizzo has quit [Ping timeout: 256 seconds]
GianlucaRizzo has joined #hpy
GianlucaRizzo has quit [Ping timeout: 250 seconds]
antocuni has left #hpy [Leaving]
antocuni has joined #hpy
<fijal> antocuni: ping
<antocuni> pong
<fijal> ok, so if you have a sequence like this
<fijal> obj = malloc(obj), h1 = malloc(handle, obj), free(h1), stuff, h2 = malloc(handle, obj), free(h2)
<fijal> that's pretty normal right
<fijal> ?
GianlucaRizzo has joined #hpy
<antocuni> I'm not sure to understand the syntax; handles are not malloc()ed, they are indexes into a RPython list. You can open a new handle and this means putting the w_obj into the list (and closing the handle means to remove it from the list)
<fijal> "creation of handle"
<antocuni> ok
<fijal> ok, so the raw data that can be referenced has to survive between h1 = .... and free(h2)
<fijal> right?
<antocuni> not completely. The raw data has to survive for the whole lifetime of the object (obviously, because that's where the object lives!), but the ADDRESS of this data can change inside "stuff"
GianlucaRizzo has quit [Ping timeout: 260 seconds]
<fijal> I think you would need to have reference counting, because it seems like "gc.pin has to succeed" is a requirement
<fijal> and you would need to completely redesign our GC for the case of having too many pinned objects
<antocuni> yes, gc.pin has to succeed and yes, we need to improve our GC to do that
<fijal> I mean really, "redesign"
<fijal> it's not a simple improvement
<antocuni> that's not the impression which I got when talking to Armin, but maybe I misunderstood
<cfbolz> we should have a call
<cfbolz> this is not working
<antocuni> yes
<cfbolz> as a medium
<antocuni> but also, there is really no hurry
<fijal> cfbolz: why is it not working?
<antocuni> this is for improving the performance of hpy on pypy, but it's not the top priority
<antocuni> currently, there is no need for pinning because the C data is malloced() anyway
ronny has quit [Quit: Bridge terminating on SIGTERM]
jboi has quit [Quit: Bridge terminating on SIGTERM]
jevinskie[m] has quit [Quit: Bridge terminating on SIGTERM]
<antocuni> the pinning is needed if we decide to gc-allocate the hpy_data inside W_HPyObject, which is something which we cannot do right now anyway
<cfbolz> fijal: because you and anto are talking past each other
<cfbolz> antocuni: is it correct that for a purely python defined instance that you pass to C with HPy, everything is very efficient and you don't need pinning?
<fijal> no, I disagree
<antocuni> cfbolz: yes
<fijal> I maintain I perfectly understood what anto says
<fijal> the difference is "this is a small improvement to our GC" vs "this is a massive undertaking which requires quite careful redesign"
<fijal> I would not call it "talking past each other"
<antocuni> fijal: ok, but you are still talking about a hypotetical optimization which I'm not going to do anytime soon anyway :)
<fijal> yes yes, I'm only interested in the intellectual pursuit of what's feasible too :)
jboi has joined #hpy
<antocuni> so, this is a more precise outline of what's happening when you create an instance of a C-defined type: https://paste.openstack.org/show/bEBl0H9kQWYDHKTMlVxG/
ronny has joined #hpy
jevinskie[m] has joined #hpy
<cfbolz> antocuni: something I was wondering: in the current (non-optimized) model for C data, you find and move the object pointers in there in the GC how?
<antocuni> the C address of hpy_data must be fixed only between points 6 and 9, and only of the code calls HPy_AsStruct, and that's where pinning would be necessary
<cfbolz> 6 and 9?
<cfbolz> I want to know: a C object points to a Python list. how is the C data updated when the list moves?
<antocuni> cfbolz: not sure if I understand the question. In the current model, W_HPyObject is GC-managed and can mode, while W_HPyObject.hpy_data is malloced and has a fixed address for the whole lifetime
<antocuni> cfbolz: in that case I use an HPyField
<antocuni> which on PyPy they are implemented as gcrefs
<antocuni> and there is a custom GC tracer which calls the user-provided tp_traverse to know where they are
<antocuni> (that's what I'm doing these days)
<cfbolz> so every collect calls all these tp_traverse?
<antocuni> yes
<cfbolz> what does the api for the traverse C function look like, if the content of a field moves?
<antocuni> I don't understand the question
<cfbolz> so an HPyField in some hpy_data can point to a gcref, right?
<cfbolz> the gcref can move
<antocuni> yes
<cfbolz> who updates the hpy_data
<antocuni> the GC
<cfbolz> how does it know the offsets of the hpy_fields?
<antocuni> because it has the custom tracer (which is implemented by calling tp_traverse)
<antocuni> this is how a tp_traverse look like, FWIW: https://github.com/hpyproject/hpy/blob/master/test/test_hpyfield.py#L42
<antocuni> in that example, the void* self points to hpy_data
<fijal> cfbolz: we have the same thing for jitframe?
<fijal> it's an extra root that needs updating
<antocuni> yes, and we also have it for micronumpy's arrays of objects, although I don't know if it's still working nowadays
<cfbolz> I just was on the phone with phlebas, I understand what graalpython is doing significantly better now ;-)
<cfbolz> they have a ton of cool optimizations that we don't yet
<cfbolz> antocuni: what's the most up-to-date branch to look at for hpy in pypy
<antocuni> there is hpy-0.0.4, and I started a sub-branch hpy-0.0.4-hpyfield
<antocuni> but the latter does not contain much
<cfbolz> thanks
<cfbolz> phlebas: I know you are in a meeting, but of course CPython should do the same handle optimizations for ints etc
<cfbolz> antocuni: we already came to the conclusion that hpy can be used to introduce pointer tagging, right?
<antocuni> I think I already talked about that with someone, yes
<antocuni> I don't remember what was the conclusion :)
<antocuni> is graalpython doing it?
<cfbolz> yes
<antocuni> cool
<antocuni> only for ints or also for e.g. floats?
<cfbolz> both
<cfbolz> and they encode various other things in the bits of the handle
<cfbolz> like the length if it is small
<antocuni> uhm wait. How can you squeeze a 64 bit float into a 64 bit handle?
<antocuni> the length of what?
<cfbolz> you hide everything that's not a float in NaNs
<antocuni> ah right
<cfbolz> antocuni: anything ;-)
<cfbolz> probably only tuples and stuff
<antocuni> ah, so that HPy_Length is very fast
<antocuni> brilliant
<cfbolz> yes
<cfbolz> the NaN trick is fairly "standard", all the JS VMs do it
<antocuni> phlebas, fangerer: you should really write a blog post about this stuff
<cfbolz> yep
<antocuni> yes, I think we use the NaN trick also in PyPy for lists of int-float-none, don't we?
<cfbolz> yes
<cfbolz> but it's much cooler in handles
<antocuni> so, if we port the handle tagging thing to CPython, HPy might end up being *faster* than standard C exts? :)
<cfbolz> yes, I was wondering
<cfbolz> it would allow doing it cleanly in CPython
<cfbolz> because you would cleanly known which code supports this: everything using hpy
<antocuni> how is it different than using tagged pointers in PyObject*, though?
<cfbolz> antocuni: you can't upgrade to that easily
<cfbolz> you would have to fix too many things
<antocuni> right, like all the existing extensions
<cfbolz> yes
<cfbolz> and hpy would give you a way to know which extensions are safe
<antocuni> yes
<antocuni> and the super nice thing is that the extensions don't even need to know
<cfbolz> exactly
<cfbolz> they "just" need to use hpy correctly
<antocuni> and that's where the debug mode helps
<cfbolz> and pypy as a debugging tool (it's main use anyway)
<antocuni> "pypy as a debugging tool"? What do you mean?
<cfbolz> antocuni: you find problems in your module on pypy-hpy that you wouldn't see on CPytho if you still use PyObject* in some corner, no?
GianlucaRizzo has joined #hpy
<antocuni> hopefully these problems should be caught by the debug mode
<antocuni> but yes, pypy as a secondary debug mode is helpful as well
arigato has quit [Ping timeout: 240 seconds]
antocuni has quit [Ping timeout: 240 seconds]
arigato has joined #hpy
antocuni has joined #hpy
GianlucaRizzo has quit [Remote host closed the connection]
FFY00_ has joined #hpy
FFY00 has quit [Ping timeout: 276 seconds]
FFY00 has joined #hpy
FFY00_ has quit [Ping timeout: 252 seconds]
GianlucaRizzo has joined #hpy
FFY00_ has joined #hpy
FFY00 has quit [Ping timeout: 260 seconds]
GianlucaRizzo has quit [Remote host closed the connection]
GianlucaRizzo has joined #hpy
GianlucaRizzo has quit [Remote host closed the connection]
GianlucaRizzo has joined #hpy
GianlucaRizzo has quit [Remote host closed the connection]
GianlucaRizzo has joined #hpy
GianlucaRizzo has quit [Remote host closed the connection]
GianlucaRizzo has joined #hpy
GianlucaRizzo has quit [Remote host closed the connection]
GianlucaRizzo has joined #hpy
GianlucaRizzo has quit [Remote host closed the connection]
GianlucaRizzo has joined #hpy
GianlucaRizzo has quit [Ping timeout: 256 seconds]
GianlucaRizzo has joined #hpy
FFY00_ has quit [Ping timeout: 240 seconds]
FFY00 has joined #hpy
marvin_ has quit [Remote host closed the connection]
GianlucaRizzo has quit [Ping timeout: 246 seconds]
marvin has joined #hpy
GianlucaRizzo has joined #hpy
GianlucaRizzo has quit [Ping timeout: 276 seconds]
Gianluca_ has joined #hpy
Gianluca_ has quit [Remote host closed the connection]
GianlucaRizzo has joined #hpy
GianlucaRizzo has quit [Ping timeout: 276 seconds]
GianlucaRizzo has joined #hpy
GianlucaRizzo has quit [Ping timeout: 246 seconds]
GianlucaRizzo has joined #hpy
GianlucaRizzo has quit [Remote host closed the connection]
GianlucaRizzo has joined #hpy
GianlucaRizzo has quit [Ping timeout: 276 seconds]
pmp-p has quit [Ping timeout: 276 seconds]
GianlucaRizzo has joined #hpy
GianlucaRizzo has quit [Ping timeout: 246 seconds]
GianlucaRizzo has joined #hpy
GianlucaRizzo has quit [Remote host closed the connection]
GianlucaRizzo has joined #hpy
GianlucaRizzo has quit [Ping timeout: 260 seconds]
GianlucaRizzo has joined #hpy
GianlucaRizzo has quit [Ping timeout: 276 seconds]