Manual Pages for UNIX Darwin command on man ttrace
MyWebUniversity

Manual Pages for UNIX Darwin command on man ttrace

ttrace(n) ttrace(n)

NAME

ttrace - Trace-based interpreter initialization

SYNOPSIS

package require TTccll 88..33 package require TThhrreeaadd ??22..66?? ttttrraaccee::::eevvaall arg ?arg ...? ttttrraaccee::::eennaabbllee ttttrraaccee::::ddiissaabbllee ttttrraaccee::::cclleeaannuupp ttttrraaccee::::uuppddaattee ?epoch? ttttrraaccee::::ggeettssccrriipptt ttttrraaccee::::aatteennaabbllee cmd arglist body ttttrraaccee::::aattddiissaabbllee cmd arglist body ttttrraaccee::::aaddddttrraaccee cmd arglist body ttttrraaccee::::aaddddssccrriipptt name body ttttrraaccee::::aaddddrreessoollvveerr cmd arglist body ttttrraaccee::::aaddddcclleeaannuupp body ttttrraaccee::::aaddddeennttrryy cmd var val ttttrraaccee::::ggeetteennttrryy cmd var ttttrraaccee::::ggeetteennttrriieess cmd ?pattern? ttttrraaccee::::ddeelleennttrryy cmd ttttrraaccee::::pprreellooaadd cmd

DESCRIPTION

This package creates a framework for on-demand replication of the

interpreter state accross threads in an multithreading application. It relies on the mechanics of the Tcl uunnkknnoowwnn command mechanism. The package requires Tcl threading extension but can be alternatively

used stand-alone within the AOLserver, a scalable webserver from Amer-

ica Online. UUSSEERR CCOOMMMMAANNDDSS

This section describes user-level commands. Those commands can be used

by script writers to control the execution of the tracing framework. ttttrraaccee::::eevvaall arg ?arg ...? This command concatenates given arguments and evaluates the

resulting Tcl command with trace framework enabled. If the com-

mand execution was ok, it takes necessary steps to automatically

propagate the trace epoch change to all threads in the applica-

tion. For AOLserver, only newly created threads actually receive the epoch change. For the Tcl threading extension, all threads created by the extension are automatically updated. If

the command execution resulted in Tcl error, no state propaga-

tion takes place.

This is the most important user-level command of the package as

it wraps most of the commands described below. This greatly sim-

plifies things, because user need to learn just this (one) com-

mand in order to effectively use the package. Other commands, as

desribed below, are included mostly for the sake of complete-

ness. ttttrraaccee::::eennaabbllee Activates all registered callbacks in the framework and starts a new trace epoch. The trace epoch encapsulates all changes done to the interpreter during the time traces are activated. ttttrraaccee::::ddiissaabbllee Deactivates all registered callbacks in the framework and closes the current trace epoch. ttttrraaccee::::cclleeaannuupp

Used to clean-up all on-demand loaded resources in the inter-

preter. It effectively brings Tcl interpreter to its pristine state. ttttrraaccee::::uuppddaattee ?epoch? Used to refresh the state of the interpreter to match the optional trace ?epoch?. If the optional ?epoch? is not given, it takes the most recent trace epoch. ttttrraaccee::::ggeettssccrriipptt Returns a synthesized Tcl script which may be sourced in any interpreter. This script sets the stage for the Tcl uunnkknnoowwnn

command so it can load traced resources from the in-memory data-

base. Normally, this command is automatically invoked by other

higher-level commands like ttttrraaccee::::eevvaall and ttttrraaccee::::uuppddaattee.

CCAALLLLBBAACCKK CCOOMMMMAANNDDSS

A word upfront: the package already includes callbacks for tracing fol-

lowing Tcl commands: pprroocc, nnaammeessppaaccee, vvaarriiaabbllee, llooaadd, and rreennaammee. Addi-

tionaly, a set of callbacks for tracing resources (object, clasess) for

the XOTcl v1.1.0+, an OO-extension to Tcl, is also provided. This

gives a solid base for solving most of the real-life needs and serves

as an example for people wanting to customize the package to cover their specific needs. Below, you can find commands for registering callbacks in the framework and for writing callback scripts. These callbacks are invoked by the

