4 ms·
Why Python needs to be paused during profiling – but Ruby doesn't always
- cozzyd 5y agoWithout nonblocking mode in py-spy (which is amazing, by the way!), I had a case where some compiled code froze until I manually sent a SIGCONT.
- benfrederickson 5y agoSorry about leaving your program suspended - I believe that was because of a bug that should be fixed now https://github.com/benfred/py-spy/issues/390 https://github.com/benfred/py-spy/issues/390 =(
- cozzyd 5y agoWell look at that! I guess I'll try it again with a newer version when I get a chance, thanks!
- baq 5y agothank you so much! it wasn't a big deal (if you remembered to check after using py-spy, granted). i'd take py-spy with this bug vs not having py-spy at all any day :)
- lathiat 5y agoInteresting I’ve had this happen with strace and/or gdb before when hitting control-c a few times.
- no_time 5y agoSlight tagent but do you and many others here appear mere hours after their project is mentioned? Pure luck or a large percentage of HN users are querying the api to see who mentions their projects?
- baq 5y agoi've seen this multiple times, happens especially when detaching py-spy. have to be very careful to check if the process isn't stopped when debugging in prod ^_^
- hangonhn 5y agoDoes anyone know why Python chose linked list for its frames vs an array like Ruby? I imagine both choices have their own advantages and disadvantages.
- the_mitsuhiko 5y agoMost likely because it was easier. It's definitely not a good choice but unfortunately `PyFrame_GetBack(PyFrameObject *)` exists as an API which makes it tricky now to switch to something else as it must be possible to discover the previous frame from a frame. It's even exposed to userspace with `frameobject.f_back`.
- dmw_ng 5y agoNo definitive answer, but educated guess: I'm not sure how things are in Ruby, but in Python frame object lifetime does not correspond to the C stack implementing the interpreter. If your code throws an exception, frames are returned as part of the public API of the exception object, and can thus indefinitely outlive the associated function execution. You could still implement an array-oriented frame stack in Python, but I think that would mean exceptions become more expensive, as it means making a complete copy of the array any time an exception was thrown, even if the user never makes use of it.
- the_mitsuhiko 5y agoIt would be trivial to change from a linked list to an allocated vector if it were not for exposed APIs. In fact it would most likely be more efficient.
- gpderetta 5y agoInteresting. Wasn't the selling point of Stackless Python that it did not use the C stack (as done by CPython) as the Python stack?