Java thread performance on raspberry pi

The goal of the application is to process 800 concurrent clients through TCP, and each client sends a 3.5kb XML. XML per second Each of these requests needs to be parsed (see code snipping) This happens on different threads

The limitation of this project is that it must run on a small raspberry PI3 (1.2 GHz quad core, 1GB RAM) When I increased the load to more than 150 clients (80% CPU utilization), I encountered a utilization problem

When I run this program, my development machine seems to work well (0-1% dosage, less than 150) I know my development machine is more powerful than RPI, so it runs better But the difference seems too great

In my current setup, I use Java NiO to process / read all incoming connections Then I use multiple threads to read the data

This is simple code currently running on the processing thread Also try to read a simple byte [] array 1 byte at a time Even read the Stax stream The "read type" of the operation gives the worst performance for every change in the reading I've tried

BufferedInputStream input = new BufferedInputStream(new ByteArrayInputStream(buffer.array(),bytecount));
int current;
/* In this snippet input.read() is the cause of performance issues 
Reading directly from byte[] gives similar poor performance.
*/
while ((current = input.read()) != -1) {
    continue;
}

According to my analyzer, input The read () call uses a lot of processing power on PI, accounting for 97% of the total CPU time The other 3% are the main threads that handle connections

On my development machine, this is almost flipped, and the main thread accounts for 93% of the CPU utilization 7% for processing threads

What could lead to this huge difference? Why is the read () call on PI so expensive compared to my other machines? Is it possibly memory related?

Notes:

>PI runs raspbian Linux – openjdk 1.8 0_ 40 internal > dev machine run10 – Java (TM) se runtime environment (version 1.8.0_121-b13) > tried to run the - XMS - Xmx flag on both machines and the results were the same

Solution

It turns out that the problem is the combination of JVM and 32-bit operating system on raspberry PI 3 When running 32-bit raspbian with openjdk, the performance of my application is very poor (especially on "read" calls) Switching to Oracle JVM gave me "better" expected performance

However, when switching to 64 bit operating system (openssuse in my case), the performance of openjdk and Oracle JVM is very good

(in the comments to @jww, it is recommended to switch to 64 bit operating system)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>