You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by umohank <um...@gmail.com> on 2020/09/23 12:03:39 UTC
C++ QPID Messaging : CPU high issue
Hi,
Client : C++ QPID Messaging
Broker : ActiveMQ Artemis
I am facing CPU high issue.
Creating temp queue and waiting for the message in recevier.fetch() call.
Getting CPU *20+% in release built 32bit* for the below code.
try {
connection.open();
Session session = connection.createTransactionalSession();
Receiver receiver = session.createReceiver("Temp");
char szControlPlane[512] = { 0x00 };
receiver.setCapacity(512);
session.sync();
while (true)
{
Message request;
if (receiver.fetch(request, Duration::SECOND * 5))
{
}
}
}
Is there any think I am missing OR waiting for message in receiver.fetch
taking more CPU?
Thanks,
mohan
--
Sent from: http://qpid.2158936.n2.nabble.com/Apache-Qpid-users-f2158936.html
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: C++ QPID Messaging : CPU high issue
Posted by umohank <um...@gmail.com>.
Yes, I am running the client on windows.
Thanks,
Mohan
--
Sent from: http://qpid.2158936.n2.nabble.com/Apache-Qpid-users-f2158936.html
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: C++ QPID Messaging : CPU high issue
Posted by Gordon Sim <gs...@redhat.com>.
On 24/09/2020 7:29 pm, umohank wrote:
> Hi Gordon,
>
> I have tried Fetch API with Duration and without duration.
>
> Without passing timeout duration:
> if (receiver.fetch(request))
> CPU is high, myclient_FetchWithoutDuration_CPUHigh.out
> <http://qpid.2158936.n2.nabble.com/file/t396516/myclient_FetchWithoutDuration_CPUHigh.out>
>
> With setting timeout duration:
> if (receiver.fetch(request, Duration::SECOND * 1))
> No CPU high issue, myclient_FetchWithDuration_NoCPUIssue.out
> <http://qpid.2158936.n2.nabble.com/file/t396516/myclient_FetchWithDuration_NoCPUIssue.out>
>
> any reason why?
Interesting. It would seem that on windows (on your build/platform at
least), the use of Duration::FOREVER is causing a problem with the wait
mechanism.
I don't use windows I'm afraid so I can't determine why that might be
exactly. Looking at the code it uses boost for both the time and
condition implementation on windows. (Specifically in the
Duration::FOREVER case it looks lie it creates a boost_posix_time::ptime
from boost::posix_time::max_date_time then passes that to
boost::condition_variable_any::timed_wait() which it would seem is
returning immediately in your case).
> does C++ QPID Messaging support event driven mechanism?
Not sure what you mean. It does not have a way to specify a callback to
which messages are dispatched if that is what you mean. (However such a
dispatcher is simple to write yourself by fetching messages from one or
more receivers and passing them to the callbacks you want).
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: C++ QPID Messaging : CPU high issue
Posted by umohank <um...@gmail.com>.
Hi Gordon,
I have tried Fetch API with Duration and without duration.
Without passing timeout duration:
if (receiver.fetch(request))
CPU is high, myclient_FetchWithoutDuration_CPUHigh.out
<http://qpid.2158936.n2.nabble.com/file/t396516/myclient_FetchWithoutDuration_CPUHigh.out>
With setting timeout duration:
if (receiver.fetch(request, Duration::SECOND * 1))
No CPU high issue, myclient_FetchWithDuration_NoCPUIssue.out
<http://qpid.2158936.n2.nabble.com/file/t396516/myclient_FetchWithDuration_NoCPUIssue.out>
any reason why?
does C++ QPID Messaging support event driven mechanism?
thanks,
Mohan
--
Sent from: http://qpid.2158936.n2.nabble.com/Apache-Qpid-users-f2158936.html
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: C++ QPID Messaging : CPU high issue
Posted by Gordon Sim <gs...@redhat.com>.
On 24/09/2020 7:48 am, umohank wrote:
> Enabled only trace+ log.
> In a second "ConnectionContext::get(), current=0000000000000000" call
> triggered 2500+ times
> Find the attached trace myclient.out
> <http://qpid.2158936.n2.nabble.com/file/t396516/myclient.out>
It looks as though the Condition::wait() implementation is not working
as expected on your platform. Are you running the client on windows?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: C++ QPID Messaging : CPU high issue
Posted by Gordon Sim <gs...@redhat.com>.
On 24/09/2020 7:48 am, umohank wrote:
> Enabled only trace+ log.
> In a second "ConnectionContext::get(), current=0000000000000000" call
> triggered 2500+ times
> Find the attached trace myclient.out
> <http://qpid.2158936.n2.nabble.com/file/t396516/myclient.out>
>
> Code snippet which I am trying( taken from QPID sample server.cpp )
>
> Connection connection(url, connectionOptions);
> try {
> connection.open();
> Session session = connection.createSession();
> Receiver receiver = session.createReceiver("service_queue; {create:
> always}");
>
> while (true) {
> Message request = receiver.fetch();
> const Address& address = request.getReplyTo();
>
> }
> connection.close();
> return 0;
> }
> catch (const std::exception& error) {
> std::cout << error.what() << std::endl;
> connection.close();
> }
I should qualify my answer a little. The code above is *not* what is
running for the recorded trace.
The trace shows a sender created for 'my_queue' and a receiver on a
dynamic (i.e. temp queue). The sender sends a messages to my_queue which
is accepted. It looks like the receiver is trying to fetch a message
concurrently with that send. If it is a fetch(), then it does look as
though the wait behaviour is not working for your build on your platform.
The trace would also be consistent with a loop on Receiver::get() where
the capacity is set to 1 however, in which case it would be expected.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: C++ QPID Messaging : CPU high issue
Posted by umohank <um...@gmail.com>.
Enabled only trace+ log.
In a second "ConnectionContext::get(), current=0000000000000000" call
triggered 2500+ times
Find the attached trace myclient.out
<http://qpid.2158936.n2.nabble.com/file/t396516/myclient.out>
Code snippet which I am trying( taken from QPID sample server.cpp )
Connection connection(url, connectionOptions);
try {
connection.open();
Session session = connection.createSession();
Receiver receiver = session.createReceiver("service_queue; {create:
always}");
while (true) {
Message request = receiver.fetch();
const Address& address = request.getReplyTo();
}
connection.close();
return 0;
}
catch (const std::exception& error) {
std::cout << error.what() << std::endl;
connection.close();
}
Thanks,
Mohan
--
Sent from: http://qpid.2158936.n2.nabble.com/Apache-Qpid-users-f2158936.html
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: C++ QPID Messaging : CPU high issue
Posted by Gordon Sim <gs...@redhat.com>.
On 23/09/2020 7:21 pm, umohank wrote:
> I have also tried with the server.cpp
> <https://qpid.apache.org/releases/qpid-cpp-1.39.0/messaging-api/cpp/examples/server.cpp.html>
> sample application
>
> For this also I am getting high CPU, and there is no data to consume, server
> waits for the data to consume.
If you set QPID_LOG_ENABLE=trace+ (i.e. not just the protocol
interactions), what do you see?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: C++ QPID Messaging : CPU high issue
Posted by umohank <um...@gmail.com>.
I have also tried with the server.cpp
<https://qpid.apache.org/releases/qpid-cpp-1.39.0/messaging-api/cpp/examples/server.cpp.html>
sample application
For this also I am getting high CPU, and there is no data to consume, server
waits for the data to consume.
Thanks,
Mohan
--
Sent from: http://qpid.2158936.n2.nabble.com/Apache-Qpid-users-f2158936.html
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: C++ QPID Messaging : CPU high issue
Posted by Ted Ross <tr...@redhat.com>.
Another thing to try is to replace "fetch" with "get". Since you have set
the capacity of the receiver, you don't need fetch to actively poll the
server.
On Wed, Sep 23, 2020 at 10:29 AM Gordon Sim <gs...@redhat.com> wrote:
> On 23/09/2020 3:13 pm, umohank wrote:
> > receiver.fetch() waits infinitely if there is no duration mentioned .
> > As I have mentioned 5 seconds, It wait for 5 seconds and come out if no
> > message in Queue.
> >
> > Note : I am getting CPU high even if there is not message in queue to
> > consume.
> > I have tried receiver.fetch with abnd without duration, in both
> > case I am getting CPU high.
>
> Get a protocol trace (set env var QPID_LOG_ENABLE=trace=+Protocol) and
> get a pstack thread dump for the client process. That might give you
> more information.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
>
>
Re: C++ QPID Messaging : CPU high issue
Posted by Gordon Sim <gs...@redhat.com>.
On 23/09/2020 7:06 pm, umohank wrote:
> Hi Gordon,
>
> I have tried with both fetch and get API.
> In both case getting same result.
>
> <http://qpid.2158936.n2.nabble.com/file/t396516/Capture.jpg>
> myclient_fetch_api.out
> <http://qpid.2158936.n2.nabble.com/file/t396516/myclient_fetch_api.out>
> myclient_get_api.out
> <http://qpid.2158936.n2.nabble.com/file/t396516/myclient_get_api.out>
>
> I have attached trace for both.
The fetch trace doesn't look like it matches your code. It does one
fetch only (if it did more we should see it flushing and reissuing
credit every 5 seconds).
I would look at a thread dump of your program and see what the threads
in it are doing.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: C++ QPID Messaging : CPU high issue
Posted by umohank <um...@gmail.com>.
Hi Gordon,
I have tried with both fetch and get API.
In both case getting same result.
<http://qpid.2158936.n2.nabble.com/file/t396516/Capture.jpg>
myclient_fetch_api.out
<http://qpid.2158936.n2.nabble.com/file/t396516/myclient_fetch_api.out>
myclient_get_api.out
<http://qpid.2158936.n2.nabble.com/file/t396516/myclient_get_api.out>
I have attached trace for both.
Thanks,
Mohan
--
Sent from: http://qpid.2158936.n2.nabble.com/Apache-Qpid-users-f2158936.html
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: C++ QPID Messaging : CPU high issue
Posted by Gordon Sim <gs...@redhat.com>.
On 23/09/2020 3:13 pm, umohank wrote:
> receiver.fetch() waits infinitely if there is no duration mentioned .
> As I have mentioned 5 seconds, It wait for 5 seconds and come out if no
> message in Queue.
>
> Note : I am getting CPU high even if there is not message in queue to
> consume.
> I have tried receiver.fetch with abnd without duration, in both
> case I am getting CPU high.
Get a protocol trace (set env var QPID_LOG_ENABLE=trace=+Protocol) and
get a pstack thread dump for the client process. That might give you
more information.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: C++ QPID Messaging : CPU high issue
Posted by umohank <um...@gmail.com>.
receiver.fetch() waits infinitely if there is no duration mentioned .
As I have mentioned 5 seconds, It wait for 5 seconds and come out if no
message in Queue.
Note : I am getting CPU high even if there is not message in queue to
consume.
I have tried receiver.fetch with abnd without duration, in both
case I am getting CPU high.
Thanks,
Mohan
--
Sent from: http://qpid.2158936.n2.nabble.com/Apache-Qpid-users-f2158936.html
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: C++ QPID Messaging : CPU high issue
Posted by Ted Ross <tr...@redhat.com>.
On Wed, Sep 23, 2020 at 8:10 AM umohank <um...@gmail.com> wrote:
> Hi,
>
> Client : C++ QPID Messaging
> Broker : ActiveMQ Artemis
>
> I am facing CPU high issue.
> Creating temp queue and waiting for the message in recevier.fetch()
> call.
> Getting CPU *20+% in release built 32bit* for the below code.
>
>
> try {
> connection.open();
> Session session = connection.createTransactionalSession();
> Receiver receiver = session.createReceiver("Temp");
> char szControlPlane[512] = { 0x00 };
>
> receiver.setCapacity(512);
> session.sync();
> while (true)
> {
> Message request;
> if (receiver.fetch(request, Duration::SECOND * 5))
> {
> }
> }
> }
>
> Is there any think I am missing OR waiting for message in receiver.fetch
> taking more CPU?
>
I believe that the receiver.fetch function will return immediately with
'false' if the receiver is closed. It's possible that there was some error
in the attaching of the receiver to the broker.
>
> Thanks,
> mohan
>
>
>
> --
> Sent from:
> http://qpid.2158936.n2.nabble.com/Apache-Qpid-users-f2158936.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
>
>