This is really interesting. It'd be great to have this up in testman somehow.
-----Original Message-----
From: ros-diffs-bounces(a)reactos.org [mailto:ros-diffs-bounces@reactos.org] On Behalf Of
sir_richard(a)svn.reactos.org
Sent: 28 January 2010 15:51
To: ros-diffs(a)reactos.org
Subject: [ros-diffs] [sir_richard] 45297: [PERF]: Not in any way a scientific number you
should bet the farm on, but we do now count the number of cycles at the very first
instruction of kernel initialization, at the moment SMSS initializes the registry (when we
c
Author: sir_richard
Date: Thu Jan 28 16:51:18 2010
New Revision: 45297
URL:
http://svn.reactos.org/svn/reactos?rev=45297&view=rev
Log:
[PERF]: Not in any way a scientific number you should bet the farm on, but we do now count
the number of cycles at the very first instruction of kernel initialization, at the moment
SMSS initializes the registry (when we call kernel initialization complete), and at the
moment there have been 12 processes created (10 without counting idle/system), which is a
bit less than a normal GUI boot. We also display the number if interrupts, system calls,
and context switches it took to get us there. A purely comparative number, perhaps worthy
for inclusion in testman/regression tests?
Modified:
trunk/reactos/ntoskrnl/config/ntapi.c
trunk/reactos/ntoskrnl/include/internal/ke.h
trunk/reactos/ntoskrnl/ke/i386/kiinit.c
trunk/reactos/ntoskrnl/ps/process.c
Modified: trunk/reactos/ntoskrnl/config/ntapi.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/ntapi.c?re…
==============================================================================
--- trunk/reactos/ntoskrnl/config/ntapi.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/config/ntapi.c [iso-8859-1] Thu Jan 28 16:51:18 2010
@@ -890,6 +890,14 @@
/* Always do this as kernel mode */
if (KeGetPreviousMode() == UserMode) return ZwInitializeRegistry(Flag);
+ /* Enough of the system has booted by now */
+ BootCyclesEnd = __rdtsc();
+ DPRINT1("Boot took %I64d cycles!\n", BootCyclesEnd - BootCycles);
+ DPRINT1("Interrupts: %d System Calls: %d Context Switches: %d\n",
+ KeGetCurrentPrcb()->InterruptCount,
+ KeGetCurrentPrcb()->KeSystemCalls,
+ KeGetContextSwitches(KeGetCurrentPrcb()));
+
/* Validate flag */
if (Flag > CM_BOOT_FLAG_MAX) return STATUS_INVALID_PARAMETER;
Modified: trunk/reactos/ntoskrnl/include/internal/ke.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/ke.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/ke.h [iso-8859-1] Thu Jan 28 16:51:18 2010
@@ -139,6 +139,8 @@
extern ULONG KiFreezeFlag;
extern ULONG KiDPCTimeout;
extern PGDI_BATCHFLUSH_ROUTINE KeGdiFlushUserBatch;
+extern ULONGLONG BootCycles, BootCyclesEnd;
+extern ULONG ProcessCount;
/* MACROS *************************************************************************/
Modified: trunk/reactos/ntoskrnl/ke/i386/kiinit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/kiinit.c?…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/kiinit.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/i386/kiinit.c [iso-8859-1] Thu Jan 28 16:51:18 2010
@@ -24,6 +24,10 @@
/* Spinlocks used only on X86 */
KSPIN_LOCK KiFreezeExecutionLock;
KSPIN_LOCK Ki486CompatibilityLock;
+
+/* Perf */
+ULONG ProcessCount;
+ULONGLONG BootCycles, BootCyclesEnd;
/* FUNCTIONS *****************************************************************/
@@ -683,6 +687,9 @@
PKTSS Tss;
PKIPCR Pcr;
+ /* Boot cycles timestamp */
+ BootCycles = __rdtsc();
+
/* Check if we are being booted from FreeLDR */
if (!((ULONG_PTR)LoaderBlock & 0x80000000))
KiRosPrepareForSystemStartup((PROS_LOADER_PARAMETER_BLOCK)LoaderBlock);
Modified: trunk/reactos/ntoskrnl/ps/process.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/process.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/ps/process.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ps/process.c [iso-8859-1] Thu Jan 28 16:51:18 2010
@@ -843,6 +843,18 @@
/* Run the Notification Routines */
PspRunCreateProcessNotifyRoutines(Process, TRUE);
+
+ /* If 12 processes have been created, enough of user-mode is ready */
+ if (++ProcessCount == 12)
+ {
+ /* Enough of the system has booted by now */
+ BootCyclesEnd = __rdtsc();
+ DPRINT1("User Boot took %I64d cycles!\n", BootCyclesEnd - BootCycles);
+ DPRINT1("Interrupts: %d System Calls: %d Context Switches: %d\n",
+ KeGetCurrentPrcb()->InterruptCount,
+ KeGetCurrentPrcb()->KeSystemCalls,
+ KeGetContextSwitches(KeGetCurrentPrcb()));
+ }
CleanupWithRef:
/*