Skip to content

Commit bc15405

Browse files
authored
Merge pull request #93 from hpi-swa-lab/fix/spaceUsed
Fix & extend space usage computation
2 parents fa6b43b + 129da33 commit bc15405

File tree

8 files changed

+66
-14
lines changed

8 files changed

+66
-14
lines changed

packages/TraceDebugger.package/TDBMemory.class/instance/spaceUsed.st

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ spaceUsed
66
tally := SpaceTally new.
77
^ ({self. values. values array} detectSum: [:ea | tally spaceForInstance: ea depth: 0])
88
+ ((values array select: [:assoc | assoc notNil])
9-
detectSum: [:assoc | tally
10-
spaceForInstance: assoc value
11-
depth: 5 "runs array anyOne value second"])
9+
detectSum: [:assoc |
10+
(tally spaceForInstance: assoc key "object" depth: 0)
11+
+ (tally
12+
spaceForInstance: assoc value "slots"
13+
depth: 6 "array anyOne value array anyOne second")])

packages/TraceDebugger.package/TDBMemory.class/methodProperties.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@
2323
"object:priorTo:fieldAt:put:" : "ct 1/22/2022 15:40",
2424
"object:priorTo:instVarAt:put:" : "ct 11/19/2021 18:55",
2525
"postCopy" : "ct 5/13/2022 23:15",
26-
"spaceUsed" : "ct 2/14/2022 17:19" } }
26+
"spaceUsed" : "ct 7/20/2022 19:06" } }
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
support
2+
spaceUsed
3+
4+
| tally space |
5+
tally := SpaceTally new.
6+
space := "self memory spaceUsed"0.
7+
space := space
8+
+ (tally spaceForInstance: intervals depth: 1)
9+
+ (tally spaceForInstance: rawValues depth: 2).
10+
sideEffects ifNotNil:
11+
[space := space + (sideEffects detectSum: #spaceUsed)].
12+
^ space

packages/TraceDebugger.package/TDBMemorySlice.class/methodProperties.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"setSideEffects:" : "ct 7/4/2022 00:36",
5656
"sideEffects" : "ct 5/14/2022 21:57",
5757
"size" : "ct 4/30/2022 19:24",
58+
"spaceUsed" : "ct 7/24/2022 20:09",
5859
"tdbRangeContextsDo:" : "ct 6/2/2022 13:54",
5960
"tdbRangeContextsStep" : "ct 6/2/2022 17:37",
6061
"times" : "ct 6/2/2022 10:20",

packages/TraceDebuggerTests.package/TDBCursorTest.class/instance/testSpaceUsed.st

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ testSpaceUsed
33
"Smoke test."
44

55
| cursor emptyMemorySpace emptySpace emptyTraceSpace |
6-
cursor := self classUnderTest forContext: (Context
7-
sender: nil
8-
receiver: TDBTestLogic new
9-
method: TDBTestLogic >> #plonk
10-
arguments: #()).
6+
cursor := self classUnderTest forContext:
7+
[| x |
8+
x := Array new: 100000]
9+
asContext.
1110

1211
emptyMemorySpace := cursor memory spaceUsed.
1312
self assert: emptyMemorySpace < 1000.
@@ -16,10 +15,14 @@ testSpaceUsed
1615
emptySpace := cursor spaceUsed.
1716
self assert: emptyMemorySpace < 1000.
1817

19-
cursor doStepUntil: [:context | context isDead].
18+
cursor doStepUntil: [:context | context willReallyStore].
2019

21-
self assert: cursor memory spaceUsed - emptyMemorySpace > (20 * 4).
22-
self assert: cursor memory spaceUsed < 10000.
20+
self assert: cursor memory spaceUsed - emptyMemorySpace > (20 * 5).
21+
self assert: cursor memory spaceUsed < 2000.
2322
self assert: cursor rootTrace spaceUsed - emptyTraceSpace > (20 * 4).
2423
self assert: cursor spaceUsed > emptySpace.
25-
self assert: cursor rootTrace spaceUsed < 100000.
24+
self assert: cursor rootTrace spaceUsed < 1000.
25+
26+
cursor doStepUntil: [:context | false].
27+
28+
self assert: cursor memory spaceUsed - emptyMemorySpace > (100000 * 8).

packages/TraceDebuggerTests.package/TDBCursorTest.class/methodProperties.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"testDoStepThroughUntil" : "ct 2/17/2022 19:09",
3333
"testDoStepThroughUntilFromSender" : "ct 3/13/2022 14:54",
3434
"testReturnValue" : "ct 3/17/2022 00:55",
35-
"testSpaceUsed" : "ct 6/3/2022 16:49",
35+
"testSpaceUsed" : "ct 7/24/2022 20:05",
3636
"testTraceContextFilter" : "ct 2/20/2022 19:39",
3737
"testTraceFor:contextFilter:like:" : "ct 3/15/2022 23:59",
3838
"testTraceFor:like:" : "ct 2/20/2022 19:39",
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
tests - support
2+
testSpaceUsed
3+
"Smoke test."
4+
5+
slice := self classUnderTest
6+
memory: self memoryClass new
7+
intervals: {1 to: 1}
8+
rawValues: {nil}.
9+
self assert: slice spaceUsed < 100.
10+
11+
slice := self classUnderTest
12+
memory: self memoryClass new
13+
intervals: ((1 to: 1000) collect: [:ea | ea to: ea])
14+
rawValues: ((1 to: 1000) collect: [:ea | ea]).
15+
self assert: slice spaceUsed > (1000 * 8 * 2).
16+
self assert: slice spaceUsed < (1000 * 8 * 2 * 4).
17+
18+
slice := self classUnderTest
19+
memory: self memoryClass new
20+
intervals: {1 to: 1}
21+
rawValues: {Array new: 1000}.
22+
self assert: slice spaceUsed > (1000 * 8).
23+
self assert: slice spaceUsed < (1000 * 8 * 4).
24+
25+
slice := self classUnderTest
26+
memory: self memoryClass new
27+
intervals: {1 to: 1}
28+
rawValues: {nil}
29+
sideEffects: {self memoryClass new
30+
object: self priorTo: 1 atSlot: #plonk put: (Array new: 1000);
31+
yourself}.
32+
self assert: slice spaceUsed > (1000 * 8).
33+
self assert: slice spaceUsed < (1000 * 8 * 4).

packages/TraceDebuggerTests.package/TDBMemorySliceTest.class/methodProperties.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"testRawWithTimesCollect" : "ct 6/2/2022 13:55",
2828
"testRawWithTimesGather" : "ct 6/2/2022 13:56",
2929
"testSize" : "ct 5/28/2022 15:28",
30+
"testSpaceUsed" : "ct 7/24/2022 20:14",
3031
"testTimesAndRawValues" : "ct 6/2/2022 11:55",
3132
"testTimesAndRawValuesCollect" : "ct 6/2/2022 13:16",
3233
"testTimesAndRawValuesDo" : "ct 6/2/2022 13:16",

0 commit comments

Comments
 (0)