You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@karaf.apache.org by R V Ramakrishna <ra...@gmail.com> on 2014/12/18 12:37:16 UTC

Karaf runs slower in Intel Socx 1000 board.

Team,

We have a requirement to run our project (IoT) in Intel Socx 1000 board.
Initially it was running in Linux and Windows machine. Performance is good.
The same setup in embedded intel board takes time. Start up takes around 20
mints and response time takes around 50 secs. We have around 29 bundles
runnning in Karaf 3.0.2 version.

I did take up a thread dump, heapdump. What I observed is in our code the
Jaxb marshall/unmarshalling is taking longer times. Can anybody give me some
suggestion as how to overcome this?

Thanks and Regards,
RK



--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-runs-slower-in-Intel-Socx-1000-board-tp4037286.html
Sent from the Karaf - Dev mailing list archive at Nabble.com.

Re: Karaf runs slower in Intel Socx 1000 board.

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Please,

When you send a private message, it doesn't make sense to send on the 
mailing list: it creates useless noise.

Regards
JB

On 12/27/2014 04:57 PM, R V Ramakrishna wrote:
> Hi JB,
>
> If possible can you please the dump and help me out on this?
>
> Thanks,
> RK
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Karaf-runs-slower-in-Intel-Socx-1000-board-tp4037286p4037438.html
> Sent from the Karaf - Dev mailing list archive at Nabble.com.
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Karaf runs slower in Intel Socx 1000 board.

Posted by R V Ramakrishna <ra...@gmail.com>.
Hi JB,

If possible can you please the dump and help me out on this?

Thanks,
RK



--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-runs-slower-in-Intel-Socx-1000-board-tp4037286p4037438.html
Sent from the Karaf - Dev mailing list archive at Nabble.com.

Re: Karaf runs slower in Intel Socx 1000 board.

Posted by Daniel Kulp <dk...@apache.org>.
Two things:

1) Cache the JAXBContext.   Creating a JAXBContext is very expensive and slow as it involves scanning packages, annotations, etc….   Create that once.

2) unmarshalling from an InputStream is also very expensive as it needs to create a SAX Parser which involves the SPI lookup mechanism as well as several System.getProperties calls which can kill scalability.   Also note that this opens up the door to various attacks as that SAX parser is not configured to block various things.


If you can, do something like:

XMLInputFactory factory  =  XMLInputFactory.newInstance(); 
factory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.TRUE);
factory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.FALSE);
factory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE);
factory.setXMLResolver(new XMLResolver() {
            public Object resolveEntity(String publicID, String systemID,
                                        String baseURI, String namespace)
                throws XMLStreamException {
                throw new XMLStreamException("Reading external entities is disabled");
            }
        });
then cache that factory along with your JAXBContext.   Then do:

unmarshaller.unmarshall(factory.createXMLStreamReader(inputStream));


That will perform a ton better and be significantly more secure.    If the factory is the woodstox factory (which you REALLY should use as it’s much faster than the one built into the JDK), then also add:

factory.setProperty("com.ctc.wstx.maxAttributesPerElement", maxAttributeCount)
factory.setProperty("com.ctc.wstx.maxAttributeSize", maxAttributeSize)
factory.setProperty("com.ctc.wstx.maxChildrenPerElement", innerElementCountThreshold)
factory.setProperty("com.ctc.wstx.maxElementCount", maxElementCount)
factory.setProperty("com.ctc.wstx.maxElementDepth", innerElementLevelThreshold)
factory.setProperty("com.ctc.wstx.maxCharacters", maxXMLCharacters)
factory.setProperty("com.ctc.wstx.maxTextLength", maxTextLength))

with reasonable values for those settings.   That would prevent a slew of various DOS attacks as well as can help reduce some of the memory usage.

Dan



