Skip to content

High CPU usage when unpacking on Ubuntu 12.04 with msgpack 4.8 #207

@imcom

Description

@imcom
(gdb) bt
#0  0x00007fee03ef525d in sem_post () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x000000000056d237 in PyThread_release_lock (lock=0x27bd4f0) at ../Python/thread_pthread.h:346
#2  0x000000000051a1fd in PyEval_EvalFrameEx (
    f=Frame 0x2ac03c0, for file /usr/local/lib/python2.7/dist-packages/msgpack/fallback.py, line 537, in _fb_unpack (self=<Unpacker(_max_buffer_size=2147483647, _encoding=None, _max_map_len=2147483647, _max_bin_len=2147483647, _max_ext_len=2147483647, _fb_sloppiness=0, _object_hook=None, _fb_buf_o=52492, _fb_buf_n=1866623, _fb_buf_i=22, _unicode_errors='strict', _use_list=True, _max_str_len=2147483647, _ext_hook=<type at remote 0x17ed550>

Recently, I've been observing this strange situation that my script just simply receives msgpack-ed data from stdin and extracts it. However, during that procedure, the script causes sever futex contention. I've used gdb to track it down and found out that there are tons of require and release on the same lock object, e.g. "lock=0x27bd4f0", which seems to me that is used by msgpack, specifically _fb_unpack.

Just wondering has anyone else observed similar phenomenon ? I have not got time to dig into the _fb_unpack function so currently I have no idea why this function can cause futex contention.

futex(0x27bd4f0, FUTEX_WAIT_PRIVATE, 0, NULL) = 0
futex(0x27bd4f0, FUTEX_WAIT_PRIVATE, 0, NULL) = -1 EAGAIN (Resource temporarily unavailable)
futex(0x27bd4f0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x27bd4f0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x27bd4f0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x27bd4f0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x27bd4f0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x27bd4f0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x27bd4f0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x27bd4f0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x27bd4f0, FUTEX_WAIT_PRIVATE, 0, NULL) = 0
futex(0x27bd4f0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x27bd4f0, FUTEX_WAIT_PRIVATE, 0, NULL) = 0
futex(0x27bd4f0, FUTEX_WAIT_PRIVATE, 0, NULL) = -1 EAGAIN (Resource temporarily unavailable)
futex(0x27bd4f0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x27bd4f0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x27bd4f0, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x27bd4f0, FUTEX_WAKE_PRIVATE, 1) = 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions