Movatterモバイル変換


[0]ホーム

URL:


 / 
MCE-1.901
River stage three • 22 direct dependents • 287 total dependents
/MCE::Util

NAME

MCE::Util - Utility functions

VERSION

This document describes MCE::Util version 1.901

SYNOPSIS

use MCE::Util;

DESCRIPTION

A utility module for MCE. Nothing is exported by default. Exportable is get_ncpu.

get_ncpu()

Returns the number of logical (online/active/enabled) CPU cores; never smaller than one.

my $ncpu = MCE::Util::get_ncpu();

Specifying 'auto' for max_workers calls MCE::Util::get_ncpu automatically. MCE 1.521 sets an upper-limit when specifying 'auto'. The reason is mainly to safeguard apps from spawning 100 workers on a box having 100 cores. This is important for apps which are IO-bound.

use MCE;## 'Auto' is the total # of logical cores (lcores) (8 maximum, MCE 1.521).## The computed value will not exceed the # of logical cores on the box.my $mce = MCE->new(max_workers => 'auto',       ##  1 on HW with 1-lcores;  2 on  2-lcoresmax_workers =>  16,          ## 16 on HW with 4-lcores; 16 on 32-lcoresmax_workers => 'auto',       ##  4 on HW with 4-lcores;  8 on 16-lcoresmax_workers => 'auto*1.5',   ##  4 on HW with 4-lcores; 12 on 16-lcoresmax_workers => 'auto*2.0',   ##  4 on HW with 4-lcores; 16 on 16-lcoresmax_workers => 'auto/2.0',   ##  2 on HW with 4-lcores;  4 on 16-lcoresmax_workers => 'auto+3',     ##  4 on HW with 4-lcores; 11 on 16-lcoresmax_workers => 'auto-1',     ##  3 on HW with 4-lcores;  7 on 16-lcoresmax_workers => MCE::Util::get_ncpu,   ## run on all lcores);

In summary:

1. Auto has an upper-limit of 8 in MCE 1.521 (# of lcores, 8 maximum)2. Math may be applied with auto (*/+-) to change the upper limit3. The computed value for auto will not exceed the total # of lcores4. One can specify max_workers explicitly to a hard value5. MCE::Util::get_ncpu returns the actual # of lcores

ACKNOWLEDGMENTS

The portable code for detecting the number of processors was adopted fromTest::Smoke::SysInfo.

INDEX

MCE,MCE::Core

AUTHOR

Mario E. Roy,<marioeroy AT gmail DOT com>

Module Install Instructions

To install MCE, copy and paste the appropriate command in to your terminal.

cpanm

cpanm MCE

CPAN shell

perl -MCPAN -e shellinstall MCE

For more information on module installation, please visitthe detailed CPAN module installation guide.

Keyboard Shortcuts

Global
sFocus search bar
?Bring up this help dialog
GitHub
gpGo to pull requests
gigo to github issues (only if github is preferred repository)
POD
gaGo to author
gcGo to changes
giGo to issues
gdGo to dist
grGo to repository/SCM
gsGo to source
gbGo to file browse
Search terms
module: (e.g.module:Plugin)
distribution: (e.g.distribution:Dancer auth)
author: (e.g.author:SONGMU Redis)
version: (e.g.version:1.00)

[8]ページ先頭

©2009-2025 Movatter.jp