DIRECTORY IO, Rope; DBStats: CEDAR DEFINITIONS = BEGIN Initialize: PROC[]; CounterEvent: TYPE = { CacheReadOrWrite, CacheHTLookup, CacheHTConflictInLookup, CacheMiss, CacheWritePageBack, SegmentAllocPage, SegmentFreePage, StorageCreateTuple, StorageCreateSystemTuple, StorageDestroyTuple, StorageReadTupleset, StorageReadField, StorageWriteField, StorageInitVecPage, StorageCheckVecPage, StorageAllocVec, StorageFreeVec, StorageModifyVec, StorageModifyDifficultVec, StorageCompactPage, DBIndexInsert, DBIndexDelete, DBIndexOpenScan, DBIndexNextScan, DBIndexBiggerKey, DBIndexEqualKey, BTreeSearchPage, BTreeSwapInPage, BTreeSwapOutPage }; Inc: PROC[event: CounterEvent] = INLINE { CounterArray[event] _ CounterArray[event] + 1 }; TimerEvent: TYPE = { AlpineFileCreateTransaction, AlpineFileFinishTransaction, AlpineFileOpen, AlpineFileReadPage, AlpineFileWritePage, AlpineFileGetSize, AlpineFileSetSize, OpenTransaction, CloseTransaction, MarkTransaction, AbortTransaction, DeclareDomain, LookupDomain, DestroyDomain, DeclareRelation, LookupRelation, DestroyRelation, DeclareEntity, LookupEntity, DestroyEntity, DeclareIndex, DestroyIndex, CreateRelship, LookupRelship, LookupProperty, DestroyRelship, SetF, GetF, SetP, GetP, EntityInfo, RelationSubset, NextRelship, PrevRelship, DomainSubset, NextEntity, PrevEntity }; FileTimerEvent: TYPE = TimerEvent [AlpineFileCreateTransaction .. AlpineFileSetSize]; Starting: PROC[event: TimerEvent] = INLINE { StartTimer[event] }; Stopping: PROC[event: TimerEvent] = INLINE { StopTimer[event] }; Aborting: PROC[event: TimerEvent] = INLINE { AbortTimer[event] }; Print: PROC[heading: Rope.ROPE _ NIL, out: IO.STREAM_ NIL, verbose: BOOLEAN _ FALSE]; CounterArray: PRIVATE ARRAY CounterEvent OF LONG CARDINAL; StartTimer: PRIVATE PROC[event: TimerEvent]; StopTimer: PRIVATE PROC[event: TimerEvent]; AbortTimer: PRIVATE PROC[event: TimerEvent]; END. -- DBStats CHANGE LOG Created by MBrown on September 18, 1980 11:12 PM Changed by MBrown on September 21, 1980 2:50 PM Changed by MBrown on September 21, 1980 9:59 PM Changed by Cattell on September 22, 1980 3:13 PM Changed by MBrown on October 31, 1980 10:03 AM Changed by MBrown on November 10, 1980 3:35 PM Changed by MBrown on November 14, 1980 3:37 PM Changed by MBrown on November 14, 1980 5:32 PM Changed by MBrown on December 8, 1980 5:41 PM Changed by MBrown on December 16, 1980 10:33 AM Changed by MBrown on February 26, 1981 10:08 AM Changed by MBrown on 17-Jun-81 12:05:42 Changed by Cattell on 15-Dec-81 10:16:23 Changed by Cattell on April 29, 1982 8:23 pm Changed by Willie-Sue on June 24, 1982 12:00 pm Changed by Cattell on October 11, 1982 3:25 pm Changed by MBrown on November 29, 1982 2:04 pm Changed by Willie-Sue on February 15, 1985 †File DBStats.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Last edited by: MBrown on November 29, 1982 2:04 pm Cattell on March 14, 1983 2:08 pm Willie-Sue on February 15, 1985 11:09:54 am PST Widom, August 26, 1985 10:52:23 am PDT Donahue, March 12, 1986 9:20:42 am PST This is the interface to the Cedar database statistics gathering facility. There are two kinds of "events": counter and timer. Counter events are for logging the freqency with which a specific action or set of actions is performed. If e is a counter event, then Inc[e] causes e's counter to be incremented by 1. Inc[e] is very inexpensive to perform. Timer events are for logging the time required for a specific action or set of actions. If e is a timer event, then Starting[e] records the current time in a variable associated with e. Then when Stopping[e] is performed at some later time, it notes the difference between the current time and the time recorded by the previous Starting[e]. At a minimum, the average value of this time interval is maintained; a more elaborate implementation may also be supplied (max value, standard deviation, histogram, ...). Starting[e] and Stopping[e] involve one procedure call each and hence are more expensive than Inc[e] (but note that events are statically typed so only one set of operations applies to an event in any case). When two calls to Starting[e] occur in succession with no intervening Stopping[e], the first Starting[e] is ignored; when two calls to Stopping[e] occur consecutively, the last is ignored. Each of these situations counts as a "glitch", and the number of glitches is reported for debugging purposes during Print, described below. Glitches may occur due to a failure to call Stopping[e] during the UNWIND of a procedure activation that called Starting[e]; a glitch is not a fatal error because we consider it cumbersome to provide a catch for UNWIND simply to avoid glitches. Any program using this package must initialize the stats implementation module by calling DBStats.Initialize[] before calling Inc[e] or Starting[e]. The current state of all active counters and timers is appended to the file "DBStats.log" by DBStats.Print[]; this does not change the state of counters or timers, but resets the count of glitches to 0. ERROR is raised if Print is called before Initialize. Initialize should be called to reinitialize the stats module after printing if independent statistics are desired. Inc[e], Starting[e], and Stopping[e] are all INLINE procedures, and calls to them with compile-time constant parameters produce no code when the procedure bodies below are made empty. Hence calls to these procedures may be imbedded freely in a system for testing, and then this defs module can be stubbed (all procs INLINE with empty bodies) for the efficient "production" version. Initializes stats module. DBCache-- DBSegment-- DBStorage (Tuples)-- DBStorage (BTree)-- Increments the counter associated with event. DBFile-- DBModel-- Glitch if an unmatched Starting[event]; older Starting[event] is superceded by this one. Logs time since previous Starting[event]. Glitch if no unmatched Starting[event]; this Stopping call is ignored. Cancel count of event (same as Stopping, but doesn't count the time). Prints current state of stats module to outStream, then resets glitch count. If verbose then print all events, otherwise just print nonzero ones. Private implementation details Document the fact that Print prints to file DBStats.log, not IODefs.WriteChar. Introduce glitches (instead of raising ERROR), based on use of timer events in DBFileImpl. Added some timer events. Added header parm to Print; added new DBTuples timer events. Flushed all DBTuples timer events. Added BTree counter events. Added Attribute cache counter events. Added OpenToClose timer event, defined FileTimerEvent subrange. Added FileAbortTransaction timer event. Added putChar, cleanup, and verbose parms to Print. Added CloseDBGroupScansActive, CloseDBTuplesetScansActive counters. Modified to use IOStream. Added DBView events. IOStream => IO Added more DBView events, removed old DBTuples events. Added Aborting. New DBFile events Made Cedar, added tioga formatting Κ ˜šœ™Jšœ Οmœ1™<—šœ™Jšœ#™#Jšœ!™!Jšœ/™/J™&Icode™&—J˜JšΟk œžœ˜J˜šœ žœž œž˜"JšœJ™JJ˜Jšœ3™3J˜JšœR™RJšœT™TJšœ9™9J˜JšœN™NJšœO™OJšœS™SJšœM™MJšœO™OJšœL™LJšœM™MJšœR™RJšœT™TJ˜JšœR™RJšœT™TJšœS™SJšœN™NJšœN™NJšœS™SJšœQ™QJ˜JšœQ™QJšœO™OJšœP™PJšœQ™QJšœS™SJšœN™NJšœ#™#J˜JšœQ™QJšœO™OJšœR™RJšœS™SJšœ5™5J˜J˜šΟn œžœ˜Jšœ™J˜—šœžœ˜Jšœ ™ J˜J˜J˜J˜ J˜Jšœ ™ J˜J˜Jšœ™J˜J˜J˜J˜J˜J˜J˜J˜J˜J˜J˜J˜J˜Jšœ™J˜J˜J˜J˜J˜J˜J˜J˜J˜—J˜J˜šŸœžœ˜ Jšžœ3˜9Jšœ-™-J˜—šœ žœ˜Jšœ™J˜J˜J˜J˜J˜J˜J˜Jšœ ™ J˜J˜J˜J˜J˜J˜ J˜J˜J˜J˜J˜J˜ J˜J˜ J˜ J˜J˜Jšœ˜J˜J˜J˜J˜J˜J˜ J˜J˜ J˜ J˜ J˜ J˜ —J˜J˜JšœžœB˜VJ˜šŸœžœžœ˜AJšœN™NJšœ ™ J˜—šŸœžœžœ˜@Jšœ)™)JšœF™FJ˜—šŸœžœžœ˜AJšœE™EJ˜—šŸœžœžœžœžœžœžœ žœžœ˜UJšœL™LJšœD™DJ˜J˜—Jšœ™J˜Jš œžœžœžœžœžœ˜:JšŸ œžœžœ˜,JšŸ œžœžœ˜,JšŸ œžœžœ˜,J˜J˜—JšžœΟc ˜J˜J˜Jšžœž˜ J˜Jšœ/ž˜1J˜Jšœ.ž˜0JšœN™NJ˜Jšœ.ž˜0JšœN™NJšœ ™ J˜Jšœ/ž˜1Jšœ™J˜Jšœ-ž˜/Jšœ<™