VirtualBox

Changeset 2948 in kBuild


Ignore:
Timestamp:
Sep 20, 2016 3:36:07 PM (8 years ago)
Author:
bird
Message:

kWorker/kDep: save a few header stat calls while optimizing dependencies.

Location:
trunk/src
Files:
5 edited

Legend:

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

    r2938 r2948  
    3131PROGRAMS += kWorker
    3232kWorker_TEMPLATE = BIN-STATIC-THREADED
     33kWorker_DEFS := KWORKER
    3334kWorker_DEFS.debug = K_STRICT
    3435kWorker_DEFS.release = NASSERT
     
    6061kWorkerLib_DEFPATH = ../lib # Need fix from r2837.
    6162kWorkerLib_DEFPATH := $(PATH_SUB_CURRENT)/../lib
     63kWorkerLib_DEFS := KWORKER
    6264kWorkerLib_SOURCES = \
    6365        crc32.c \
  • trunk/src/kWorker/kWorker.c

    r2946 r2948  
    4747#include "nt/ntstat.h"
    4848#include "kbuild_version.h"
    49 /* lib/nt_fullpath.c */
    50 extern void nt_fullpath(const char *pszPath, char *pszFull, size_t cchFull);
    5149
    5250#include "nt/ntstuff.h"
     
    5452
    5553#include "nt/kFsCache.h"
     54#include "nt_fullpath.h"
    5655#include "quote_argv.h"
    5756#include "md5.h"
     
    28002799 */
    28012800
     2801
     2802/**
     2803 * This is for kDep.
     2804 */
     2805int kwFsPathExists(const char *pszPath)
     2806{
     2807    BirdTimeSpec_T  TsIgnored;
     2808    KFSLOOKUPERROR  enmError;
     2809    PKFSOBJ         pFsObj = kFsCacheLookupNoMissingA(g_pFsCache, pszPath, &enmError);
     2810    if (pFsObj)
     2811    {
     2812        kFsCacheObjRelease(g_pFsCache, pFsObj);
     2813        return 1;
     2814    }
     2815    return birdStatModTimeOnly(pszPath, &TsIgnored, 1) == 0;
     2816}
     2817
     2818
     2819/* duplicated in dir-nt-bird.c */
     2820void nt_fullpath_cached(const char *pszPath, char *pszFull, size_t cbFull)
     2821{
     2822    KFSLOOKUPERROR  enmError;
     2823    PKFSOBJ         pPathObj = kFsCacheLookupA(g_pFsCache, pszPath, &enmError);
     2824    if (pPathObj)
     2825    {
     2826        KSIZE off = pPathObj->cchParent;
     2827        if (off > 0)
     2828        {
     2829            KSIZE offEnd = off + pPathObj->cchName;
     2830            if (offEnd < cbFull)
     2831            {
     2832                PKFSDIR pAncestor;
     2833
     2834                pszFull[off + pPathObj->cchName] = '\0';
     2835                memcpy(&pszFull[off], pPathObj->pszName, pPathObj->cchName);
     2836
     2837                for (pAncestor = pPathObj->pParent; off > 0; pAncestor = pAncestor->Obj.pParent)
     2838                {
     2839                    kHlpAssert(off > 1);
     2840                    kHlpAssert(pAncestor != NULL);
     2841                    kHlpAssert(pAncestor->Obj.cchName > 0);
     2842                    pszFull[--off] = '/';
     2843                    off -= pAncestor->Obj.cchName;
     2844                    kHlpAssert(pAncestor->Obj.cchParent == off);
     2845                    memcpy(&pszFull[off], pAncestor->Obj.pszName, pAncestor->Obj.cchName);
     2846                }
     2847                kFsCacheObjRelease(g_pFsCache, pPathObj);
     2848                return;
     2849            }
     2850        }
     2851        else
     2852        {
     2853            if ((size_t)pPathObj->cchName + 1 < cbFull)
     2854            {
     2855                memcpy(pszFull, pPathObj->pszName, pPathObj->cchName);
     2856                pszFull[pPathObj->cchName] = '/';
     2857                pszFull[pPathObj->cchName + 1] = '\0';
     2858
     2859                kFsCacheObjRelease(g_pFsCache, pPathObj);
     2860                return;
     2861            }
     2862        }
     2863
     2864        /* do fallback. */
     2865        kHlpAssertFailed();
     2866        kFsCacheObjRelease(g_pFsCache, pPathObj);
     2867    }
     2868
     2869    nt_fullpath(pszPath, pszFull, cbFull);
     2870}
    28022871
    28032872
  • trunk/src/kmk/dir-nt-bird.c

    r2931 r2948  
    456456
    457457
    458 
     458/* duplicated in kWorker.c */
    459459void nt_fullpath_cached(const char *pszPath, char *pszFull, size_t cbFull)
    460460{
     
    478478                    kHlpAssert(off > 1);
    479479                    kHlpAssert(pAncestor != NULL);
    480                     kHlpAssert(pAncestor->ObjcchName > 0);
     480                    kHlpAssert(pAncestor->Obj.cchName > 0);
    481481                    pszFull[--off] = '/';
    482482                    off -= pAncestor->Obj.cchName;
  • trunk/src/lib/kDep.c

    r2886 r2948  
    5959#include "kDep.h"
    6060
     61#ifdef KWORKER
     62extern int kwFsPathExists(const char *pszPath);
     63#endif
     64
    6165
    6266/*******************************************************************************
     
    239243         * Check that the file exists before we start depending on it.
    240244         */
    241 #ifdef KMK
     245#ifdef KWORKER
     246        if (kwFsPathExists(pszFilename))
     247#elif defined(KMK)
    242248        if (!file_exists_p(pszFilename))
    243249#elif K_OS == K_OS_WINDOWS
  • trunk/src/lib/nt/kFsCache.c

    r2944 r2948  
    8989
    9090
     91
     92/*********************************************************************************************************************************
     93*   Internal Functions                                                                                                           *
     94*********************************************************************************************************************************/
     95static KBOOL kFsCacheRefreshObj(PKFSCACHE pCache, PKFSOBJ pObj, KFSLOOKUPERROR *penmError);
    9196
    9297
     
    12571262    else if (pDir->fPopulated)
    12581263    {
    1259         KU32  cAllocated = K_ALIGN_Z(pDir->cChildren, 16);
    1260         void *pvNew      = kHlpAlloc(sizeof(pDir->papChildren[0]) * cAllocated);
     1264        KU32  cAllocated;
     1265        void *pvNew;
     1266
     1267        /* Make sure we really need to do this first. */
     1268        if (!pDir->fNeedRePopulating)
     1269        {
     1270            if (   pDir->Obj.uCacheGen == KFSOBJ_CACHE_GEN_IGNORE
     1271                || pDir->Obj.uCacheGen == pCache->auGenerations[pDir->Obj.fFlags & KFSOBJ_F_USE_CUSTOM_GEN])
     1272                return K_TRUE;
     1273            if (   kFsCacheRefreshObj(pCache, &pDir->Obj, penmError)
     1274                && !pDir->fNeedRePopulating)
     1275                return K_TRUE;
     1276        }
     1277
     1278        /* Yes we do need to. */
     1279        cAllocated = K_ALIGN_Z(pDir->cChildren, 16);
     1280        pvNew      = kHlpAlloc(sizeof(pDir->papChildren[0]) * cAllocated);
    12611281        if (pvNew)
    12621282        {
     
    16081628        && (pDir->Obj.fFlags & KFSOBJ_F_WORKING_DIR_MTIME) )
    16091629    {
    1610         MY_IO_STATUS_BLOCK          Ios;
    1611         MY_FILE_BASIC_INFORMATION   BasicInfo;
    1612         MY_NTSTATUS                 rcNt;
    1613 
    1614         Ios.Information = -1;
    1615         Ios.u.Status    = -1;
    1616 
    1617         rcNt = g_pfnNtQueryInformationFile(pDir->hDir, &Ios, &BasicInfo, sizeof(BasicInfo), MyFileBasicInformation);
    1618         if (MY_NT_SUCCESS(rcNt))
    1619             return BasicInfo.LastWriteTime.QuadPart != pDir->iLastWrite;
     1630        if (!pDir->fNeedRePopulating)
     1631        {
     1632            MY_IO_STATUS_BLOCK          Ios;
     1633            MY_FILE_BASIC_INFORMATION   BasicInfo;
     1634            MY_NTSTATUS                 rcNt;
     1635
     1636            Ios.Information = -1;
     1637            Ios.u.Status    = -1;
     1638
     1639            rcNt = g_pfnNtQueryInformationFile(pDir->hDir, &Ios, &BasicInfo, sizeof(BasicInfo), MyFileBasicInformation);
     1640            if (MY_NT_SUCCESS(rcNt))
     1641            {
     1642                if (BasicInfo.LastWriteTime.QuadPart != pDir->iLastWrite)
     1643                {
     1644                    pDir->fNeedRePopulating = K_TRUE;
     1645                    return K_TRUE;
     1646                }
     1647                return K_FALSE;
     1648            }
     1649        }
    16201650    }
    16211651    /* The cache root never changes. */
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