Re: What is the overhead of using windows messages?
- From: "Nick Schultz" <nick.schultz@xxxxxxxx>
- Date: Fri, 25 Jul 2008 11:53:39 -0700
It isn't exactly 100%, but hovers around 95%.
I think I am blocking because when I run stress tests on my system I get
pretty linear cpu usage as I simulate traffic on the bus:
when bus load is at ~75% (27902pks in 5s) I get cpu usage isa around 45%
when bus load is at ~50% (17439 pks in 5s) I get cpu usage of about 30%
when bus load is at ~25% (8720 pks in 5s) I get cpu usage of about 17%
each packet contains 8 bytes of data and there is some overhead for IDs and
such, probably another 3-4 bytes of data extra.
Note that this much CPU is being used just to respond to the messages that
CANLIB is sending, I then drop the packet since there aren't any clients
connected. So I'm not using WM_COPYDATA ,any IPC, or even queuing to my
client-handling threads.
Perhaps using a callback function will be more efficient?
From the CANLIB Documentation:"The callback function is called in the context of a high-priority thread
created by CANLIB"
So I'm assuming that I wouldn't be able to send any messages as that thread
will probably not be in the message loop, correct? So then I/O Completion
Port would make sense to handle my queuing.
Back to the drawing board I suppose... :-\
Nick
"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message
news:nc5k841023jk3bgbu9bk3eklm8h533h12q@xxxxxxxxxx
How many messages per second are you sending?
Note that WM_COPYDATA is a bit expensive because of the need to map the
data into the
receiving process; for small data packets, raw messages (for example,
packing 1-4 bytes
int he WPARAM) might be faster. If you are getting 100% utlilization, you
need to find
out why you are not blocking; it sounds like you are in a polling loop
somewhere.
I would choose an I/O Completion Port to handle the queuing; it is
probably faster than
most other schemes you could come up with.
Named pipes *might* be faster, but until you are prepared to do detailed
performance
measurement, you won't be able to tell.
joe
On Fri, 25 Jul 2008 09:42:31 -0700, "Nick Schultz" <nick.schultz@xxxxxxxx>
wrote:
After getting a running prototype of my packet sniffing app on aJoseph M. Newcomer [MVP]
production
machine, I have realized that I use the entire cpu under a 40% bus load.
I figured it must be because of all the messages being sent from the
CANLIB
driver to my application. It sends a notification message when the
receive
queue leaves its empty state. When no clients are connected, my apps then
simply drops the packets. This process itself takes 100% of cpu usage on
a
Celeron 3.0ghz. When a client connects, a new thread is created to
service
that client. the thread processesing incoming CAN packets then sends a
message to all the client threads with a pointer to the new packet. the
thread client then serializes the packet, and sends it off to its client
via
WM_COPYDATA.
However, with just the backend running (without any clients), my cpu is
already tapped. So I'm trying to find another way to get the job done.
In addition to sending window messages, the CANLIB driver allows
asynchronous notification by using a callback function. I suppose this
function can then place all the packets onto a queue which then can be
read
by the client threads. What would be an efficient way of notifing the
client thread that the queue is not empty? (ie no polling \ windows
messages)
second, what would be a faster IPC than using WM_COPYDATA? would using
named pipes be any faster?
Thanks,
Nick
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- Follow-Ups:
- Re: What is the overhead of using windows messages?
- From: Scott McPhillips [MVP]
- Re: What is the overhead of using windows messages?
- References:
- What is the overhead of using windows messages?
- From: Nick Schultz
- Re: What is the overhead of using windows messages?
- From: Joseph M . Newcomer
- What is the overhead of using windows messages?
- Prev by Date: Re: What is the overhead of using windows messages?
- Next by Date: error C2660: 'DrawFocusRect' : function does not take 4 parameters
- Previous by thread: Re: What is the overhead of using windows messages?
- Next by thread: Re: What is the overhead of using windows messages?
- Index(es):
Relevant Pages
|