What’s the situation with the IO? Are you buffering? Are you holding the lock for a long time or rapidly locking and unlocking?
If you can share the code I can take a look.
What’s the situation with the IO? Are you buffering? Are you holding the lock for a long time or rapidly locking and unlocking?
If you can share the code I can take a look.
Code is here: https://gist.github.com/usefulcat/56f334bc58c97edb073b457b68...
There is actually one other file but it only contains a couple of struct definitions for the libpcap file and packet headers. Thanks for having a look!
I didn't think there was room for that much improvement; I'm really impressed.
Edit: HOLY CRAP! I have a program written in Rust, ppbert[1], and I just tried wrapping my StdoutLock object in a BufWriter, and I improved the performance of my pretty-printing by a factor of 2x! I knew to use BufReader for files, I didn't know it was helpful for stdin and stdout! Thank you _so much_ for sharing your experience, I've certainly benefited!
Benchmark #1: ppbert -2 *.bert2
Time (mean ± σ): 3.816 s ± 0.115 s [User: 2.494 s, System: 1.321 s]
Range (min … max): 3.688 s … 4.028 s
Benchmark #2: ppbert-dev -2 *.bert2
Time (mean ± σ): 1.728 s ± 0.045 s [User: 1.493 s, System: 0.234 s]
Range (min … max): 1.678 s … 1.843 s
Summary
'ppbert-dev -2 *.bert2' ran 2.21x faster than 'ppbert -2 *.bert2'
[1] https://github.com/gnuvince/ppbert