VirtualBox

Changeset 2968 in kBuild


Ignore:
Timestamp:
Sep 26, 2016 6:14:50 PM (8 years ago)
Author:
bird
Message:

kWorker: KWORKER_STATS env var triggers statistics to be dumped on exit.

Location:
trunk/src/kWorker
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kWorker/Makefile.kmk

    r2948 r2968  
    7777       nt/ntunlink.c \
    7878       nt/kFsCache.c \
    79        quote_argv.c
     79       quote_argv.c \
     80        maybe_con_write.c \
     81        maybe_con_fwrite.c \
     82        msc_buffered_printf.c
    8083kbuild_version.c_DEFS = KBUILD_SVN_REV=$(KBUILD_SVN_REV)
    8184
  • trunk/src/kWorker/kWorker.c

    r2965 r2968  
    4444#include <ctype.h>
    4545#include <errno.h>
     46#include <process.h>
    4647
    4748#include "nt/ntstat.h"
     
    977978
    978979
     980/** Number of jobs executed. */
     981static KU32     g_cJobs;
     982/** Number of tools. */
     983static KU32     g_cTools;
     984/** Number of modules. */
     985static KU32     g_cModules;
     986/** Number of non-native modules. */
     987static KU32     g_cNonNativeModules;
     988
     989
     990
    979991/*********************************************************************************************************************************
    980992*   Internal Functions                                                                                                           *
     
    18181830        KW_LOG(("New module: %p LB %#010x %s (native)\n",
    18191831                (KUPTR)pMod->pLdrMod->aSegments[0].MapAddress, kLdrModSize(pMod->pLdrMod), pMod->pszPath));
     1832        g_cModules++;
    18201833        return kwLdrModuleLink(pMod);
    18211834    }
     
    21242137                                    pMod->u.Manual.pvBits = pMod->u.Manual.pbCopy;
    21252138                                    pMod->u.Manual.enmState = KWMODSTATE_NEEDS_BITS;
     2139                                    g_cModules++;
     2140                                    g_cNonNativeModules++;
    21262141                                    return pMod;
    21272142                                }
     
    28342849
    28352850        kFsCacheObjRelease(g_pFsCache, pToolFsObj);
     2851        g_cTools++;
    28362852        return pTool;
    28372853    }
     
    96979713    }
    96989714#endif
     9715    g_cJobs++;
    96999716
    97009717    /*
     
    1003710054
    1003810055/**
     10056 * Prints statistics.
     10057 */
     10058static void kwPrintStats(void)
     10059{
     10060    PROCESS_MEMORY_COUNTERS_EX MemInfo;
     10061    MEMORYSTATUSEX MemStatus;
     10062    IO_COUNTERS IoCounters;
     10063    DWORD cHandles;
     10064    KSIZE cMisses;
     10065    char  szBuf[16*1024];
     10066    int   off = 0;
     10067    char  szPrf[24];
     10068    extern size_t maybe_con_fwrite(void const *pvBuf, size_t cbUnit, size_t cUnits, FILE *pFile);
     10069
     10070    sprintf(szPrf, "%5d/%u:", getpid(), K_ARCH_BITS);
     10071
     10072    szBuf[off++] = '\n';
     10073
     10074    off += sprintf(&szBuf[off], "%s %10" KU32_PRI " jobs,  %" KU32_PRI" tools,  %" KU32_PRI " modules,  %" KU32_PRI" non-native ones\n",
     10075                   szPrf, g_cJobs, g_cTools, g_cModules, g_cNonNativeModules);
     10076
     10077    off += sprintf(&szBuf[off], "%s %10" KSIZE_PRI_U " bytes for the cache\n",
     10078                   szPrf, g_pFsCache->cbObjects + g_pFsCache->cbAnsiPaths + g_pFsCache->cbUtf16Paths + sizeof(*g_pFsCache));
     10079    off += sprintf(&szBuf[off], "%s %10" KSIZE_PRI_U " objects, taking up %" KSIZE_PRI_U " bytes, avg %" KSIZE_PRI_U " bytes\n",
     10080                   szPrf, g_pFsCache->cObjects, g_pFsCache->cbObjects,
     10081                   g_pFsCache->cbObjects / g_pFsCache->cObjects);
     10082    off += sprintf(&szBuf[off], "%s %10" KSIZE_PRI_U " A path hashes, taking up %" KSIZE_PRI_U " bytes, avg %" KSIZE_PRI_U " bytes, %" KSIZE_PRI_U " collision\n",
     10083                   szPrf, g_pFsCache->cAnsiPaths, g_pFsCache->cbAnsiPaths,
     10084                   g_pFsCache->cbAnsiPaths / K_MAX(g_pFsCache->cAnsiPaths, 1), g_pFsCache->cAnsiPathCollisions);
     10085#ifdef KFSCACHE_CFG_UTF16
     10086    off += sprintf(&szBuf[off], "%s %10" KSIZE_PRI_U " W path hashes, taking up %" KSIZE_PRI_U " bytes, avg %" KSIZE_PRI_U " bytes, %" KSIZE_PRI_U " collisions\n",
     10087                   szPrf, g_pFsCache->cUtf16Paths, g_pFsCache->cbUtf16Paths,
     10088                   g_pFsCache->cbUtf16Paths / K_MAX(g_pFsCache->cUtf16Paths, 1), g_pFsCache->cUtf16PathCollisions);
     10089#endif
     10090    off += sprintf(&szBuf[off], "%s %10" KSIZE_PRI_U " child hash tables, total of %" KSIZE_PRI_U " entries, %" KSIZE_PRI_U " children inserted, %" KSIZE_PRI_U " collisions\n",
     10091                   szPrf, g_pFsCache->cChildHashTabs, g_pFsCache->cChildHashEntriesTotal,
     10092                   g_pFsCache->cChildHashed, g_pFsCache->cChildHashCollisions);
     10093
     10094    cMisses = g_pFsCache->cLookups - g_pFsCache->cPathHashHits - g_pFsCache->cWalkHits;
     10095    off += sprintf(&szBuf[off], "%s %10" KSIZE_PRI_U " lookups: %" KSIZE_PRI_U " (%" KU64_PRI " %%) path hash hits, %" KSIZE_PRI_U " (%" KU64_PRI "%%) walks hits, %" KSIZE_PRI_U " (%" KU64_PRI "%%) misses\n",
     10096                   szPrf, g_pFsCache->cLookups,
     10097                   g_pFsCache->cPathHashHits, g_pFsCache->cPathHashHits * (KU64)100 / K_MAX(g_pFsCache->cLookups, 1),
     10098                   g_pFsCache->cWalkHits, g_pFsCache->cWalkHits * (KU64)100 / K_MAX(g_pFsCache->cLookups, 1),
     10099                   cMisses, cMisses * (KU64)100 / K_MAX(g_pFsCache->cLookups, 1));
     10100    off += sprintf(&szBuf[off], "%s %10" KSIZE_PRI_U " child searches, %" KSIZE_PRI_U " (%" KU64_PRI "%%) hash hits\n",
     10101                   szPrf, g_pFsCache->cChildSearches,
     10102                   g_pFsCache->cChildHashHits, g_pFsCache->cChildHashHits * (KU64)100 / K_MAX(g_pFsCache->cChildSearches, 1));
     10103    off += sprintf(&szBuf[off], "%s %10" KSIZE_PRI_U " name changes, growing %" KSIZE_PRI_U " times (%" KU64_PRI "%%)\n",
     10104                   szPrf, g_pFsCache->cNameChanges, g_pFsCache->cNameGrowths,
     10105                   g_pFsCache->cNameGrowths * 100 / K_MAX(g_pFsCache->cNameChanges, 1) );
     10106
     10107
     10108    /*
     10109     * Process & Memory details.
     10110     */
     10111    if (!GetProcessHandleCount(GetCurrentProcess(), &cHandles))
     10112        cHandles = 0;
     10113    MemInfo.cb = sizeof(MemInfo);
     10114    if (!GetProcessMemoryInfo(GetCurrentProcess(), (PPROCESS_MEMORY_COUNTERS)&MemInfo, sizeof(MemInfo)))
     10115        memset(&MemInfo, 0, sizeof(MemInfo));
     10116    off += sprintf(&szBuf[off], "%s %10" KU32_PRI " handles; %" KU32_PRI " page faults; %" KSIZE_PRI_U " bytes page file, peaking at %" KSIZE_PRI_U " bytes\n",
     10117                   szPrf, cHandles, MemInfo.PageFaultCount, MemInfo.PagefileUsage, MemInfo.PeakPagefileUsage);
     10118    off += sprintf(&szBuf[off], "%s %10" KSIZE_PRI_U " bytes working set, peaking at %" KSIZE_PRI_U " bytes; %" KSIZE_PRI_U " byte private\n",
     10119                   szPrf, MemInfo.WorkingSetSize, MemInfo.PeakWorkingSetSize, MemInfo.PrivateUsage);
     10120    off += sprintf(&szBuf[off], "%s %10" KSIZE_PRI_U " bytes non-paged pool, peaking at %" KSIZE_PRI_U " bytes; %7" KSIZE_PRI_U " bytes paged pool, peaking at %" KSIZE_PRI_U " bytes\n",
     10121                   szPrf, MemInfo.QuotaNonPagedPoolUsage, MemInfo.QuotaPeakNonPagedPoolUsage,
     10122                   MemInfo.QuotaPagedPoolUsage, MemInfo.QuotaPeakPagedPoolUsage);
     10123
     10124    if (!GetProcessIoCounters(GetCurrentProcess(), &IoCounters))
     10125        memset(&IoCounters, 0, sizeof(IoCounters));
     10126    off += sprintf(&szBuf[off], "%s %10" KU64_PRI " bytes in %" KU64_PRI " reads\n",
     10127                   szPrf, IoCounters.ReadTransferCount, IoCounters.ReadOperationCount);
     10128    off += sprintf(&szBuf[off], "%s %10" KU64_PRI " bytes in %" KU64_PRI " writes\n",
     10129                   szPrf, IoCounters.WriteTransferCount, IoCounters.WriteOperationCount);
     10130    off += sprintf(&szBuf[off], "%s %10" KU64_PRI " bytes in %" KU64_PRI " other I/O operations\n",
     10131                   szPrf, IoCounters.OtherTransferCount, IoCounters.OtherOperationCount);
     10132
     10133    MemStatus.dwLength = sizeof(MemStatus);
     10134    if (!GlobalMemoryStatusEx(&MemStatus))
     10135        memset(&MemStatus, 0, sizeof(MemStatus));
     10136    off += sprintf(&szBuf[off], "%s %10" KU64_PRI " bytes used VA, %#" KX64_PRI " bytes available\n", szPrf,
     10137                   MemStatus.ullTotalVirtual - MemStatus.ullAvailVirtual, MemStatus.ullAvailVirtual);
     10138    off += sprintf(&szBuf[off], "%s %9u%% system memory load\n", szPrf, MemStatus.dwMemoryLoad);
     10139
     10140    maybe_con_fwrite(szBuf, off, 1, stdout);
     10141    fflush(stdout);
     10142}
     10143
     10144
     10145/**
    1003910146 * Handles what comes after --test.
    1004010147 *
     
    1013610243        kwSandboxCleanupLate(&g_Sandbox);
    1013710244    }
     10245
     10246    if (getenv("KWORKER_STATS") != NULL)
     10247        kwPrintStats();
    1013810248
    1013910249# ifdef WITH_LOG_FILE
     
    1043610546            CloseHandle(g_hLogFile);
    1043710547#endif
     10548        if (getenv("KWORKER_STATS") != NULL)
     10549            kwPrintStats();
    1043810550        return rc > 0 ? 0 : 1;
    1043910551    }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette