Commit a50af363 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'update-allocations-gem-fix-names' into 'master'

Update allocations Gem & ignore classes without names

## What does this MR do?

1. Updates the allocations Gem to 1.0.5 so it can be used on 2.2/2.3 without crashing
2. Changes the background sampler to ignore classes/modules without a name (as we can't do much with these)

## Are there points in the code the reviewer needs to double check?

No.

## Why was this MR needed?

Using MRI 2.2 or 2.3 would lead to a segmentation fault in the allocations Gem, sometimes this problem would also occur on 2.1

## What are the relevant issue numbers?

Not an issue, but the merge request that highlighted these problems: !3807

## Does this MR meet the acceptance criteria?

- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [ ] ~~[Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)~~
- [ ] ~~API support added~~
- [ ] Tests
  - [x] Added for this feature/bug
  - [ ] All builds are passing
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [ ] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

See merge request !4645
parents 9a61eada 7eabc67e
...@@ -79,6 +79,8 @@ v 8.9.0 (unreleased) ...@@ -79,6 +79,8 @@ v 8.9.0 (unreleased)
- Allow users to create confidential issues in private projects - Allow users to create confidential issues in private projects
- Measure CPU time for instrumented methods - Measure CPU time for instrumented methods
- Instrument private methods and private instance methods by default instead just public methods - Instrument private methods and private instance methods by default instead just public methods
- Updated the allocations Gem to version 1.0.5
- The background sampler now ignores classes without names
v 8.8.5 (unreleased) v 8.8.5 (unreleased)
- Ensure branch cleanup regardless of whether the GitHub import process succeeds - Ensure branch cleanup regardless of whether the GitHub import process succeeds
......
...@@ -50,7 +50,7 @@ GEM ...@@ -50,7 +50,7 @@ GEM
after_commit_queue (1.3.0) after_commit_queue (1.3.0)
activerecord (>= 3.0) activerecord (>= 3.0)
akismet (2.0.0) akismet (2.0.0)
allocations (1.0.4) allocations (1.0.5)
arel (6.0.3) arel (6.0.3)
asana (0.4.0) asana (0.4.0)
faraday (~> 0.9) faraday (~> 0.9)
......
...@@ -66,7 +66,11 @@ module Gitlab ...@@ -66,7 +66,11 @@ module Gitlab
def sample_objects def sample_objects
sample = Allocations.to_hash sample = Allocations.to_hash
counts = sample.each_with_object({}) do |(klass, count), hash| counts = sample.each_with_object({}) do |(klass, count), hash|
hash[klass.name] = count name = klass.name
next unless name
hash[name] = count
end end
# Symbols aren't allocated so we'll need to add those manually. # Symbols aren't allocated so we'll need to add those manually.
......
...@@ -72,6 +72,7 @@ describe Gitlab::Metrics::Sampler do ...@@ -72,6 +72,7 @@ describe Gitlab::Metrics::Sampler do
end end
end end
if Gitlab::Metrics.mri?
describe '#sample_objects' do describe '#sample_objects' do
it 'adds a metric containing the amount of allocated objects' do it 'adds a metric containing the amount of allocated objects' do
expect(sampler).to receive(:add_metric). expect(sampler).to receive(:add_metric).
...@@ -81,6 +82,16 @@ describe Gitlab::Metrics::Sampler do ...@@ -81,6 +82,16 @@ describe Gitlab::Metrics::Sampler do
sampler.sample_objects sampler.sample_objects
end end
it 'ignores classes without a name' do
expect(Allocations).to receive(:to_hash).and_return({ Class.new => 4 })
expect(sampler).not_to receive(:add_metric).
with('object_counts', an_instance_of(Hash), type: nil)
sampler.sample_objects
end
end
end end
describe '#sample_gc' do describe '#sample_gc' do
......
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