The Trunk: System-mt.1199.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: System-mt.1199.mcz

commits-2
Marcel Taeumel uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-mt.1199.mcz

==================== Summary ====================

Name: System-mt.1199
Author: mt
Time: 17 December 2020, 6:15:09.310895 pm
UUID: 00f96e57-9bc5-d044-bcb7-2dd90b55507b
Ancestors: System-mt.1198

Fixes SpaceTally. Only enumerate objects in variable classes, not bytes or words. Thus, avoid to create LargePositiveIntegers while counting.

=============== Diff against System-mt.1198 ===============

Item was changed:
  Object subclass: #SpaceTally
  instanceVariableNames: 'results depth'
  classVariableNames: ''
  poolDictionaries: ''
  category: 'System-Tools'!
 
  !SpaceTally commentStamp: '<historical>' prior: 0!
  I'm responsible to help getting information about system space usage. The information I compute is represented by a spaceTallyItem.
 
  Here are some examples to inspect:
  SpaceTally new spaceTally: (Array with: TextMorph with: Point).
  SpaceTally new systemWideSpaceTally.
  SpaceTally new depth: 2; spaceTally: (PackageInfo named: #Morphic) classes.
  SpaceTally new depth: 1; spaceTally: (PackageInfo named: #Monticello) classes. "Includes cached source code"
+ SpaceTally new spaceForInstancesOf: Form depth: 1. "Includes footprint for bitmaps"!
- SpaceTally new spaceForInstancesOf: Form depth: 2. "Includes bitmaps and large integers"!

Item was changed:
  ----- Method: SpaceTally>>spaceForInstance:depth:seen: (in category 'instance size') -----
  spaceForInstance: anObject depth: anInteger seen: seenObjectsOrNil
 
  | ctxt class basicSize depth total |
  seenObjectsOrNil ifNotNil: [
  (seenObjectsOrNil ifAbsentAdd: anObject) ifFalse: [^ 0]].
  ctxt := thisContext.
  class := ctxt objectClass: anObject.
  basicSize := 0.
  total := class isVariable
  ifTrue: [class byteSizeOfInstanceOfSize: (basicSize := ctxt objectSize: anObject)]
  ifFalse: [class isImmediateClass ifTrue: [0] ifFalse: [class byteSizeOfInstance]].
  (depth := anInteger - 1) >= 0 ifTrue: [
  anObject isCompiledCode
  ifTrue: [
  anObject literalsDo: [:literal |
  total := total + (self spaceForInstance: literal depth: depth seen: seenObjectsOrNil)]]
  ifFalse: [
+ (class instSpec between: 2 and: 4) ifTrue: [ "only indexable objects, no bytes etc."
+ 1 to: basicSize do: [:index |
+ total := total + (self spaceForInstance: (ctxt object: anObject basicAt: index) depth: depth seen: seenObjectsOrNil)]].
- 1 to: basicSize do: [:index |
- total := total + (self spaceForInstance: (ctxt object: anObject basicAt: index) depth: depth seen: seenObjectsOrNil)].
  1 to: class instSize do: [:index |
  total := total + (self spaceForInstance: (ctxt object: anObject instVarAt: index) depth: depth seen: seenObjectsOrNil)]]].
  ^ total!

Item was changed:
  ----- Method: SpaceTally>>spaceForInstancesOf:depth:seen: (in category 'instance size') -----
  spaceForInstancesOf: aClass depth: anInteger seen: seenObjects
  "Answer a pair of the number of bytes consumed by all instances of the given class, including their object headers, and the number of instances. Follow each instance's fields up to the given depth. Beware of cycles to shared objects, which will tamper the resulting numbers.
 
  SpaceTally new spaceForInstancesOf: Form depth: 0. --- Same as #spaceForInstancesOf:
  SpaceTally new spaceForInstancesOf: Form depth: 1. --- Includes memory footprint for bits etc.
- SpaceTally new spaceForInstancesOf: Form depth: 2. --- Also includes LargePositiveIntegers in bitmaps ;-)
  "
 
  | instances total |
  instances := aClass allInstances.
  instances isEmpty ifTrue: [^#(0 0)].
  total := 0.
  instances do: [:each | total := total + (self spaceForInstance: each depth: anInteger seen: seenObjects)].
  ^{ total. instances size }!