Commit 3c32fe31 authored by Ahmad Sherif's avatar Ahmad Sherif

Merge branch 'sh-reduce-memory-usage-smaps' into 'master'

Reduce memory allocations parsing smaps files

See merge request gitlab-org/gitlab-monitor!92
parents a985abf3 36bcca52
# frozen_string_literal: true
require_relative "memstats/mapping"
# Ported from https://github.com/discourse/discourse/blob/master/script/memstats.rb
......
# frozen_string_literal: true
module GitLab
module Monitor
module MemStats
......@@ -56,7 +58,9 @@ module GitLab
end
def parse_first_line(line)
parts = line.strip.split
line.strip!
parts = line.split
@address_start, @address_end = parts[0].split("-")
@perms = parts[1]
@offset = parts[2]
......@@ -66,8 +70,15 @@ module GitLab
end
def parse_field_line(line)
parts = line.strip.split
field = parts[0].downcase.sub(":", "")
line.strip!
parts = line.split
return unless parts
parts[0].downcase!
parts[0].sub!(":", "")
field = parts[0]
return unless respond_to? "#{field}="
......
# frozen_string_literal: true
require_relative "memstats"
module GitLab
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment