Hunting Performance in Python Code – Part 4. CPU Profiling (interpreter)

In this post I will talk about some tools and ways in which you can profile the interpreter, when running a Python script.

Just like in our previous post, the meaning of CPU profiling is the same, but now we are not targeting the Python script. Instead we want to know how the Python interpreter works and where it spends the most time when running our Python script.

We see next how you can trace the CPU usage and find the hotspots in our interpreter.

Read More »

Implementing sendmsg and recvmsg for PyPy

Sendmsg and recvmsg are two system calls which allow to send messages on a socket as one could by using send/recv or sendto/recvfrom with a few noticeable differences:

  • Extra information can be passed in a packet on a socket that is not considered part of the message. This is known as ancillary data or control information.
  • Sendmsg and recvmsg can be used on both connected or unconnected sockets (if the protocol allows) due to the option to specify the address similar to how sendto/recvfrom work.
  • The ancillary data allowed through the socket differs from one socket type to another. For example, on Unix socket sendmsg and recvmsg can use ancillary to pass file descriptors from one process to another, where as on UDPv6 they can allow for extra information regarding the packet (such as IPV6_PKTINFO​) to be attached in the ancillary.

Read More »