Re: caching questions

2003-07-23 Thread Peter Haworth
On Tue, 22 Jul 2003 13:05:00 +0300, Stas Bekman wrote:
> Peter Haworth wrote:
> > Cache::Mmap (which I wrote) isn't threadsafe, but should work OK in a
> > forking MPM. If anyone wants to contribute code to make it threadsafe
> > (preferably without impacting single-threaded performance too much),
> > I'll be very grateful. I'd do it myself, but I've never used threads, so
> > I'm bound to get it wrong.
>
> I haven't looked at the module's implementation, but if you have a C-level
> thread-safety issues, you may consider using libapr which provides a
> thread-safe mmap API.

No, it's perl-level stuff at the point that matters. Currently, it uses fine
grained file locking to prevent concurrent accesses from other processes,
but as far as I understand it, this won't prevent concurrent accesses from
other threads in the same process.

-- 
Peter Haworth   [EMAIL PROTECTED]
"Do you expect me to implement it?"
"No, Mister Schwern, I expect you to DIE!"
-- Michael G Schwern in p5p


Re: caching questions

2003-07-22 Thread Perrin Harkins
On Tue, 2003-07-22 at 02:13, Tom Schindl wrote:
> Sorry to step in here, but could I use any of the caching modules you
> mentionned in mod_perl2?

I can't vouch for the thread safety of these modules, but all of them
should work in prefork mode.

- Perrin


Re: caching questions

2003-07-22 Thread Stas Bekman
Peter Haworth wrote:
On 22 Jul 2003 08:13:43 +0200, Tom Schindl wrote:

Am Mon, 2003-07-21 um 21.45 schrieb Perrin Harkins:

On Sun, 2003-07-20 at 15:47, Patrick Galbraith wrote:

I know there's IPC, and also memcached. I've used IPC::Shareable
before, but don't know if that's the route I'd wanna go.
It's not. IPC::Shareable is very slow. If you want to share data, use
Cache::FileCache, Cache::Mmap, MLDBM::Sync, or IPC::MM.
Sorry to step in here, but could I use any of the caching modules you
mentionned in mod_perl2?


Cache::Mmap (which I wrote) isn't threadsafe, but should work OK in a
forking MPM. If anyone wants to contribute code to make it threadsafe
(preferably without impacting single-threaded performance too much), I'll be
very grateful. I'd do it myself, but I've never used threads, so I'm bound
to get it wrong.
I haven't looked at the module's implementation, but if you have a C-level 
thread-safety issues, you may consider using libapr which provides a 
thread-safe mmap API.

__
Stas BekmanJAm_pH --> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: caching questions

2003-07-22 Thread Peter Haworth
On 22 Jul 2003 08:13:43 +0200, Tom Schindl wrote:
> Am Mon, 2003-07-21 um 21.45 schrieb Perrin Harkins:
> > On Sun, 2003-07-20 at 15:47, Patrick Galbraith wrote:
> > > I know there's IPC, and also memcached. I've used IPC::Shareable
> > > before, but don't know if that's the route I'd wanna go.
> >
> > It's not. IPC::Shareable is very slow. If you want to share data, use
> > Cache::FileCache, Cache::Mmap, MLDBM::Sync, or IPC::MM.
>
> Sorry to step in here, but could I use any of the caching modules you
> mentionned in mod_perl2?

Cache::Mmap (which I wrote) isn't threadsafe, but should work OK in a
forking MPM. If anyone wants to contribute code to make it threadsafe
(preferably without impacting single-threaded performance too much), I'll be
very grateful. I'd do it myself, but I've never used threads, so I'm bound
to get it wrong.

-- 
Peter Haworth   [EMAIL PROTECTED]
"[That sentence] occupied the table running through the middle of the middle
room in a half-way house. It was so equidistant that it managed to find a patch
of gravitic stability, a Lagrange of Reason, within which it set up a giant
tubular space station of the type that NASA were hoping to build by 2010."
-- Ashley Pomeroy


Re: caching questions

2003-07-21 Thread Tom Schindl
Sorry to step in here, but could I use any of the caching modules you
mentionned in mod_perl2?

thx

tom

Am Mon, 2003-07-21 um 21.45 schrieb Perrin Harkins:
> On Sun, 2003-07-20 at 15:47, Patrick Galbraith wrote:
> > One thing that my code does is check to see if it's cache has been
> > updated to the db, which I wish I could really have some sort of cache
> > that's in one place in memory (as opposed to each child process).
> 
> Well, you can't, unless you use threads.
> 
> > I know there's IPC, and also memcached. I've used IPC::Shareable before,
> > but don't know if that's the route I'd wanna go.
> 
> It's not.  IPC::Shareable is very slow.  If you want to share data, use
> Cache::FileCache, Cache::Mmap, MLDBM::Sync, or IPC::MM.
> 
> > Has anyone implemented a good caching system that sets up a global cache
> > that you don't have to check constantly because you happen to have been
> > served out by a child that doesn't have the latest cache from DB? One
> > single memory object?
> 
> The systems I listed above all use a shared cache that will have the
> same data regardless of which process accesses it.
> 
> - Perrin
> 



Re: caching questions

2003-07-21 Thread Perrin Harkins
On Sun, 2003-07-20 at 15:47, Patrick Galbraith wrote:
> One thing that my code does is check to see if it's cache has been
> updated to the db, which I wish I could really have some sort of cache
> that's in one place in memory (as opposed to each child process).

Well, you can't, unless you use threads.

> I know there's IPC, and also memcached. I've used IPC::Shareable before,
> but don't know if that's the route I'd wanna go.

It's not.  IPC::Shareable is very slow.  If you want to share data, use
Cache::FileCache, Cache::Mmap, MLDBM::Sync, or IPC::MM.

> Has anyone implemented a good caching system that sets up a global cache
> that you don't have to check constantly because you happen to have been
> served out by a child that doesn't have the latest cache from DB? One
> single memory object?

The systems I listed above all use a shared cache that will have the
same data regardless of which process accesses it.

- Perrin


caching questions

2003-07-20 Thread Patrick Galbraith
Today I just looked at Apache::Session, and just realised I spent the
last couple weeks coding what it does, more or less. I'm not sure If I
should use what I wrote, or it.
One thing that my code does is check to see if it's cache has been
updated to the db, which I wish I could really have some sort of cache
that's in one place in memory (as opposed to each child process).
I know there's IPC, and also memcached. I've used IPC::Shareable before,
but don't know if that's the route I'd wanna go.
Has anyone implemented a good caching system that sets up a global cache
that you don't have to check constantly because you happen to have been
served out by a child that doesn't have the latest cache from DB? One
single memory object?
I hope what I'm asking makes sense ;)

thanks much...
--
--
Patrick Galbraith
Senior Software Developer
[EMAIL PROTECTED] [EMAIL PROTECTED]
[EMAIL PROTECTED]
206.719.2461