ResourceCommands.mesa
Copyright Ó 1993 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, February 17, 1993 4:48:29 pm PST
Christian Jacobi, April 27, 1993 4:15 pm PDT
Poor mans load state analysis.
This application prints many different class of states and does the necessay imports. Eventually we will recognize certain packages which know how to print their states separately. If we would continue to import all the information sources we would create a monster.
DIRECTORY
Commander, IncrementalLoad, IO, Rope, UnixShm0, UXStrings;
ResourceCommands: CEDAR MONITOR
IMPORTS Commander, IncrementalLoad, IO, UnixShm0, UXStrings =
BEGIN
LoadStateCommand: Commander.CommandProc = TRUSTED {
textSum, dataSum, bssSum: CARD32 ¬ 0;
FOR fe: IncrementalLoad.FileEntry ¬ IncrementalLoad.GetPrevFileEntry[NIL], IncrementalLoad.GetPrevFileEntry[fe] WHILE fe#NIL DO
fileName: Rope.ROPE ¬ UXStrings.ToRope[fe.fName];
textSize: CARD32 ¬ fe.text.len;
dataSize: CARD32 ¬ fe.data.len;
bssSize: CARD32 ¬ fe.bss.len;
IO.PutF[cmd.out, "text:%8g data:%8g bss:%7g ", IO.card[textSize], IO.card[dataSize], IO.card[bssSize]];
IO.PutF1[cmd.out, "%g\n", IO.rope[fileName]];
textSum ¬ textSum+textSize;
dataSum ¬ dataSum+dataSize;
bssSum ¬ bssSum+bssSize;
ENDLOOP;
IO.PutF[cmd.out, "text:%8g data:%8g bss:%7g TOTAL\n", IO.card[textSum], IO.card[dataSum], IO.card[bssSum]];
};
VMStateCommand: Commander.CommandProc = TRUSTED {
address: UnixShm0.RawVM ¬ UnixShm0.VMReserve[0];
value: CARD ¬ LOOPHOLE[address];
IO.PutF1[cmd.out, "VM reserved: %g \n", IO.card[value]];
};
GCCurrentByteCount: PROC [] RETURNS [CARD] = TRUSTED MACHINE CODE {
"<xr/GC.h>.XR←GCCurrentByteCount"
};
GCCurrentObjectCount: PROC [] RETURNS [CARD] = TRUSTED MACHINE CODE {
"<xr/GC.h>.XR←GCCurrentObjectCount"
};
GCTotalByteCount: PROC [] RETURNS [CARD] = TRUSTED MACHINE CODE {
"<xr/GC.h>.XR←GCTotalByteCount"
};
GCTotalObjectCount: PROC [] RETURNS [CARD] = TRUSTED MACHINE CODE {
"<xr/GC.h>.XR←GCTotalObjectCount"
};
GCHeapSize: PROC [] RETURNS [CARD] = TRUSTED MACHINE CODE {
"<xr/GC.h>.XR←GCHeapSize"
};
GCCompositeInUse: PROC [] RETURNS [CARD] = TRUSTED MACHINE CODE {
Number of longwords in accessible composite objects.
"<xr/GC.h>.$GC𡤌omposite←in←use"
};
GCAtomicInUse: PROC [] RETURNS [CARD] = TRUSTED MACHINE CODE {
Number of longwords in accessible atomic objects.
"<xr/GC.h>.$GC𡤊tomic←in←use"
};
GCStateCommand: Commander.CommandProc = TRUSTED {
currentByteCount: CARD ¬ GCCurrentByteCount[];
currentObjectCount: CARD ¬ GCCurrentObjectCount[];
totalByteCount: CARD ¬ GCTotalByteCount[];
totalObjectCount: CARD ¬ GCTotalObjectCount[];
heapSize: CARD ¬ GCHeapSize[];
atomic: CARD ¬ GCAtomicInUse[]*BYTES[CARD];
composite: CARD ¬ GCCompositeInUse[]*BYTES[CARD];
IO.PutF1[cmd.out, "heapSize: %g \n", IO.card[heapSize]];
IO.PutF1[cmd.out, "currentByteCount: %g \n", IO.card[currentByteCount]];
IO.PutF1[cmd.out, "totalByteCount: %g \n", IO.card[totalByteCount]];
IO.PutF1[cmd.out, "currentObjectCount: %g \n", IO.card[currentObjectCount]];
IO.PutF1[cmd.out, "totalObjectCount: %g \n", IO.card[totalObjectCount]];
IO.PutF1[cmd.out, "atomic bytes in use: %g \n", IO.card[atomic]];
IO.PutF1[cmd.out, "composite bytes in use: %g \n", IO.card[composite]];
};
TotalStateCommand: Commander.CommandProc = TRUSTED {
IO.PutF[cmd.out, "%lLoad State%l\n", IO.rope["b"], IO.rope["B"]];
[] ¬ LoadStateCommand[cmd];
IO.PutF[cmd.out, "%lVM State%l\n", IO.rope["b"], IO.rope["B"]];
[] ¬ VMStateCommand[cmd];
IO.PutF[cmd.out, "%lGarbage Collector State%l\n", IO.rope["b"], IO.rope["B"]];
[] ¬ GCStateCommand[cmd];
};
Commander.Register["LoadState", LoadStateCommand, "Loadstate according to incremental loader"];
Commander.Register["VMState", VMStateCommand, "VM allocated according to VMReserve"];
Commander.Register["GCState", GCStateCommand, "Garbage collector info"];
Commander.Register["TotalState", TotalStateCommand, "Lots of info"];
END.
Other interesting commands are
ExamineStorage
RopeFiles
X11ShmUsage