VirtualBox

Ignore:
Timestamp:
May 24, 2013 7:18:27 PM (12 years ago)
Author:
vboxsync
Message:

memcache.cpp: Optimization in the growth code. Drop strictness regarding no in-use entries on destruction.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/alloc/memcache.cpp

    r45903 r46257  
    123123    /** Head of the page list. */
    124124    PRTMEMCACHEPAGE             pPageHead;
     125    /** Poiner to the insertion point in the page list. */
     126    PRTMEMCACHEPAGE volatile   *ppPageNext;
    125127    /** Constructor callback. */
    126128    PFNMEMCACHECTOR             pfnCtor;
     
    210212                           && !pfnDtor;
    211213    pThis->pPageHead        = NULL;
     214    pThis->ppPageNext       = &pThis->pPageHead;
    212215    pThis->pfnCtor          = pfnCtor;
    213216    pThis->pfnDtor          = pfnDtor;
     
    245248    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
    246249    AssertReturn(pThis->u32Magic == RTMEMCACHE_MAGIC, VERR_INVALID_HANDLE);
    247 #ifdef RT_STRICT
     250
     251#if 0 /*def RT_STRICT - don't require eveything to be freed. Caches are very convenient for lazy cleanup. */
    248252    uint32_t cFree = pThis->cFree;
    249253    for (PRTMEMCACHEFREEOBJ pFree = pThis->pFreeTop; pFree && cFree < pThis->cTotal + 5; pFree = pFree->pNext)
     
    333337            ASMAtomicWritePtr(&pThis->pPageHint, pPage);
    334338
    335             /* Link the page. */
    336             PRTMEMCACHEPAGE pPrevPage = pThis->pPageHead;
    337             if (!pPrevPage)
    338                 ASMAtomicWritePtr(&pThis->pPageHead, pPage);
    339             else
    340             {
    341                 while (pPrevPage->pNext)
    342                     pPrevPage = pPrevPage->pNext;
    343                 ASMAtomicWritePtr(&pPrevPage->pNext, pPage);
    344             }
     339            /* Link the page in at the end of the list. */
     340            ASMAtomicWritePtr(pThis->ppPageNext, pPage);
     341            pThis->ppPageNext = &pPage->pNext;
    345342
    346343            /* Add it to the page counts. */
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