> On Dec 18, 2014, at 9:28 AM, R V Ramakrishna <ra...@gmail.com> wrote:
> 
> JB,
> 
> The way we do unmarshalling is 
> 
> JAXBContext jc;
>            jc = JAXBContext.newInstance(Class.forName(resObject
>                    .getClass().getName()));
>            Unmarshaller unmarshaller;
>            unmarshaller = jc.createUnmarshaller();
> 
>            unmarshaller.setSchema(schema);
>            resObject = (Resource) unmarshaller.unmarshal(inputStream);
> 
> We use Java JAXB..not servicemix implementation. Actually the code is not
> written by me, done by some other team and its a huge code. Looking at
> higher level of source i can say this Jaxb unmarshaller has been called in
> many bundles explicitly. Any way that we can get rid of this through some
> configurations. I have sent one more set of test results that I did today
> morning to you, around an hour back.
> 
> Thanks,
> RK
> 
> 
> 
> 
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Karaf-runs-slower-in-Intel-Socx-1000-board-tp4037286p4037303.html
> Sent from the Karaf - Dev mailing list archive at Nabble.com.

-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com


Re: Karaf runs slower in Intel Socx 1000 board.

Posted by R V Ramakrishna <ra...@gmail.com>.
JB,

The way we do unmarshalling is 

JAXBContext jc;
            jc = JAXBContext.newInstance(Class.forName(resObject
                    .getClass().getName()));
            Unmarshaller unmarshaller;
            unmarshaller = jc.createUnmarshaller();

            unmarshaller.setSchema(schema);
            resObject = (Resource) unmarshaller.unmarshal(inputStream);

We use Java JAXB..not servicemix implementation. Actually the code is not
written by me, done by some other team and its a huge code. Looking at
higher level of source i can say this Jaxb unmarshaller has been called in
many bundles explicitly. Any way that we can get rid of this through some
configurations. I have sent one more set of test results that I did today
morning to you, around an hour back.

Thanks,
RK




--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-runs-slower-in-Intel-Socx-1000-board-tp4037286p4037303.html
Sent from the Karaf - Dev mailing list archive at Nabble.com.

Re: Karaf runs slower in Intel Socx 1000 board.

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi,

I'm on the dump that you sent yesterday.

I keep you posted soon.

Regarding JAXB, do you create the JAXB context as each call ?
How do you do the JAXB marshalling/unmarshalling ?

Regards
JB

On 12/18/2014 12:37 PM, R V Ramakrishna wrote:
> Team,
>
> We have a requirement to run our project (IoT) in Intel Socx 1000 board.
> Initially it was running in Linux and Windows machine. Performance is good.
> The same setup in embedded intel board takes time. Start up takes around 20
> mints and response time takes around 50 secs. We have around 29 bundles
> runnning in Karaf 3.0.2 version.
>
> I did take up a thread dump, heapdump. What I observed is in our code the
> Jaxb marshall/unmarshalling is taking longer times. Can anybody give me some
> suggestion as how to overcome this?
>
> Thanks and Regards,
> RK
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Karaf-runs-slower-in-Intel-Socx-1000-board-tp4037286.html
> Sent from the Karaf - Dev mailing list archive at Nabble.com.
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Karaf runs slower in Intel Socx 1000 board.

Posted by "Jamie G." <ja...@gmail.com>.
Once you have the container up and running, you may want to try out KTop:
https://github.com/savoirtech/ktop

It'll provide you with runtime metrics from your container.
Alternatively, you could connect via JMX using JConsole or the like.

Cheers,
Jamie

On Thu, Dec 18, 2014 at 10:51 AM, Jamie G. <ja...@gmail.com> wrote:
> The best i can offer for a low resource foot print can be found on my
> personal repo for running OpenDaylight Helium release on Raspberry Pi
> (Karaf 3 based SDN controller):
> https://github.com/jgoodyear/ODLHeliumOnRPi
>
> Take a close look at the script and environment changes I made here:
> https://github.com/jgoodyear/ODLHeliumOnRPi/tree/master/helium/bin
>
> I don't know your specific OS/Platform well enough to offer tuning
> advice at that layer.
>
> Cheers,
> Jamie
>
> On Thu, Dec 18, 2014 at 9:40 AM, R V Ramakrishna
> <ra...@gmail.com> wrote:
>> Hi,
>>
>> Thanks for your response. Pls find the details.
>>
>> O/S: Linux WR-IntelligentDevice 3.4.88-WR5.0.1.19_standard_IDP-XT_2.0.2.19
>> #2 Wed Sep 24 11:51:49 MST 2014 i586 GNU/Linux
>> JVM Vendor/Version: Oracle JDK1.7.0_71
>> Board: Intel Quark Socx1000(Not galileo).
>> Memory: 512 MB
>>
>> No we have not modified any setup in karaf env variables to handle the low
>> resources. Do we have any such configurations? If so can you please mention.
>>
>> Thanks,
>> RK
>>
>>
>>
>>
>> --
>> View this message in context: http://karaf.922171.n3.nabble.com/Karaf-runs-slower-in-Intel-Socx-1000-board-tp4037286p4037297.html
>> Sent from the Karaf - Dev mailing list archive at Nabble.com.

