cameron314 / concurrentqueue

A fast multi-producer, multi-consumer lock-free concurrent queue for C++11
Other
9.99k stars 1.69k forks source link

M1 profiling results #335

Open cjappl opened 1 year ago

cjappl commented 1 year ago

Hello, me again!

I just ran the profiling on my M1, figured you may want to check out the results

https://gist.github.com/cjappl/6277bb149ad356dc48ec312188a8e757

Note: I had to comment out bench_empty_dequeue as it was hanging on std::queue. I can investigate if you're curious and want those values in the results

cameron314 commented 1 year ago

Am indeed curious about the hang. Could it possibly be just very, very slow? The std::queue-based implementation is dead simple.

cjappl commented 1 year ago

Alright, there's gotta be some UB or something going on here. I changed the test matrix such that this was the only test that ran (empty queue on std::queue)

const bool QUEUE_BENCH_SUPPORT[QUEUE_COUNT][BENCHMARK_TYPE_COUNT] = {
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};

Running this suite by itself hangs indefinitely, or takes >1hr to return, however just modifying it to this:

Screen Shot 2023-03-02 at 11 52 00 AM

Runs successfully (results posted here, including the test previously commented out)

Hooking it up to a profiler, it seems that the test is basically just spinning asking the system what time it is?

Screen Shot 2023-03-02 at 11 54 33 AM

I know from audio land that introducing a system call can force data races to resolve. Is there anything in this specific test case you would consider not thread safe? Or any UB? I should probably try to run with some sanitizers..

cameron314 commented 1 year ago

Best guess: something might be so fast it's taking 0 ns :-)

cjappl commented 1 year ago

Let me know if you want me to dig into anything more, otherwise feel free to close this and the readerwriterqueue issue as complete.

Happy to profile again in the future if it'd be helpful.

cameron314 commented 1 year ago

👍 Thanks for your help! Will leave these open for now until I have a chance to look more deeply at the results (could be a while!). Don't think you need to explore more on your end (unless you want to, of course).

cjappl commented 1 year ago

Sounds like a plan! Ping me if you need me.