From da7d769c4336f8d84c1179d950d79ab3fe64d0bb Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Thu, 28 Jan 2010 15:51:18 +0000 Subject: [PATCH] [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? svn path=/trunk/; revision=45297 --- reactos/ntoskrnl/config/ntapi.c | 8 ++++++++ reactos/ntoskrnl/include/internal/ke.h | 2 ++ reactos/ntoskrnl/ke/i386/kiinit.c | 7 +++++++ reactos/ntoskrnl/ps/process.c | 12 ++++++++++++ 4 files changed, 29 insertions(+) diff --git a/reactos/ntoskrnl/config/ntapi.c b/reactos/ntoskrnl/config/ntapi.c index 0d622696cef..deb21ad9f0b 100644 --- a/reactos/ntoskrnl/config/ntapi.c +++ b/reactos/ntoskrnl/config/ntapi.c @@ -890,6 +890,14 @@ NtInitializeRegistry(IN USHORT Flag) /* 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; diff --git a/reactos/ntoskrnl/include/internal/ke.h b/reactos/ntoskrnl/include/internal/ke.h index 8f70db9a369..e2e63172ec0 100644 --- a/reactos/ntoskrnl/include/internal/ke.h +++ b/reactos/ntoskrnl/include/internal/ke.h @@ -139,6 +139,8 @@ extern ULONG_PTR KiBugCheckData[5]; extern ULONG KiFreezeFlag; extern ULONG KiDPCTimeout; extern PGDI_BATCHFLUSH_ROUTINE KeGdiFlushUserBatch; +extern ULONGLONG BootCycles, BootCyclesEnd; +extern ULONG ProcessCount; /* MACROS *************************************************************************/ diff --git a/reactos/ntoskrnl/ke/i386/kiinit.c b/reactos/ntoskrnl/ke/i386/kiinit.c index 10e47627316..ea7f140ac39 100644 --- a/reactos/ntoskrnl/ke/i386/kiinit.c +++ b/reactos/ntoskrnl/ke/i386/kiinit.c @@ -25,6 +25,10 @@ ULONG_PTR KiDoubleFaultStack = (ULONG_PTR)&KiDoubleFaultStackData[KERNEL_STACK_S KSPIN_LOCK KiFreezeExecutionLock; KSPIN_LOCK Ki486CompatibilityLock; +/* Perf */ +ULONG ProcessCount; +ULONGLONG BootCycles, BootCyclesEnd; + /* FUNCTIONS *****************************************************************/ VOID @@ -683,6 +687,9 @@ KiSystemStartup(IN PLOADER_PARAMETER_BLOCK LoaderBlock) 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); diff --git a/reactos/ntoskrnl/ps/process.c b/reactos/ntoskrnl/ps/process.c index 2cc0c4f6ae2..5b904f2504e 100644 --- a/reactos/ntoskrnl/ps/process.c +++ b/reactos/ntoskrnl/ps/process.c @@ -843,6 +843,18 @@ PspCreateProcess(OUT PHANDLE ProcessHandle, /* 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: /*