framework in order to gather interpreter state changes, build in-memory

database, perform custom-cleanups and various other tasks.

ttttrraaccee::::aatteennaabbllee cmd arglist body

Registers Tcl callback to be activated at ttttrraaccee::::eennaabbllee. Reg-

istered callbacks are activated on FIFO basis. The callback def-

inition includes the name of the callback, cmd, a list of call-

back arguments, arglist and the body of the callback. Effec-

tively, this actually resembles the call interface of the stan-

dard Tcl pprroocc command. ttttrraaccee::::aattddiissaabbllee cmd arglist body

Registers Tcl callback to be activated at ttttrraaccee::::ddiissaabbllee. Reg-

istered callbacks are activated on FIFO basis. The callback def-

inition includes the name of the callback, cmd, a list of call-

back arguments, arglist and the body of the callback. Effec-

tively, this actually resembles the call interface of the stan-

dard Tcl pprroocc command. ttttrraaccee::::aaddddttrraaccee cmd arglist body Registers Tcl callback to be activated for tracing the Tcl ccmmdd command. The callback definition includes the name of the Tcl command to trace, cmd, a list of callback arguments, arglist and the body of the callback. Effectively, this actually resembles the call interface of the standard Tcl pprroocc command. ttttrraaccee::::aaddddssccrriipptt name body Registers Tcl callback to be activated for building a Tcl script to be passed to other interpreters. This script is used to set the stage for the Tcl uunnkknnoowwnn command. Registered callbacks are activated on FIFO basis. The callback definition includes the name of the callback, name and the body of the callback. ttttrraaccee::::aaddddrreessoollvveerr cmd arglist body Registers Tcl callback to be activated by the overloaded Tcl uunnkknnoowwnn command. Registered callbacks are activated on FIFO basis. This callback is used to resolve the resource and load the resource in the current interpreter. ttttrraaccee::::aaddddcclleeaannuupp body Registers Tcl callback to be activated by the ttrraaccee::::cclleeaannuupp. Registered callbacks are activated on FIFO basis. ttttrraaccee::::aaddddeennttrryy cmd var val

Adds one entry to the named in-memory database.

ttttrraaccee::::ggeetteennttrryy cmd var

Returns the value of the entry from the named in-memory data-

base. ttttrraaccee::::ggeetteennttrriieess cmd ?pattern?

Returns names of all entries from the named in-memory database.

ttttrraaccee::::ddeelleennttrryy cmd

Deletes an entry from the named in-memory database.

ttttrraaccee::::pprreellooaadd cmd

Registers the Tcl command to be loaded in the interpreter. Com-

mands registered this way will always be the part of the inter-

preter and not be on-demand loaded by the Tcl uunnkknnoowwnn command.

DDIISSCCUUSSSSIIOONN

Common introspective state-replication approaches use a custom Tcl

script to introspect the running interpreter and synthesize another Tcl

script to replicate this state in some other interpreter. This pack-

age, on the contrary, uses Tcl command traces. Command traces are reg-

istered on selected Tcl commands, like pprroocc, nnaammeessppaaccee, llooaadd and other

standard (and/or user-defined) Tcl commands. When activated, those

traces build an in-memory database of created resources. This database

is used as a resource repository for the (overloaded) Tcl uunnkknnoowwnn com-

mand which creates the requested resource in the interpreter on demand. This way, users can update just one interpreter (master) in one thread and replicate that interpreter state (or part of it) to other threads/interpreters in the process. Immediate benefit of such approach is the much smaller memory footprint of the application and much faster thread creation. By not actually loading all necessary procedures (and other resources) in every thread at the thread initialization time, but by deffering this to the time the resource is actually referenced, significant improvements in both memory consumption and thread initialization time can be achieved. Some

tests have shown that memory footprint of an multithreading Tcl appli-

cation went down more than three times and thread startup time was reduced for about 50 times. Note that your mileage may vary. Other

benefits include much finer control about what (and when) gets repli-

cated from the master to other Tcl thread/interpreters.

SEE ALSO

thread, tpool, tsv KKEEYYWWOORRDDSS command tracing, introspection

Tcl Threading 2.6 ttrace(n)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™