sys-proctable is slow in production
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/27474 introduced the sys-proctable
gem.
We had a production incident with the deploy of 11.11 RC2, where CPU usage was much higher. We don't know exactly what caused this but one thing we did notice showing up in perf was smaps_account
: gitlab-com/gl-infra/production#832 (comment 171331542)
@tkuah pointed out this issue on the gem: https://github.com/djberg96/sys-proctable/issues/64
And in production, we can see that using smaps: false
is much faster:
[ gprd ] production> Benchmark.realtime { 100.times { Sys::ProcTable.ps(smaps: false).select {|p| p.cmdline.match(/unicorn_rails worker.+ #{Rails.root.to_s}/)}.count } }
=> 3.6349638774991035
[ gprd ] production> Benchmark.realtime { 100.times { Sys::ProcTable.ps.select {|p| p.cmdline.match(/unicorn_rails worker.+ #{Rails.root.to_s}/)}.count } }
=> 6.409302402287722
@andrewn pointed out we could probably make this even more efficient: gitlab-com/gl-infra/production#832 (comment 171497637)