简体   繁体   English

Perl中的并行处理。 CPU使用率100%

[英]parallel processing in perl. CPU usage 100%

i have developed a script for data extraction in perl. 我开发了一个脚本,用于在Perl中进行数据提取。

using a parallel::ForkManager module and its functionalities 使用parallel::ForkManager模块及其功能

it works well when i run the script from 4core cpu. 当我从4core cpu运行脚本时,它运行良好。 but when i try to run it from different cpu which is of 2core only has a cpu usage 100%. 但是当我尝试从2core的不同cpu运行它时,cpu的使用率只有100%。

my problem is to reduce that cpu usage n run script smoothly. 我的问题是减少cpu使用率n顺利运行脚本。 i already reduces the max_Child_process to 10 previously it was 40. restriction: my script must parse all pages and store data in database within a 25 seconds. 我已经将max_Child_process降低为10,以前是40。限制:我的脚本必须在25秒内解析所有页面并将数据存储在数据库中。 currently it is doing it in 22-24 seconds but uses full cpu. 目前,它的执行时间为22-24秒,但使用了完整的CPU。 can anybody gives me some idea about how and what to do for reducing my cpu usage. 谁能给我一些有关如何减少CPU使用率的想法。

Use a usleep when waiting for child processes. 等待子进程时使用usleep。

until (waitpid(-1, WNOHANG)) { usleep(100); }

Dramatically reduces cpu in parallel programs 大幅降低并行程序中的cpu

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM