Skip to content

Commit

Permalink
AllocationSiteProfiler: speeding up copyExecutionStack calculcation
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanmontt committed Jul 18, 2024
1 parent ab36cc7 commit 2cd3bb3
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/IllimaniProfiler-Tests/Behavior.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Extension { #name : 'Behavior' }

{ #category : '*IllimaniProfiler-Tests' }
Behavior >> illNew [
"Mocking method for testing "

^ self basicNew initialize
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Extension { #name : 'IllAllocationSiteProfiler' }

{ #category : '*IllimaniProfiler-Tests' }
IllAllocationSiteProfiler >> instrumentator: anInstrumentator [

instrumentator := anInstrumentator
]
16 changes: 16 additions & 0 deletions src/IllimaniProfiler-Tests/IllAllocationSiteProfilerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@ IllAllocationSiteProfilerTest >> profilerClass [
^ IllAllocationSiteProfiler
]

{ #category : 'tests' }
IllAllocationSiteProfilerTest >> testFilterContextIgnoringClass [

profiler
instrumentator: (IllMockInstrumentator onProfiler: profiler);
copyExecutionStack;
samplingRate: 1;
startProfiling.

Object illNew.

self assert: profiler objectAllocations first context receiver class equals: self class.
self assert: profiler objectAllocations first context homeMethod
equals: self class >> #testFilterContextIgnoringClass
]

{ #category : 'tests' }
IllAllocationSiteProfilerTest >> testProfileOnCopyExecutionStack [

Expand Down
19 changes: 19 additions & 0 deletions src/IllimaniProfiler-Tests/IllMockInstrumentator.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Class {
#name : 'IllMockInstrumentator',
#superclass : 'IllInstrumentator',
#category : 'IllimaniProfiler-Tests-Allocations-Profiler',
#package : 'IllimaniProfiler-Tests',
#tag : 'Allocations-Profiler'
}

{ #category : 'initialization' }
IllMockInstrumentator >> initializeMethodProxies [

proxyBasicNew := MpMethodProxy onMethod: Behavior >> #illNew handler: handler
]

{ #category : 'instrumentation' }
IllMockInstrumentator >> proxyVariables [

^ { proxyBasicNew }
]
6 changes: 2 additions & 4 deletions src/IllimaniProfiler/IllAllocationSiteProfiler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,8 @@ IllAllocationSiteProfiler >> filterContext: aContext ignoringClass: aClass [
| sender |
sender := aContext sender.
[
sender receiver class = aClass or: [
sender receiver class = aClass class or: [
classesToAvoidInTheContextSearch includes: sender receiver class ] ] ]
sender receiver class = aClass class or: [
classesToAvoidInTheContextSearch includes: sender receiver class ] ]
whileTrue: [ sender := sender sender ].
^ sender
]
Expand All @@ -128,7 +127,6 @@ IllAllocationSiteProfiler >> initialize [
objectAllocations := OrderedCollection new.
copyExecutionStack := false.
classesToAvoidInTheContextSearch := self defaultClassesToAvoidInTheContextSearch
, (self defaultClassesToAvoidInTheContextSearch collect: [ :aClass | aClass class ])
]

{ #category : 'profiling' }
Expand Down

0 comments on commit 2cd3bb3

Please sign in to comment.