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" require_relative "memstats/mapping"
# Ported from https://github.com/discourse/discourse/blob/master/script/memstats.rb # Ported from https://github.com/discourse/discourse/blob/master/script/memstats.rb
......
# frozen_string_literal: true
module GitLab module GitLab
module Monitor module Monitor
module MemStats module MemStats
...@@ -56,7 +58,9 @@ module GitLab ...@@ -56,7 +58,9 @@ module GitLab
end end
def parse_first_line(line) def parse_first_line(line)
parts = line.strip.split line.strip!
parts = line.split
@address_start, @address_end = parts[0].split("-") @address_start, @address_end = parts[0].split("-")
@perms = parts[1] @perms = parts[1]
@offset = parts[2] @offset = parts[2]
...@@ -66,8 +70,15 @@ module GitLab ...@@ -66,8 +70,15 @@ module GitLab
end end
def parse_field_line(line) def parse_field_line(line)
parts = line.strip.split line.strip!
field = parts[0].downcase.sub(":", "")
parts = line.split
return unless parts
parts[0].downcase!
parts[0].sub!(":", "")
field = parts[0]
return unless respond_to? "#{field}=" return unless respond_to? "#{field}="
......
# frozen_string_literal: true
require_relative "memstats" require_relative "memstats"
module GitLab 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