\documentclass[]{article}
\usepackage{amsmath,graphicx,supertabular,hyperref,tabularx,ifthen}
\title{TIP \#378: Fixing the Performance of TIP 280}
\date{October 04, 2010}
\author{Andreas Kupries, Jeff Hobbs}
\urlstyle{sf}
\setlength{\parskip}{1ex}
\setlength{\parindent}{0pt}
\def\tipversion$#1${\texttt{\$#1\$}}
\def\tiplangle#1{\ensuremath{<}}
\def\tiprangle#1{\ensuremath{>}}
\def\tipbar#1{\ensuremath{|}}
\def\tipmail#1#2{\(\langle\){\small\expandafter\url{#1@#2}}\(\rangle\)}
\ifx\pdfoutput\undefined
\newcommand{\tipimage}[2]{\typeout{Make sure you download #1.eps}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.eps}}{\includegraphics[width=0.8\textwidth]{#1.eps}}}
\newcommand{\tipxref}[1]{}
\newcommand{\tipxrefend}{}
\else
\newcommand{\tipimage}[2]{\typeout{Make sure you create #1.pdf}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.pdf}}{\includegraphics[width=0.8\textwidth]{#1.pdf}}}
\pdfcatalog{/PageMode /UseOutlines}
\newcommand{\tipxref}[1]{\pdfannotlink attr {/C [0.5 0.5 1.0] /Border [0 0 1]} goto name {#1}}
\newcommand{\tipxrefend}{\pdfendlink}
\fi
\newenvironment{tipabstract}{\begin{abstract}}{\end{abstract}}
\begin{document}\maketitle
\begin{center}\begin{tabularx}{\linewidth}{|r@{: }X|}\hline
\textbf{TIP \#378}&\textbf{Fixing the Performance of TIP 280}\\\hline
Author&

Andreas Kupries \tipmail{andreask}{activestate.com}
\par
Jeff Hobbs \tipmail{jeffh}{activestate.com}
\\
Created&Monday, \(\text{4}^{\text{th}}\) October 2010\\
Type&Project\\
Tcl Version&\(8.6\)\\
State&Final\\
Vote&Done\\
Version&\tipversion$Revision: 1.3 $\\
Post History&\\
\hline\end{tabularx}\end{center}
\thispagestyle{empty}\pagestyle{empty}
\begin{tipabstract}

A Tcl command is proposed which enable a user of Tcl to disable the most performance intensive parts of the \cite{tip280} implementation, at the loss of some detail.
\end{tipabstract}
\tableofcontents\setcounter{page}{0}\clearpage\pagestyle{plain}

\section{Background and Motivation}

\cite{tip280} extended Tcl's abilities for introspection with the \textbf{info frame} command able to determine the location of its call, i.e., the name of the file the code is in, and the absolute line number in that file.

In the quest for the best possible detail one particular part of the implementation had a great impact on the performance of bytecode execution, doing complex stack/hash manipulations for each argument of each INST\_INVOKE\_STK instruction to keep track of the location of scripts delivered to \textbf{uplevel} commands as arguments of Tcl procedures (i.e., implementations of control structures in Tcl).

This TIP now proposes to put the execution of this part of \cite{tip280}'s implementation under user control, allowing them to trade \textbf{info frame}-exactness for speed, and vice versa.

\section{Script Level API}

\begin{quote}
\textbf{interp debug} \textit{interp-path} ?\textbf{-frame} ?\textit{boolean}??
\end{quote}

This API was chosen to be potentially extensible for other future interpreter level control needs.

\subsection{Default Setting}

This behavior will be turned off by default, unless Tcl is compiled with -DTCL\_INTERP\_DEBUG\_FRAME or \$::env(TCL\_INTERP\_DEBUG\_FRAME) is set at interpreter creation time.

Note that this is a one-way switch because the \textbf{info frame} tracking is maintained in a stack that must remain consistent once switched on. Switching off when deep in the stack would cause memory loss and possible crashes without tracing on top of tracing, and it is felt that being an interp-level switch, one-way switching should be sufficient for user needs.

\section{Reference Implementation}

A reference implementation is provided at SourceForge [\url{https://sourceforge.net/support/tracker.php?aid=3081184}].

\section{Copyright}

This document has been placed in the public domain.

\section{Colophon}

\textit{TIP AutoGenerator --- written by Donal K. Fellows}
\begin{thebibliography}{TIP \#1}
\addcontentsline{toc}{section}{References}
\bibitem[TIP \#280]{tip280}
Andreas Kupries,
Andreas Kupries,
\emph{Add Full Stack Trace Capability With Location Introspection},
on-line at \url{http://purl.org/tcl/tip/280.html}
\end{thebibliography}
\end{document}
