Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Memory-resident message queue

Reply
Thread Tools

Memory-resident message queue

 
 
quigstah@gmail.com
Guest
Posts: n/a
 
      04-05-2006

From: - view profile
Date: Wed, Apr 5 2006 12:56 am
Email: "quigs...@gmail.com" <quigs...@gmail.com>
Groups: comp.unix.programmer
Not yet rated
Rating:
show options

Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Remove | Report Abuse | Find messages by this author

Hey Folks!

Here's the scenario: I'm trying to rapidly develop some C code that
interfaces with some embedded Python. I need custom message queues, to
pass data between the C and Python.

I'm looking for something more high-level than IPC shared memory.
Berkeley DB seems a very viable option, but I'm concerned that it can't
be kept completely memory resident (as I'm expecting millions of tiny
messages being passed back and forth, and I want to avoid high disk i/o
if possible).

The messages are to be strings of some (possibly dynamic) length. Some
metadata will have to be associated with each message, including a
unique integer id, and a few other minor things.

I've considered allocating a big block of memory and making some custom
API to it with an xml-rpc protocol. I'm much more inclined to use
something that is already out there, of course, especially since I'm
racing to get this code out the door. I also heard of Prevaylor
(Java-based prevalence layer), which is an interesting concept I hadn't
previously heard of.

Any thoughts or ideas? I'm open to anything, and I want to thank you
in advance for your time and consideration.

Regards,
John Quigley
https://chicagolug.org/~jquigley/

 
Reply With Quote
 
 
 
 
Nick Keighley
Guest
Posts: n/a
 
      04-05-2006
wrote:

<snip header stuff>

> Here's the scenario: I'm trying to rapidly develop some C code that
> interfaces with some embedded Python. I need custom message queues, to
> pass data between the C and Python.


this is really off-topic to comp.lang.c I've added comp.programming to
the groups posted to

> I'm looking for something more high-level than IPC shared memory.
> Berkeley DB seems a very viable option, but I'm concerned that it can't
> be kept completely memory resident (as I'm expecting millions of tiny
> messages being passed back and forth, and I want to avoid high disk i/o
> if possible).


how big can your queue get? If you are holding millions of entries in
the
queue it may get quite large.

> The messages are to be strings of some (possibly dynamic) length. Some
> metadata will have to be associated with each message, including a
> unique integer id, and a few other minor things.
>
> I've considered allocating a big block of memory and making some custom
> API to it with an xml-rpc protocol. I'm much more inclined to use
> something that is already out there, of course, especially since I'm
> racing to get this code out the door. I also heard of Prevaylor
> (Java-based prevalence layer), which is an interesting concept I hadn't
> previously heard of.
>
> Any thoughts or ideas? I'm open to anything, and I want to thank you
> in advance for your time and consideration.


I'm rather a fan of roll-your own. XML-RPC seems a bit heavy weight to
me
but I don't know your application. I'd be thinking linked list or
cyclic buffer
in IPC. The dynamic strings sound a bit messy (is there an upper limit)
but not totally undoable. I'm sure the XP will be telling you to write
a test.
I'd ignore the shared memory bit for the moment and implment a simple
queing
system. Presumably there are libraries out there to do this sort of
thing.
Google?

In the past I've used linked lists of blocks of memory. Reasonable
compromise
between flexibility and simple memory management.


--
Nick Keighley

 
Reply With Quote
 
 
 
 
Ben Pfaff
Guest
Posts: n/a
 
      04-05-2006
"" <> writes:

> Berkeley DB seems a very viable option, but I'm concerned that it can't
> be kept completely memory resident (as I'm expecting millions of tiny
> messages being passed back and forth, and I want to avoid high disk i/o
> if possible).


Berkeley DB has a memory-only mode.
--
"doe not call up Any that you can not put downe."
--H. P. Lovecraft
 
Reply With Quote
 
Joe Estock
Guest
Posts: n/a
 
      04-06-2006
Nick Keighley wrote:
> wrote:
>
> <snip header stuff>
>
>> Here's the scenario: I'm trying to rapidly develop some C code that
>> interfaces with some embedded Python. I need custom message queues, to
>> pass data between the C and Python.

