VirtualBox

Changeset 46199 in vbox for trunk/src


Ignore:
Timestamp:
May 21, 2013 7:49:19 PM (12 years ago)
Author:
vboxsync
Message:

strcache.cpp: Enabled it. Some tuning.

Location:
trunk/src/VBox/Runtime
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/Makefile.kmk

    r46162 r46199  
    419419        common/string/stringalloc.cpp \
    420420        common/string/strprintf.cpp \
     421        common/string/strcache.cpp \
    421422        common/string/strspace.cpp \
    422423        common/string/strstrip.cpp \
     
    489490        generic/semxroads-generic.cpp \
    490491        generic/spinlock-generic.cpp \
    491         generic/strcache-stubs-generic.cpp \
    492492        generic/timerlr-generic.cpp \
    493493        r3/alloc-ef.cpp \
  • trunk/src/VBox/Runtime/common/dbg/dbgmod.cpp

    r46165 r46199  
    757757#endif
    758758        default:
     759            rc = VERR_NOT_IMPLEMENTED;
    759760            break;
    760761    }
  • trunk/src/VBox/Runtime/common/dbg/dbgmodexports.cpp

    r46113 r46199  
    9797    }
    9898
     99    /* Add dummy segments for segments that doesn't get mapped. */
     100    if (pSeg->LinkAddress == NIL_RTLDRADDR)
     101        return RTDbgModSegmentAdd(pArgs->pDbgMod, 0, 0, pszName, 0 /*fFlags*/, NULL);
     102
    99103    RTLDRADDR cb = RT_MAX(pSeg->cb, pSeg->cbMapped);
    100104    return RTDbgModSegmentAdd(pArgs->pDbgMod, pSeg->RVA, cb, pszName, 0 /*fFlags*/, NULL);
  • trunk/src/VBox/Runtime/common/string/strcache.cpp

    r46198 r46199  
    7575 */
    7676#define RTSTRCACHE_MERGED_THRESHOLD_BIT     6
     77
     78
     79/** The number of bytes (power of two) that the merged allocation lists should
     80 * be grown by.  Must be much greater than RTSTRCACHE_MERGED_THRESHOLD. */
     81#define RTSTRCACHE_MERGED_GROW_SIZE         _32K
     82/** The number of bytes (power of two) that the fixed allocation lists should
     83 * be grown by. */
     84#define RTSTRCACHE_FIXED_GROW_SIZE          _32K
    7785
    7886/** Validates a string cache handle, translating RTSTRCACHE_DEFAULT when found,
     
    556564         * cases, but it's too much effort to write and execute).
    557565         */
    558         size_t const     cbChunk = RTSTRCACHE_HEAP_THRESHOLD * 16;  AssertReturn(cbChunk > cbEntry * 2, NULL);
     566        size_t const     cbChunk = RTSTRCACHE_MERGED_GROW_SIZE; AssertReturn(cbChunk > cbEntry * 2, NULL);
    559567        PRTSTRCACHECHUNK pChunk  = (PRTSTRCACHECHUNK)RTMemPageAlloc(cbChunk);
    560568        if (!pChunk)
     
    628636    if (!pFree)
    629637    {
    630         PRTSTRCACHECHUNK pChunk = (PRTSTRCACHECHUNK)RTMemPageAlloc(PAGE_SIZE);
     638        PRTSTRCACHECHUNK pChunk = (PRTSTRCACHECHUNK)RTMemPageAlloc(RTSTRCACHE_FIXED_GROW_SIZE);
    631639        if (!pChunk)
    632640            return NULL;
     
    762770        if (cbEntry >= RTSTRCACHE_MERGED_THRESHOLD_BIT)
    763771        {
    764             if (cbEntry < RTSTRCACHE_HEAP_THRESHOLD * 2)
     772            if (cbEntry <= RTSTRCACHE_HEAP_THRESHOLD)
    765773                pEntry = rtStrCacheAllocMergedEntry(pThis, uHash, pchString, cchString, cbEntry);
    766774            else
  • trunk/src/VBox/Runtime/testcase/tstRTStrCache.cpp

    r44529 r46199  
    8888        RTTESTI_CHECK(RTStrCacheRetain(psz) == 5);
    8989        RTTESTI_CHECK(RTStrCacheRetain(psz) == 6);
    90         RTTESTI_CHECK(RTStrCacheRelease(NIL_RTSTRCACHE, psz) == 5);
    91         RTTESTI_CHECK(RTStrCacheRelease(NIL_RTSTRCACHE, psz) == 4);
     90        RTTESTI_CHECK(RTStrCacheRelease(hStrCache, psz) == 5);
     91        RTTESTI_CHECK(RTStrCacheRelease(hStrCache, psz) == 4);
    9292        RTTESTI_CHECK_MSG_RETV((pv2 = ASMMemIsAll8(psz, i, 'a')) == NULL && !psz[i], ("i=%#x psz=%p off=%#x\n", i, psz, (uintptr_t)pv2 - (uintptr_t)psz));
    9393
     
    107107            }
    108108        }
     109    }
     110
     111    /* Lots of allocations. */
     112    memset(szTest, 'b', sizeof(szTest));
     113    memset(szTest2, 'e', sizeof(szTest));
     114    const char *pszTest1Rets[4096 + 16];
     115    const char *pszTest2Rets[4096 + 16];
     116    for (uint32_t i = 1; i < RT_ELEMENTS(pszTest1Rets); i++)
     117    {
     118        RTTESTI_CHECK(pszTest1Rets[i] = RTStrCacheEnterN(hStrCache, szTest, i));
     119        RTTESTI_CHECK(strlen(pszTest1Rets[i]) == i);
     120        RTTESTI_CHECK(pszTest2Rets[i] = RTStrCacheEnterN(hStrCache, szTest2, i));
     121        RTTESTI_CHECK(strlen(pszTest2Rets[i]) == i);
     122    }
     123
     124    for (uint32_t i = 1; i < RT_ELEMENTS(pszTest1Rets); i++)
     125    {
     126        uint32_t cRefs;
     127        RTTESTI_CHECK(strlen(pszTest1Rets[i]) == i);
     128        RTTESTI_CHECK_MSG((cRefs = RTStrCacheRelease(hStrCache, pszTest1Rets[i])) == 0, ("cRefs=%#x i=%#x\n", cRefs, i));
     129        RTTESTI_CHECK(strlen(pszTest2Rets[i]) == i);
     130        RTTESTI_CHECK_MSG((cRefs = RTStrCacheRelease(hStrCache, pszTest2Rets[i])) == 0, ("cRefs=%#x i=%#x\n", cRefs, i));
    109131    }
    110132}
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