DEV: Seperate concerns of tracking GC stat from MethodProfiler (#22921)

Why this change?

This is a follow up to e8f7b62752a65e33aa1cee748fc966c4ad14b1ee.
Tracking of GC stats didn't really belong in the `MethodProfiler` class
so we want to extract that concern into its own class.

As part of this PR, the `track_gc_stat_per_request` site setting has
also been renamed to `instrument_gc_stat_per_request`.
This commit is contained in:
Alan Guo Xiang Tan
2023-08-02 10:46:37 +08:00
committed by GitHub
parent e8f7b62752
commit 773b22e8d0
8 changed files with 83 additions and 39 deletions

View File

@ -37,24 +37,4 @@ RSpec.describe MethodProfiler do
expect(result[:at_beach][:calls]).to eq(2)
end
it "profiles GC stat information when `track_gc_stat_per_request` site setting has been enabled" do
MethodProfiler.start
GC.start(full_mark: false) # Minor GC
result = MethodProfiler.stop
expect(result[:gc]).not_to be_present
SiteSetting.track_gc_stat_per_request = true
MethodProfiler.start
GC.start(full_mark: true) # Major GC
GC.start(full_mark: false) # Minor GC
result = MethodProfiler.stop
expect(result[:gc]).to be_present
expect(result[:gc][:time]).to be >= 0.0
expect(result[:gc][:major_count]).to eq(1)
expect(result[:gc][:minor_count]).to eq(1)
end
end