Commit 75a7ff00 authored by Florian Schmaus's avatar Florian Schmaus
Browse files

Merge branch 'fsearch-finer-fiber-control' into 'master'

fsearch: add more fine grained control about the used fiber throttles

See merge request !375
parents 1957be38 86c71e53
......@@ -29,7 +29,9 @@ namespace po = boost::program_options;
static const char* needle;
static size_t needle_len;
static emper::Semaphore* max_running;
static emper::Semaphore* max_fibers;
static emper::Semaphore* max_searching;
static emper::Semaphore* max_walking;
static emper::lib::ShardedFileBuffer* outBuf;
......@@ -71,7 +73,7 @@ void walk_dir() {
switch (stealingMode) {
case emper::StealingMode::child:
emper::io::recursive_directory_walk(".", filter, fn, max_running, max_running);
emper::io::recursive_directory_walk(".", filter, fn, max_searching, max_walking);
break;
case emper::StealingMode::continuation:
emper::io::fibril_recursive_directory_walk(".", filter, fn);
......@@ -94,13 +96,28 @@ static auto fssearch(const po::variables_map& vm) -> int {
if (vm.count("max-fibers")) {
unsigned int maxFibersCount = vm["max-fibers"].as<unsigned int>();
max_running = new emper::Semaphore(maxFibersCount);
max_fibers = max_searching = max_walking = new emper::Semaphore(maxFibersCount);
} else {
if (vm.count("max-searchers")) {
unsigned int maxSearchersCount = vm["max-searchers"].as<unsigned int>();
max_searching = new emper::Semaphore(maxSearchersCount);
}
if (vm.count("max-walkers")) {
unsigned int maxWalkersCount = vm["max-walkers"].as<unsigned int>();
max_walking = new emper::Semaphore(maxWalkersCount);
}
}
Runtime runtime;
std::cerr << "Starting fsearch with stealingMode=" << stealingMode;
if (max_running) std::cerr << " and " << max_running->getCount() << " file fibers";
if (max_fibers)
std::cerr << " and " << max_fibers->getCount() << " fibers";
else {
if (max_searching) std::cerr << ", " << max_searching->getCount() << " searching fibers";
if (max_walking) std::cerr << " and " << max_walking->getCount() << " walking fibers";
}
std::cerr << std::endl;
auto* dirWalker = Fiber::from(walk_dir);
......@@ -108,7 +125,12 @@ static auto fssearch(const po::variables_map& vm) -> int {
runtime.waitUntilFinished();
delete max_running;
if (max_searching == max_walking)
delete max_fibers;
else {
delete max_searching;
delete max_walking;
}
return EXIT_SUCCESS;
}
......@@ -119,7 +141,9 @@ auto main(int argc, char* argv[]) -> int {
desc.add_options()
("help", "Show help")
("needle", po::value<std::string>(), "The String to search for")
("max-fibers", po::value<unsigned int>(), "Maximum number of file processing fibers")
("max-fibers", po::value<unsigned int>(), "Maximum number of fibers")
("max-searchers", po::value<unsigned int>(), "Maximum number of file searching fibers")
("max-walkers", po::value<unsigned int>(), "Maximum number of directory walking fibers")
("stealing-mode", po::value<enum emper::StealingMode>(&stealingMode)->default_value(emper::StealingMode::child), "Stealing mode to use, either 'child' or 'continuation'")
;
// clang-format on
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment