I am running a script that loads big files. I ran the same script in a single core OpenSuSe server and quad core PC. As expected in my PC it is much more faster than in the server. But, the script slows down the server and makes it impossible to do anything else.
我正在运行一个加载大文件的脚本。我在单核OpenSuSe服务器和四核PC中运行相同的脚本。正如我所预期的那样,它比服务器中的速度快得多。但是,脚本会降低服务器的速度,使其无法执行任何其他操作。
My script is
我的剧本是
for 100 iterations
Load saved data (about 10 mb)
time myscript (in PC)
时间myscript(在PC中)
real 0m52.564s
user 0m51.768s
sys 0m0.524s
time myscript (in server)
时间myscript(在服务器中)
real 32m32.810s
user 4m37.677s
sys 12m51.524s
I wonder why "sys" is so high when i run the code in server. I used top command to check the memory and cpu usage. It seems there is still free memory, so swapping is not the reason. % sy is so high, its probably the reason for the speed of server but I dont know what is causing % sy so high. The process that is using highest percent of CPU (99%) is "myscript". %wa is zero in the screenshot but sometimes it gets very high (50 %).
我想知道为什么当我在服务器中运行代码时“sys”如此之高。我使用top命令检查内存和CPU使用情况。似乎仍然有免费记忆,所以交换不是原因。 %sy是如此之高,它可能是服务器速度的原因,但我不知道是什么导致%sy这么高。使用最高CPU百分比(99%)的过程是“myscript”。屏幕截图中%wa为零,但有时会变得非常高(50%)。
When the script is running, load average is greater than 1 but have never seen to be as high as 2.
当脚本运行时,平均负载大于1,但从未见过高达2。
I also checked my disc:
我还检查了我的光盘:
strt:~ # hdparm -tT /dev/sda
/dev/sda:
Timing cached reads: 16480 MB in 2.00 seconds = 8247.94 MB/sec
Timing buffered disk reads: 20 MB in 3.44 seconds = 5.81 MB/sec
john@strt:~> df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 245G 102G 131G 44% /
udev 4.0G 152K 4.0G 1% /dev
tmpfs 4.0G 76K 4.0G 1% /dev/shm
I have checked these things but I am still not sure what is the real problem in my server and how to fix it. Can anyone identify a probable reason for the slowness? What could be the solution? Or is there anything else I should check?
我已经检查了这些东西,但我仍然不确定我的服务器中的真正问题是什么以及如何解决它。任何人都可以找出缓慢的可能原因吗?可能是什么解决方案?或者还有什么我应该检查的吗?
Thanks!
1 个解决方案
#1
2
You're getting a high sys activity because the load of the data you're doing takes system calls that happen in kernel. To resolve your slowness problems without upgrading the server might be possible. You can modify scheduling priority. See the man pages for nice and renice. See here and especially:
您正在获得高sys活动,因为您正在执行的数据加载需要在内核中进行系统调用。无需升级服务器即可解决您的慢速问题。您可以修改计划优先级。有关nice和renice的信息,请参阅手册页。看到这里特别是:
Niceness values range from -20 (the highest priority, lowest niceness) and 19 (the lowest priority, highest niceness).
Niceness值的范围从-20(最高优先级,最低优点)和19(最低优先级,最高优点)。
$ ps -lp 941 F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 4 S 0 941 1 0 70 -10 - 1713 poll_s ? 00:00:00 sshd
$ ps -lp 941 F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 4 S 0 941 1 0 70 -10 - 1713 poll_s? 00:00:00 sshd
$ nice -n 19 ./test.sh My niceness value is 19
$ nice -n 19 ./test.sh我的好感值是19
$ renice -n 10 -p 941 941 (process ID) old priority -10, new priority 10
$ renice -n 10 -p 941 941(进程ID)旧优先级-10,新优先级10
#1
2
You're getting a high sys activity because the load of the data you're doing takes system calls that happen in kernel. To resolve your slowness problems without upgrading the server might be possible. You can modify scheduling priority. See the man pages for nice and renice. See here and especially:
您正在获得高sys活动,因为您正在执行的数据加载需要在内核中进行系统调用。无需升级服务器即可解决您的慢速问题。您可以修改计划优先级。有关nice和renice的信息,请参阅手册页。看到这里特别是:
Niceness values range from -20 (the highest priority, lowest niceness) and 19 (the lowest priority, highest niceness).
Niceness值的范围从-20(最高优先级,最低优点)和19(最低优先级,最高优点)。
$ ps -lp 941 F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 4 S 0 941 1 0 70 -10 - 1713 poll_s ? 00:00:00 sshd
$ ps -lp 941 F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 4 S 0 941 1 0 70 -10 - 1713 poll_s? 00:00:00 sshd
$ nice -n 19 ./test.sh My niceness value is 19
$ nice -n 19 ./test.sh我的好感值是19
$ renice -n 10 -p 941 941 (process ID) old priority -10, new priority 10
$ renice -n 10 -p 941 941(进程ID)旧优先级-10,新优先级10