Re: Karaf runs slower in Intel Socx 1000 board.

Posted by "Jamie G." <ja...@gmail.com>.
The best i can offer for a low resource foot print can be found on my
personal repo for running OpenDaylight Helium release on Raspberry Pi
(Karaf 3 based SDN controller):
https://github.com/jgoodyear/ODLHeliumOnRPi

Take a close look at the script and environment changes I made here:
https://github.com/jgoodyear/ODLHeliumOnRPi/tree/master/helium/bin

I don't know your specific OS/Platform well enough to offer tuning
advice at that layer.

Cheers,
Jamie

On Thu, Dec 18, 2014 at 9:40 AM, R V Ramakrishna
<ra...@gmail.com> wrote:
> Hi,
>
> Thanks for your response. Pls find the details.
>
> O/S: Linux WR-IntelligentDevice 3.4.88-WR5.0.1.19_standard_IDP-XT_2.0.2.19
> #2 Wed Sep 24 11:51:49 MST 2014 i586 GNU/Linux
> JVM Vendor/Version: Oracle JDK1.7.0_71
> Board: Intel Quark Socx1000(Not galileo).
> Memory: 512 MB
>
> No we have not modified any setup in karaf env variables to handle the low
> resources. Do we have any such configurations? If so can you please mention.
>
> Thanks,
> RK
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Karaf-runs-slower-in-Intel-Socx-1000-board-tp4037286p4037297.html
> Sent from the Karaf - Dev mailing list archive at Nabble.com.

Re: Karaf runs slower in Intel Socx 1000 board.

Posted by R V Ramakrishna <ra...@gmail.com>.
Hi,

Thanks for your response. Pls find the details.

O/S: Linux WR-IntelligentDevice 3.4.88-WR5.0.1.19_standard_IDP-XT_2.0.2.19
#2 Wed Sep 24 11:51:49 MST 2014 i586 GNU/Linux
JVM Vendor/Version: Oracle JDK1.7.0_71
Board: Intel Quark Socx1000(Not galileo).
Memory: 512 MB

No we have not modified any setup in karaf env variables to handle the low
resources. Do we have any such configurations? If so can you please mention.

Thanks,
RK




--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-runs-slower-in-Intel-Socx-1000-board-tp4037286p4037297.html
Sent from the Karaf - Dev mailing list archive at Nabble.com.

Re: Karaf runs slower in Intel Socx 1000 board.

Posted by "Jamie G." <ja...@gmail.com>.
Hi RK,

Can you provide a few more details on the environment?

Operating System version.
JVM vendor and version

Can you tell us a little more about the system resources? How much
memory, disc speed, quantity of CPU. Have you made any modifications
to the setenv or karaf scripts to help the system handle low
resources?

I've been working with Karaf on smaller devices (RPi), but have not
worked directly with an Intel Socx 1000 board. I do have an Intel
Edison on order, however it has yet to arrive. I'm assuming you're
working on a Galileo?

In regards to Jaxb marshall/unmarshalling, you may want to look into
pooling the resources to avoid the expensive setup of the marshaller.

Cheers,
Jamie

On Thu, Dec 18, 2014 at 8:07 AM, R V Ramakrishna
<ra...@gmail.com> wrote:
> Team,
>
> We have a requirement to run our project (IoT) in Intel Socx 1000 board.
> Initially it was running in Linux and Windows machine. Performance is good.
> The same setup in embedded intel board takes time. Start up takes around 20
> mints and response time takes around 50 secs. We have around 29 bundles
> runnning in Karaf 3.0.2 version.
>
> I did take up a thread dump, heapdump. What I observed is in our code the
> Jaxb marshall/unmarshalling is taking longer times. Can anybody give me some
> suggestion as how to overcome this?
>
> Thanks and Regards,
> RK
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Karaf-runs-slower-in-Intel-Socx-1000-board-tp4037286.html
> Sent from the Karaf - Dev mailing list archive at Nabble.com.