Quantcast
Channel: User Sergey Ponomarev - Stack Overflow
Viewing all articles
Browse latest Browse all 65

CPU cache friendly byte slice

$
0
0

I have a logger that writes a lot of messages in parallel to stdout. The problem is that messages were written simultaneously and shuffled.So I had to add a mutex and lock before printing:

l.mu.Lock()fmt.Fprintf(os.Stdout format, v...)l.mu.Unlock()

I wish to avoid the locking because I need as small latency as possible. But I'm fine with some pauses and I don't care much about order of messages.On my server I have 24 CPUs and each has it's own cache. I have an idea to make per-cpu list of byte slices and then periodically gather all of them and dump to a log.Will this work in practice?I'm feeling that I'm reinventing some existing structure.Could you please recommend an optimal way to do that.


Viewing all articles
Browse latest Browse all 65

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>