bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What is the purpose of wdcache and wlcache?


From: Peng Yu
Subject: Re: What is the purpose of wdcache and wlcache?
Date: Fri, 8 Feb 2019 11:26:56 -0600

On Fri, Feb 8, 2019 at 10:50 AM Chet Ramey <chet.ramey@case.edu> wrote:
>
> On 2/8/19 10:52 AM, Peng Yu wrote:
> > On Fri, Feb 8, 2019 at 9:42 AM Chet Ramey <chet.ramey@case.edu> wrote:
> >>
> >> On 2/8/19 10:39 AM, Peng Yu wrote:
> >>>> Yes: ocache_free.
> >>>
> >>> Could you please help explain what wdcache and wlcache actually do.
> >>> Why is it essential to have them? Why not just alloc and free them
> >>> without the caches? Thanks.
> >>
> >> To avoid potentially-expensive calls to malloc and free, the same as
> >> any cache.
> >
> > There are already many mallocs and frees used in other places in the
> > program, why it is essential to use cache here. Is this decision based
> > on profiling or it is just based on some abstract concept but without
> > actual runtime data?
>
> It was based on profiling at the time I implemented it.
>
> >
> > Where are these parameters coming from?
> >
> > #define WDCACHESIZE 128
>
> That's a reasonable size for a cache, and it provided a nice balance
> between memory use and speed for the most common cases.
>
> > if ((nbytes) <= 32) {
>
> That's the byte threshold for this implementation of Duff's Device. If
> the object is larger than that, it's better to use memset, with whatever
> assist the compiler can give you.
>
> > I made the following test program. I don't understand why a longer
> > word "xyzabc" can still use the cache. What is actually stored in
> > "data"?
>
> Come on. If you're not going to read the code, at least read the comments.

This is what I don't understand. Why caching pointers not caching the
actual memory allocated to the string can improve the performance?

> /* Create an object cache C of N pointers to OTYPE. */
>
> /* Free all cached items, which are pointers to OTYPE, in object cache C. */

-- 
Regards,
Peng



reply via email to

[Prev in Thread] Current Thread [Next in Thread]