Ticket #237 (new defect)
xcache_get() takes out write lock
| Reported by: | Aryeh Gregor | Owned by: | moo |
|---|---|---|---|
| Priority: | minor | Milestone: | 4.0.0 |
| Component: | cacher | Version: | 1.2.2 |
| Keywords: | Cc: | ||
| Blocked By: | PHP Version: | PHP 5.2.6-2ubuntu4.5 | |
| Application: | Need User Feedback: | no | |
| Other Exts: | SAPI: | Irrelevant | |
| Probability: | Always | Blocking: |
Description
If I try xcache_get()ing a very large array (assigning it to a variable causes PHP's memory usage to rise by ~50M), from a lot of different threads at once, performance drops like a stone. Debugger < http://poormansprofiler.org/> shows lots of processes stuck in xc_fcntl_lock().
If I serialize() the array to a string and store the string rather than an array, there are no locking problems that I notice even with lots of requests, but the xcache_get()+unserialize() of the string takes a lot longer (on a single thread) than xcache_get() of the array.
I looked at the source code and it seems that even xcache_get() is taking out write locks. Could it maybe be modified to take out read locks instead, so there's no lock contention? The variable is practically never changed, in my case. I imagine problems would arise if you were reading smaller variables often enough, too.
I asked on IRC and icy suggested I file a ticket.

