Re: apc improvements
| From: | Gonzalo Arana | Date: | Fri, 10 Jun 2005 22:22:39 +0000 |
| Subject: | Re: apc improvements | ||
| References: | 1 2 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-2457@lists.php.net to get a copy of this message | ||
On Fri, Jun 10, 2005 at 02:03:21PM -0700, Rasmus Lerdorf wrote:
>
>
> Gonzalo Arana wrote:
> > Hi,
> >
> > ...<snip>...
> >
> > In my opinion, apc needs a read-write/read-only locking strategy to
> > boost performance. With this implemented, in case of a hit to apc's
> > ...<snip>...
> > hit to apc's cache), the running process would get scheduled.
> >
> > I would like to work on this. Does a feature like this have any chance
> > to get into apc's official source code?
>
> But there is a write on every hit for counters and the last accessed
> timestamp so I am not sure where a read-only lock would be applied.
Say, for instance, in apc_cache_find:
lock_ro(cache);
slot = &cache->slots[hash(key) % cache->num_slots];
while (*slot) {
if (key_equals((*slot)->key, key)) {
<<< mtime check >>>>
mutex_on();
(*slot)->num_hits++;
(*slot)->value->ref_count++;
prevent_garbage_collection((*slot)->value);
cache->header->num_hits++;
mutex_off();
unlock_ro(cache);
return (*slot)->value;
}
slot = &(*slot)->next;
}
mutex_on();
cache->header->num_misses++;
mutex_off();
unlock(cache);
(This is preliminary code)
>
> -Rasmus
>