RE: [jade-develop] performance/CPU usage of cyclic behaviours


Subject: RE: [jade-develop] performance/CPU usage of cyclic behaviours
From: Felix Schmid (fsc.tech@spree.de)
Date: Fri Sep 06 2002 - 17:02:20 MET DST


Hello Fabio,

I am calling block(). Here's my code:

class PingListener extends CyclicBehaviour{

         public PingListener(Agent agent){
             super(agent);
         }

         public void action() {
             AgentInfo info = null;
             ACLMessage msg =
receive(MessageTemplate.MatchPerformative(ACLMessage.REQUEST));
             if (msg != null) {
                 try {
                     ContentElement ce = content_manager.extractContent(msg);

                     if(ce instanceof Action){
                         AgentAction a = (AgentAction)((Action)ce).getAction();

                         if(a instanceof Ping){
                             log.info("received ping from " + msg.getSender());
                             Ping ping = (Ping) a;
                             info = ping.getAgentInfo();

                             /**
                              * send a pong AgentAction as response
                              */
                             ACLMessage response = new
ACLMessage(ACLMessage.INFORM);
                             response.addReceiver(msg.getSender());
                             response.setLanguage(codec.getName());
                             response.setOntology(aura_ontology.getName());
                             Pong pong = new Pong();
                             pong.setAgentInfo(info);
                             //wrap AgentAction into Action
                             Action contentAction = new Action();
                             contentAction.setActor(getAID());
                             contentAction.setAction(pong);
                             try{
                                 getContentManager().fillContent(response,
(ContentElement)contentAction);
                                 send(response);
                                 log.info("sent pong INFORM to " +
msg.getSender());
                             }
                             catch(Exception e){
                                 e.printStackTrace();
                             }
                         }
                         else{
                             log.info("wrong AgentAction");
                             block();
                         }
                     }
                 }
                 catch(Exception e) {
                     e.printStackTrace();
                 }
             }
             else {
                 block();
             }
         }
}

felix

At 16:47 06.09.2002 +0200, you wrote:
>Felix, probably you are not calling block().
>Block() puts the behaviour in blocked_state and they do not consume any CPU.
>
>-----Original Message-----
>From: Felix Schmid [mailto:fsc.tech@spree.de]
>Sent: 06 September 2002 15:49
>To: jade-develop@sharon.cselt.it
>Subject: [jade-develop] performance/CPU usage of cyclic behaviours
>
>
>Hello,
>
>I've observed that my agents are using 99% of CPU usage, even if they are
>doing nothing but waiting for messages
>in a CyclicBehavior. I am doing a receive(), not a blockingReceive(). In
>case that no message arrived (receive() returns null) I am
>calling block(), just as I've seen it in all the jade examples.
>
>Why are the agents behaving like this? I would expect them to do nothing
>(the message queue is supposed to be empty most of the time, because
>I am sending messages to the CyclicBehavior mentioned above only every 30
>seconds). Is there a way to make them less hungry for resources?
>It get's slow when I start three or four agents with the mechanism
>mentioned above.
>
>
>regards,
>felix
>
>_______________________________________________
>jade-develop mailing list
>jade-develop@sharon.cselt.it
>http://sharon.cselt.it/mailman/listinfo/jade-develop
>UNSUBSCRIBE INSTRUCTIONS AT http://jade.cselt.it/mailing.htm#unsubscribe
>
>
>====================================================================
>CONFIDENTIALITY NOTICE
>This message and its attachments are addressed solely to the persons
>above and may contain confidential information. If you have received
>the message in error, be informed that any use of the content hereof
>is prohibited. Please return it immediately to the sender and delete
>the message. Should you have any questions, please contact us by
>replying to MailAdmin@tilab.com. Thank you
>====================================================================



This archive was generated by hypermail 2a22 : Fri Sep 06 2002 - 16:54:27 MET DST