From 65d64069597882cf273d72fe872ee1fe6bd9de23 Mon Sep 17 00:00:00 2001 From: HÃ¥vard Pettersen Date: Tue, 24 Sep 2019 13:44:28 +0000 Subject: faster gbdt forest evaluation This is a draft implementation of gbdt forest evaluation doing feature-at-a-time rather than tree-at-a-time. --- .../vespa-ranking-expression-analyzer.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'searchlib') diff --git a/searchlib/src/apps/vespa-ranking-expression-analyzer/vespa-ranking-expression-analyzer.cpp b/searchlib/src/apps/vespa-ranking-expression-analyzer/vespa-ranking-expression-analyzer.cpp index 1d316fe28d8..0f49fb05f35 100644 --- a/searchlib/src/apps/vespa-ranking-expression-analyzer/vespa-ranking-expression-analyzer.cpp +++ b/searchlib/src/apps/vespa-ranking-expression-analyzer/vespa-ranking-expression-analyzer.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -191,6 +192,7 @@ struct FunctionInfo { fprintf(stderr, " WARNING: checks are not tuned (expected path length to be ignored)\n"); } fprintf(stderr, " largest set membership check: %zu\n", forest.max_set_size); + fprintf(stderr, " number of inverted checks: %zu\n", forest.total_inverted_checks); for (const auto &item: forest.tree_sizes) { fprintf(stderr, " forest contains %zu GBD tree%s of size %zu\n", item.count, maybe_s(item.count), item.size); @@ -264,7 +266,17 @@ struct State { void benchmark_option(const vespalib::string &opt_name, Optimize::Chain optimizer_chain) { options.push_back(opt_name); options_us.push_back(CompiledFunction(function, PassParams::ARRAY, optimizer_chain).estimate_cost_us(fun_info.params)); - fprintf(stderr, " LLVM(%s) execute time: %g us\n", opt_name.c_str(), options_us.back()); + fprintf(stderr, " option '%s' execute time: %g us\n", opt_name.c_str(), options_us.back()); + } + + void maybe_benchmark_fast_forest() { + auto ff = FastForest::try_convert(function); + if (ff) { + vespalib::string opt_name("ff"); + options.push_back(opt_name); + options_us.push_back(ff->estimate_cost_us(fun_info.params)); + fprintf(stderr, " option '%s' execute time: %g us\n", opt_name.c_str(), options_us.back()); + } } void report(bool verbose) { @@ -282,12 +294,13 @@ struct State { if (!vmforest_used(compiled_function->get_forests()) && !fun_info.forests.empty()) { benchmark_option("vmforest", VMForest::optimize_chain); } + maybe_benchmark_fast_forest(); fprintf(stdout, "[compile: %.3fs][execute: %.3fus]", llvm_compile_s, llvm_execute_us); for (size_t i = 0; i < options.size(); ++i) { double rel_speed = (llvm_execute_us / options_us[i]); fprintf(stdout, "[%s: %zu%%]", options[i].c_str(), as_percent(rel_speed)); if (rel_speed >= 1.1) { - fprintf(stderr, " WARNING: LLVM(%s) faster than default choice\n", + fprintf(stderr, " WARNING: option '%s' faster than default choice\n", options[i].c_str()); } } -- cgit v1.2.3