[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: What is the purpose of wdcache and wlcache?
From: |
Chet Ramey |
Subject: |
Re: What is the purpose of wdcache and wlcache? |
Date: |
Fri, 8 Feb 2019 11:49:59 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 |
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.
/* Create an object cache C of N pointers to OTYPE. */
/* Free all cached items, which are pointers to OTYPE, in object cache C. */
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/
- What is the purpose of wdcache and wlcache?, Peng Yu, 2019/02/07
- Re: What is the purpose of wdcache and wlcache?, Chet Ramey, 2019/02/08
- Re: What is the purpose of wdcache and wlcache?, Peng Yu, 2019/02/08
- Re: What is the purpose of wdcache and wlcache?, Chet Ramey, 2019/02/08
- Re: What is the purpose of wdcache and wlcache?, Peng Yu, 2019/02/08
- Re: What is the purpose of wdcache and wlcache?,
Chet Ramey <=
- Re: What is the purpose of wdcache and wlcache?, Peng Yu, 2019/02/08
- Re: What is the purpose of wdcache and wlcache?, Eric Blake, 2019/02/08
- Re: What is the purpose of wdcache and wlcache?, Chet Ramey, 2019/02/08