Commit 78181778 authored by Robert May's avatar Robert May

Merge branch '299524-remove-trace-memory-allocations-ff' into 'master'

Remove trace_memory_allocations FF [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!66022
parents 3233413c aac6b96b
---
name: trace_memory_allocations
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/52306
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/299524
milestone: '13.9'
type: development
group: group::memory
default_enabled: true
...@@ -21,24 +21,13 @@ module Gitlab ...@@ -21,24 +21,13 @@ module Gitlab
Thread.current.respond_to?(:memory_allocations) Thread.current.respond_to?(:memory_allocations)
end end
# This method changes a global state def self.start_thread_memory_allocations
def self.ensure_feature_flag!
return unless available? return unless available?
enabled = Feature.enabled?(:trace_memory_allocations, default_enabled: true)
return if enabled == Thread.trace_memory_allocations
MUTEX.synchronize do MUTEX.synchronize do
# This enables or disables feature dynamically # This method changes a global state
# based on a feature flag Thread.trace_memory_allocations = true
Thread.trace_memory_allocations = enabled
end end
end
def self.start_thread_memory_allocations
return unless available?
ensure_feature_flag!
# it will return `nil` if disabled # it will return `nil` if disabled
Thread.current.memory_allocations Thread.current.memory_allocations
......
...@@ -99,23 +99,6 @@ RSpec.describe Gitlab::InstrumentationHelper do ...@@ -99,23 +99,6 @@ RSpec.describe Gitlab::InstrumentationHelper do
:mem_mallocs :mem_mallocs
) )
end end
context 'when trace_memory_allocations is disabled' do
before do
stub_feature_flags(trace_memory_allocations: false)
Gitlab::Memory::Instrumentation.ensure_feature_flag!
end
it 'does not log memory usage metrics' do
subject
expect(payload).not_to include(
:mem_objects,
:mem_bytes,
:mem_mallocs
)
end
end
end end
context 'when load balancing is enabled' do context 'when load balancing is enabled' do
......
...@@ -18,24 +18,8 @@ RSpec.describe Gitlab::Memory::Instrumentation do ...@@ -18,24 +18,8 @@ RSpec.describe Gitlab::Memory::Instrumentation do
describe '.start_thread_memory_allocations' do describe '.start_thread_memory_allocations' do
subject { described_class.start_thread_memory_allocations } subject { described_class.start_thread_memory_allocations }
context 'when feature flag trace_memory_allocations is enabled' do it 'a hash is returned' do
before do is_expected.to be_a(Hash)
stub_feature_flags(trace_memory_allocations: true)
end
it 'a hash is returned' do
is_expected.not_to be_empty
end
end
context 'when feature flag trace_memory_allocations is disabled' do
before do
stub_feature_flags(trace_memory_allocations: false)
end
it 'a nil is returned' do
is_expected.to be_nil
end
end end
context 'when feature is unavailable' do context 'when feature is unavailable' do
...@@ -63,30 +47,14 @@ RSpec.describe Gitlab::Memory::Instrumentation do ...@@ -63,30 +47,14 @@ RSpec.describe Gitlab::Memory::Instrumentation do
expect(described_class).to receive(:measure_thread_memory_allocations).and_call_original expect(described_class).to receive(:measure_thread_memory_allocations).and_call_original
end end
context 'when feature flag trace_memory_allocations is enabled' do it 'a hash is returned' do
before do result = subject
stub_feature_flags(trace_memory_allocations: true) expect(result).to include(
end mem_objects: be > 1000,
mem_mallocs: be > 1000,
it 'a hash is returned' do mem_bytes: be > 100_000, # 100 items * 100 bytes each
result = subject mem_total_bytes: eq(result[:mem_bytes] + 40 * result[:mem_objects])
expect(result).to include( )
mem_objects: be > 1000,
mem_mallocs: be > 1000,
mem_bytes: be > 100_000, # 100 items * 100 bytes each
mem_total_bytes: eq(result[:mem_bytes] + 40 * result[:mem_objects])
)
end
end
context 'when feature flag trace_memory_allocations is disabled' do
before do
stub_feature_flags(trace_memory_allocations: false)
end
it 'a nil is returned' do
is_expected.to be_nil
end
end end
context 'when feature is unavailable' do context 'when feature is unavailable' 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