>
> this is really off-topic to comp.lang.c I've added comp.programming to
> the groups posted to
>
>> I'm looking for something more high-level than IPC shared memory.
>> Berkeley DB seems a very viable option, but I'm concerned that it can't
>> be kept completely memory resident (as I'm expecting millions of tiny
>> messages being passed back and forth, and I want to avoid high disk i/o
>> if possible).

>
> how big can your queue get? If you are holding millions of entries in
> the
> queue it may get quite large.
>
>> The messages are to be strings of some (possibly dynamic) length. Some
>> metadata will have to be associated with each message, including a
>> unique integer id, and a few other minor things.
>>
>> I've considered allocating a big block of memory and making some custom
>> API to it with an xml-rpc protocol. I'm much more inclined to use
>> something that is already out there, of course, especially since I'm
>> racing to get this code out the door. I also heard of Prevaylor
>> (Java-based prevalence layer), which is an interesting concept I hadn't
>> previously heard of.
>>
>> Any thoughts or ideas? I'm open to anything, and I want to thank you
>> in advance for your time and consideration.

>


[snip]

>
> In the past I've used linked lists of blocks of memory. Reasonable
> compromise
> between flexibility and simple memory management.
>
>


I'd recommend a doubly-linked list for the simple fact that traversing
it would be a little less cpu-intensive than starting from the top of
the list and looping through untill you find the right entry. Since the
OP is using an integral type to uniquely identify the message you could
store them in sequential order from smallest to largest which would make
it faster to search through them.

Just my two cents worth.

Joe
 
Reply With Quote
 
Nick Keighley
Guest
Posts: n/a
 
      04-06-2006
Joe Estock wrote:
> Nick Keighley wrote:
> > wrote:


> >> Here's the scenario: I'm trying to rapidly develop some C code that
> >> interfaces with some embedded Python. I need custom message queues, to
> >> pass data between the C and Python.

> >
> > this is really off-topic to comp.lang.c I've added comp.programming to
> > the groups posted to
> >
> >> I'm looking for something more high-level than IPC shared memory.
> >> Berkeley DB seems a very viable option, but I'm concerned that it can't
> >> be kept completely memory resident (as I'm expecting millions of tiny
> >> messages being passed back and forth, and I want to avoid high disk i/o
> >> if possible).

> >
> > how big can your queue get? If you are holding millions of entries in
> > the queue it may get quite large.
> >
> >> The messages are to be strings of some (possibly dynamic) length. Some
> >> metadata will have to be associated with each message, including a
> >> unique integer id, and a few other minor things.
> >>
> >> I've considered allocating a big block of memory and making some custom
> >> API to it with an xml-rpc protocol. I'm much more inclined to use
> >> something that is already out there, of course, especially since I'm
> >> racing to get this code out the door. I also heard of Prevaylor
> >> (Java-based prevalence layer), which is an interesting concept I hadn't
> >> previously heard of.
> >>
> >> Any thoughts or ideas? I'm open to anything, and I want to thank you
> >> in advance for your time and consideration.

> >
> > In the past I've used linked lists of blocks of memory. Reasonable
> > compromise between flexibility and simple memory management.

>
> I'd recommend a doubly-linked list for the simple fact that traversing
> it would be a little less cpu-intensive than starting from the top of
> the list and looping through untill you find the right entry. Since the
> OP is using an integral type to uniquely identify the message you could
> store them in sequential order from smallest to largest which would make
> it faster to search through them.
>
> Just my two cents worth.


yes but if its a true FIFO queue he can simply add to the tail and
remove from
the head. Just two pointers and double linking doesn't do much for you.
In m experience it's more usual to process messages in order of arrival
unless there are some special priority messages. Processing in order of
msg type sounds... odd.


--
Nick Keighley

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Program blocked in Queue.Queue.get and Queue.Queue.put Kris Python 0 01-04-2012 03:46 PM
Is Queue.Queue.queue.clear() thread-safe? Russell Warren Python 4 06-27-2006 03:03 PM
Write message in windows message queue (msmq) Ikkezelf C Programming 5 05-02-2006 08:54 AM
what's the difference between #include "queue.h" and #include "queue.cpp" Kceiw C++ 3 03-14-2006 03:01 AM
Queue.Queue-like class without the busy-wait Paul L. Du Bois Python 29 04-04-2005 01:28 PM



Advertisments