Re: Shared memory and memory context question

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: Shared memory and memory context question
Дата
Msg-id 20060205144356.GB27019@svana.org
обсуждение исходный текст
Ответ на Re: Shared memory and memory context question  (Richard Hills <richard@playford.net>)
Ответы Re: Shared memory and memory context question  (richard@playford.net)
Re: Shared memory and memory context question  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Sun, Feb 05, 2006 at 02:31:23PM +0000, Richard Hills wrote:
> I have a number of functions which modify tables based on complex rules stored
> in script-files. I wrote a parser for these files as a separate program first
> before incorporating it as a shared object, subsequentially it loads and
> executes rules from memory. As anything can be read from the files, and rules
> can be unloaded later, I was hoping for flexibility in allocing memory to
> store it all.

So what you load are the already processed rules? In that case you
could probably use the buffer management system. Ask it to load the
blocks and they'll be in the buffer cache. As long as you have the
buffer pinned they'll stay there. That's pretty much a read-only
approach.

If you're talking about things that don't come from disk, well, hmm...
If you want you could use a file on disk as backing and mmap() it into
each processes address space...

> Another option is to load the files but store the rules within the database,
> which should be possible, but appears to be a slightly messy way of doing it.
> Then again, messing about with shared memory allocation may be messier.
> Asking as an fairly inexperienced postgres person, what would you suggest?

The real question is, does it need to be shared-writable.
Shared-readonly is much easier (ie one writer, multiple readers). Using
a file as backing store for mmap() may be the easiest....

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Richard Hills
Дата:
Сообщение: Re: Shared memory and memory context question
Следующее
От: richard@playford.net
Дата:
Сообщение: Re: Shared memory and memory context question