Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4fd64b9

Browse files
committed
remove ceval timestamp support
1 parent ad46443 commit 4fd64b9

9 files changed

Lines changed: 1 addition & 268 deletions

File tree

Doc/library/sys.rst

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,18 +1104,6 @@ always available.
11041104
thus may not be available in all Python implementations.
11051105

11061106

1107-
.. function:: settscdump(on_flag)
1108-
1109-
Activate dumping of VM measurements using the Pentium timestamp counter, if
1110-
*on_flag* is true. Deactivate these dumps if *on_flag* is off. The function is
1111-
available only if Python was compiled with ``--with-tsc``. To understand
1112-
the output of this dump, read :file:`Python/ceval.c` in the Python sources.
1113-
1114-
.. impl-detail::
1115-
This function is intimately bound to CPython implementation details and
1116-
thus not likely to be implemented elsewhere.
1117-
1118-
11191107
.. function:: set_coroutine_wrapper(wrapper)
11201108

11211109
Allows intercepting creation of :term:`coroutine` objects (only ones that

Include/pystate.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ typedef struct _is {
4343
#ifdef HAVE_DLOPEN
4444
int dlopenflags;
4545
#endif
46-
#ifdef WITH_TSC
47-
int tscdump;
48-
#endif
4946

5047
PyObject *builtins_copy;
5148
PyObject *import_func;

Misc/SpecialBuilds.txt

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -234,29 +234,3 @@ When this symbol is defined, the ceval mainloop and helper functions count the
234234
number of function calls made. It keeps detailed statistics about what kind of
235235
object was called and whether the call hit any of the special fast paths in the
236236
code.
237-
238-
239-
WITH_TSC
240-
--------
241-
242-
Super-lowlevel profiling of the interpreter. When enabled, the sys module grows
243-
a new function:
244-
245-
settscdump(bool)
246-
If true, tell the Python interpreter to dump VM measurements to stderr. If
247-
false, turn off dump. The measurements are based on the processor's
248-
time-stamp counter.
249-
250-
This build option requires a small amount of platform specific code. Currently
251-
this code is present for linux/x86 and any PowerPC platform that uses GCC
252-
(i.e. OS X and linux/ppc).
253-
254-
On the PowerPC the rate at which the time base register is incremented is not
255-
defined by the architecture specification, so you'll need to find the manual for
256-
your specific processor. For the 750CX, 750CXe and 750FX (all sold as the G3)
257-
we find:
258-
259-
The time base counter is clocked at a frequency that is one-fourth that of
260-
the bus clock.
261-
262-
This build is enabled by the --with-tsc flag to configure.

Python/ceval.c

Lines changed: 1 addition & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -20,82 +20,6 @@
2020

2121
#include <ctype.h>
2222

23-
#ifndef WITH_TSC
24-
25-
#define READ_TIMESTAMP(var)
26-
27-
#else
28-
29-
typedef unsigned long long uint64;
30-
31-
/* PowerPC support.
32-
"__ppc__" appears to be the preprocessor definition to detect on OS X, whereas
33-
"__powerpc__" appears to be the correct one for Linux with GCC
34-
*/
35-
#if defined(__ppc__) || defined (__powerpc__)
36-
37-
#define READ_TIMESTAMP(var) ppc_getcounter(&var)
38-
39-
static void
40-
ppc_getcounter(uint64 *v)
41-
{
42-
unsigned long tbu, tb, tbu2;
43-
44-
loop:
45-
asm volatile ("mftbu %0" : "=r" (tbu) );
46-
asm volatile ("mftb %0" : "=r" (tb) );
47-
asm volatile ("mftbu %0" : "=r" (tbu2));
48-
if (__builtin_expect(tbu != tbu2, 0)) goto loop;
49-
50-
/* The slightly peculiar way of writing the next lines is
51-
compiled better by GCC than any other way I tried. */
52-
((long*)(v))[0] = tbu;
53-
((long*)(v))[1] = tb;
54-
}
55-
56-
#elif defined(__i386__)
57-
58-
/* this is for linux/x86 (and probably any other GCC/x86 combo) */
59-
60-
#define READ_TIMESTAMP(val) \
61-
__asm__ __volatile__("rdtsc" : "=A" (val))
62-
63-
#elif defined(__x86_64__)
64-
65-
/* for gcc/x86_64, the "A" constraint in DI mode means *either* rax *or* rdx;
66-
not edx:eax as it does for i386. Since rdtsc puts its result in edx:eax
67-
even in 64-bit mode, we need to use "a" and "d" for the lower and upper
68-
32-bit pieces of the result. */
69-
70-
#define READ_TIMESTAMP(val) do { \
71-
unsigned int h, l; \
72-
__asm__ __volatile__("rdtsc" : "=a" (l), "=d" (h)); \
73-
(val) = ((uint64)l) | (((uint64)h) << 32); \
74-
} while(0)
75-
76-
77-
#else
78-
79-
#error "Don't know how to implement timestamp counter for this architecture"
80-
81-
#endif
82-
83-
void dump_tsc(int opcode, int ticked, uint64 inst0, uint64 inst1,
84-
uint64 loop0, uint64 loop1, uint64 intr0, uint64 intr1)
85-
{
86-
uint64 intr, inst, loop;
87-
PyThreadState *tstate = PyThreadState_Get();
88-
if (!tstate->interp->tscdump)
89-
return;
90-
intr = intr1 - intr0;
91-
inst = inst1 - inst0 - intr;
92-
loop = loop1 - loop0 - intr;
93-
fprintf(stderr, "opcode=%03d t=%d inst=%06lld loop=%06lld\n",
94-
opcode, ticked, inst, loop);
95-
}
96-
97-
#endif
98-
9923
/* Turn this on if your compiler chokes on the big switch: */
10024
/* #define CASE_TOO_BIG 1 */
10125

@@ -108,11 +32,7 @@ void dump_tsc(int opcode, int ticked, uint64 inst0, uint64 inst1,
10832
typedef PyObject *(*callproc)(PyObject *, PyObject *, PyObject *);
10933

11034
/* Forward declarations */
111-
#ifdef WITH_TSC
112-
static PyObject * call_function(PyObject ***, Py_ssize_t, PyObject *, uint64*, uint64*);
113-
#else
11435
static PyObject * call_function(PyObject ***, Py_ssize_t, PyObject *);
115-
#endif
11636
static PyObject * fast_function(PyObject *, PyObject **, Py_ssize_t, PyObject *);
11737
static PyObject * do_call_core(PyObject *, PyObject *, PyObject *);
11838

@@ -938,46 +858,6 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
938858
#define GETITEM(v, i) PyTuple_GetItem((v), (i))
939859
#endif
940860

941-
#ifdef WITH_TSC
942-
/* Use Pentium timestamp counter to mark certain events:
943-
inst0 -- beginning of switch statement for opcode dispatch
944-
inst1 -- end of switch statement (may be skipped)
945-
loop0 -- the top of the mainloop
946-
loop1 -- place where control returns again to top of mainloop
947-
(may be skipped)
948-
intr1 -- beginning of long interruption
949-
intr2 -- end of long interruption
950-
951-
Many opcodes call out to helper C functions. In some cases, the
952-
time in those functions should be counted towards the time for the
953-
opcode, but not in all cases. For example, a CALL_FUNCTION opcode
954-
calls another Python function; there's no point in charge all the
955-
bytecode executed by the called function to the caller.
956-
957-
It's hard to make a useful judgement statically. In the presence
958-
of operator overloading, it's impossible to tell if a call will
959-
execute new Python code or not.
960-
961-
It's a case-by-case judgement. I'll use intr1 for the following
962-
cases:
963-
964-
IMPORT_STAR
965-
IMPORT_FROM
966-
CALL_FUNCTION (and friends)
967-
968-
*/
969-
uint64 inst0, inst1, loop0, loop1, intr0 = 0, intr1 = 0;
970-
int ticked = 0;
971-
972-
READ_TIMESTAMP(inst0);
973-
READ_TIMESTAMP(inst1);
974-
READ_TIMESTAMP(loop0);
975-
READ_TIMESTAMP(loop1);
976-
977-
/* shut up the compiler */
978-
opcode = 0;
979-
#endif
980-
981861
/* Code access macros */
982862

983863
#ifdef WORDS_BIGENDIAN
@@ -1225,23 +1105,6 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
12251105
#endif
12261106

12271107
for (;;) {
1228-
#ifdef WITH_TSC
1229-
if (inst1 == 0) {
1230-
/* Almost surely, the opcode executed a break
1231-
or a continue, preventing inst1 from being set
1232-
on the way out of the loop.
1233-
*/
1234-
READ_TIMESTAMP(inst1);
1235-
loop1 = inst1;
1236-
}
1237-
dump_tsc(opcode, ticked, inst0, inst1, loop0, loop1,
1238-
intr0, intr1);
1239-
ticked = 0;
1240-
inst1 = 0;
1241-
intr0 = 0;
1242-
intr1 = 0;
1243-
READ_TIMESTAMP(loop0);
1244-
#endif
12451108
assert(stack_pointer >= f->f_valuestack); /* else underflow */
12461109
assert(STACK_LEVEL() <= co->co_stacksize); /* else overflow */
12471110
assert(!PyErr_Occurred());
@@ -1260,9 +1123,6 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
12601123
a try: finally: block uninterruptible. */
12611124
goto fast_next_opcode;
12621125
}
1263-
#ifdef WITH_TSC
1264-
ticked = 1;
1265-
#endif
12661126
if (_Py_atomic_load_relaxed(&pendingcalls_to_do)) {
12671127
if (Py_MakePendingCalls() < 0)
12681128
goto error;
@@ -3403,11 +3263,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
34033263
PyObject **sp, *res;
34043264
PCALL(PCALL_ALL);
34053265
sp = stack_pointer;
3406-
#ifdef WITH_TSC
3407-
res = call_function(&sp, oparg, NULL, &intr0, &intr1);
3408-
#else
34093266
res = call_function(&sp, oparg, NULL);
3410-
#endif
34113267
stack_pointer = sp;
34123268
PUSH(res);
34133269
if (res == NULL) {
@@ -3423,11 +3279,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
34233279
assert(PyTuple_CheckExact(names) && PyTuple_GET_SIZE(names) <= oparg);
34243280
PCALL(PCALL_ALL);
34253281
sp = stack_pointer;
3426-
#ifdef WITH_TSC
3427-
res = call_function(&sp, oparg, names, &intr0, &intr1);
3428-
#else
34293282
res = call_function(&sp, oparg, names);
3430-
#endif
34313283
stack_pointer = sp;
34323284
PUSH(res);
34333285
Py_DECREF(names);
@@ -4922,11 +4774,7 @@ if (tstate->use_tracing && tstate->c_profilefunc) { \
49224774
}
49234775

49244776
static PyObject *
4925-
call_function(PyObject ***pp_stack, Py_ssize_t oparg, PyObject *kwnames
4926-
#ifdef WITH_TSC
4927-
, uint64* pintr0, uint64* pintr1
4928-
#endif
4929-
)
4777+
call_function(PyObject ***pp_stack, Py_ssize_t oparg, PyObject *kwnames)
49304778
{
49314779
PyObject **pfunc = (*pp_stack) - oparg - 1;
49324780
PyObject *func = *pfunc;

Python/pystate.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ PyInterpreterState_New(void)
9898
#else
9999
interp->dlopenflags = RTLD_LAZY;
100100
#endif
101-
#endif
102-
#ifdef WITH_TSC
103-
interp->tscdump = 0;
104101
#endif
105102

106103
HEAD_LOCK();

Python/sysmodule.c

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -609,33 +609,6 @@ PyDoc_STRVAR(getswitchinterval_doc,
609609

610610
#endif /* WITH_THREAD */
611611

612-
#ifdef WITH_TSC
613-
static PyObject *
614-
sys_settscdump(PyObject *self, PyObject *args)
615-
{
616-
int bool;
617-
PyThreadState *tstate = PyThreadState_Get();
618-
619-
if (!PyArg_ParseTuple(args, "i:settscdump", &bool))
620-
return NULL;
621-
if (bool)
622-
tstate->interp->tscdump = 1;
623-
else
624-
tstate->interp->tscdump = 0;
625-
Py_INCREF(Py_None);
626-
return Py_None;
627-
628-
}
629-
630-
PyDoc_STRVAR(settscdump_doc,
631-
"settscdump(bool)\n\
632-
\n\
633-
If true, tell the Python interpreter to dump VM measurements to\n\
634-
stderr. If false, turn off dump. The measurements are based on the\n\
635-
processor's time-stamp counter."
636-
);
637-
#endif /* TSC */
638-
639612
static PyObject *
640613
sys_setrecursionlimit(PyObject *self, PyObject *args)
641614
{
@@ -1410,9 +1383,6 @@ static PyMethodDef sys_methods[] = {
14101383
{"getprofile", sys_getprofile, METH_NOARGS, getprofile_doc},
14111384
{"setrecursionlimit", sys_setrecursionlimit, METH_VARARGS,
14121385
setrecursionlimit_doc},
1413-
#ifdef WITH_TSC
1414-
{"settscdump", sys_settscdump, METH_VARARGS, settscdump_doc},
1415-
#endif
14161386
{"settrace", sys_settrace, METH_O, settrace_doc},
14171387
{"gettrace", sys_gettrace, METH_NOARGS, gettrace_doc},
14181388
{"call_tracing", sys_call_tracing, METH_VARARGS, call_tracing_doc},

configure

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,6 @@ with_threads
830830
with_thread
831831
enable_ipv6
832832
with_doc_strings
833-
with_tsc
834833
with_pymalloc
835834
with_valgrind
836835
with_fpectl
@@ -1534,7 +1533,6 @@ Optional Packages:
15341533
--with(out)-thread[=DIRECTORY]
15351534
deprecated; use --with(out)-threads
15361535
--with(out)-doc-strings disable/enable documentation strings
1537-
--with(out)-tsc enable/disable timestamp counter profile
15381536
--with(out)-pymalloc disable/enable specialized mallocs
15391537
--with-valgrind Enable Valgrind support
15401538
--with-fpectl enable SIGFPE catching
@@ -10798,29 +10796,6 @@ fi
1079810796
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_doc_strings" >&5
1079910797
$as_echo "$with_doc_strings" >&6; }
1080010798

10801-
# Check if eval loop should use timestamp counter profiling
10802-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-tsc" >&5
10803-
$as_echo_n "checking for --with-tsc... " >&6; }
10804-
10805-
# Check whether --with-tsc was given.
10806-
if test "${with_tsc+set}" = set; then :
10807-
withval=$with_tsc;
10808-
if test "$withval" != no
10809-
then
10810-
10811-
$as_echo "#define WITH_TSC 1" >>confdefs.h
10812-
10813-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
10814-
$as_echo "yes" >&6; }
10815-
else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
10816-
$as_echo "no" >&6; }
10817-
fi
10818-
else
10819-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
10820-
$as_echo "no" >&6; }
10821-
fi
10822-
10823-
1082410799
# Check for Python-specific malloc support
1082510800
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-pymalloc" >&5
1082610801
$as_echo_n "checking for --with-pymalloc... " >&6; }

configure.ac

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3198,19 +3198,6 @@ then
31983198
fi
31993199
AC_MSG_RESULT($with_doc_strings)
32003200

3201-
# Check if eval loop should use timestamp counter profiling
3202-
AC_MSG_CHECKING(for --with-tsc)
3203-
AC_ARG_WITH(tsc,
3204-
AS_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[
3205-
if test "$withval" != no
3206-
then
3207-
AC_DEFINE(WITH_TSC, 1,
3208-
[Define to profile with the Pentium timestamp counter])
3209-
AC_MSG_RESULT(yes)
3210-
else AC_MSG_RESULT(no)
3211-
fi],
3212-
[AC_MSG_RESULT(no)])
3213-
32143201
# Check for Python-specific malloc support
32153202
AC_MSG_CHECKING(for --with-pymalloc)
32163203
AC_ARG_WITH(pymalloc,

0 commit comments

Comments
 (0)