Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YQL-18052: Introduce CLI option to purebench to toggle block engine mode #4526

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ydb/library/yql/public/purecalc/common/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ TProgramFactoryOptions::TProgramFactoryOptions()
: UdfsDir_("")
, UserData_()
, LLVMSettings("OFF")
, BlockEngineSettings("disable")
, CountersProvider(nullptr)
, NativeYtTypeFlags(0)
, UseSystemColumns(false)
Expand Down Expand Up @@ -77,6 +78,11 @@ TProgramFactoryOptions& TProgramFactoryOptions::SetLLVMSettings(TStringBuf llvm_
return *this;
}

TProgramFactoryOptions& TProgramFactoryOptions::SetBlockEngineSettings(TStringBuf blockEngineSettings) {
BlockEngineSettings = blockEngineSettings;
return *this;
}

TProgramFactoryOptions& TProgramFactoryOptions::SetCountersProvider(NKikimr::NUdf::ICountersProvider* countersProvider) {
CountersProvider = countersProvider;
return *this;
Expand Down
12 changes: 12 additions & 0 deletions ydb/library/yql/public/purecalc/common/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ namespace NYql {
/// LLVM settings. Assign "OFF" to disable LLVM, empty string for default settings.
TString LLVMSettings;

/// Block engine settings. Assign "force" to unconditionally enable
/// it, "disable" for turn it off and "auto" to left the final
/// decision to the platform heuristics.
TString BlockEngineSettings;

/// Provider for generic counters which can be used to export statistics from UDFs.
NKikimr::NUdf::ICountersProvider* CountersProvider;

Expand Down Expand Up @@ -311,6 +316,13 @@ namespace NYql {
*/
TProgramFactoryOptions& SetLLVMSettings(TStringBuf llvm_settings);

/**
* Set new block engine settings.
*
* @return reference to self, to allow method chaining.
*/
TProgramFactoryOptions& SetBlockEngineSettings(TStringBuf blockEngineSettings);

/**
* Set new counters provider. Passed pointer should stay alive for as long as the processor factory
* stays alive.
Expand Down
10 changes: 10 additions & 0 deletions ydb/library/yql/public/purecalc/common/program_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ TProgramFactory::TProgramFactory(const TProgramFactoryOptions& options)
{
EnsureLoggingInitialized();

if (!TryFromString(Options_.BlockEngineSettings, BlockEngineMode_)) {
ythrow TCompileError("", "") << "Unknown BlockEngineSettings value: expected "
<< GetEnumAllNames<EBlockEngineMode>()
<< ", but got: "
<< Options_.BlockEngineSettings;
}

NUserData::TUserData::UserDataToLibraries(Options_.UserData_, Modules_);

UserData_ = GetYqlModuleResolver(ExprContext_, ModuleResolver_, Options_.UserData_, {}, {});
Expand Down Expand Up @@ -75,6 +82,7 @@ IPullStreamWorkerFactoryPtr TProgramFactory::MakePullStreamWorkerFactory(
UserData_,
Modules_,
Options_.LLVMSettings,
BlockEngineMode_,
CountersProvider_,
mode,
syntaxVersion,
Expand Down Expand Up @@ -102,6 +110,7 @@ IPullListWorkerFactoryPtr TProgramFactory::MakePullListWorkerFactory(
UserData_,
Modules_,
Options_.LLVMSettings,
BlockEngineMode_,
CountersProvider_,
mode,
syntaxVersion,
Expand Down Expand Up @@ -133,6 +142,7 @@ IPushStreamWorkerFactoryPtr TProgramFactory::MakePushStreamWorkerFactory(
UserData_,
Modules_,
Options_.LLVMSettings,
BlockEngineMode_,
CountersProvider_,
mode,
syntaxVersion,
Expand Down
1 change: 1 addition & 0 deletions ydb/library/yql/public/purecalc/common/program_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace NYql {
TIntrusivePtr<NKikimr::NMiniKQL::IMutableFunctionRegistry> FuncRegistry_;
IModuleResolver::TPtr ModuleResolver_;
TUserDataTable UserData_;
EBlockEngineMode BlockEngineMode_;
THashMap<TString, TString> Modules_;
NKikimr::NUdf::ICountersProvider* CountersProvider_;

Expand Down
2 changes: 2 additions & 0 deletions ydb/library/yql/public/purecalc/common/worker_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ TWorkerFactory<TBase>::TWorkerFactory(TWorkerFactoryOptions options, EProcessorM
, FuncRegistry_(std::move(options.FuncRegistry))
, UserData_(std::move(options.UserData))
, LLVMSettings_(std::move(options.LLVMSettings))
, BlockEngineMode_(options.BlockEngineMode)
, CountersProvider_(options.CountersProvider_)
, NativeYtTypeFlags_(options.NativeYtTypeFlags_)
, DeterministicTimeProviderSeed_(options.DeterministicTimeProviderSeed_)
Expand Down Expand Up @@ -134,6 +135,7 @@ TExprNode::TPtr TWorkerFactory<TBase>::Compile(
typeContext->UdfResolver = NCommon::CreateSimpleUdfResolver(FuncRegistry_.Get());
typeContext->UserDataStorage = MakeIntrusive<TUserDataStorage>(nullptr, UserData_, nullptr, nullptr);
typeContext->Modules = moduleResolver;
typeContext->BlockEngineMode = BlockEngineMode_;
auto configProvider = CreateConfigProvider(*typeContext, nullptr, "");
typeContext->AddDataSource(ConfigProviderName, configProvider);
typeContext->Initialize(ExprContext_);
Expand Down
4 changes: 4 additions & 0 deletions ydb/library/yql/public/purecalc/common/worker_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace NYql {
const TUserDataTable& UserData;
const THashMap<TString, TString>& Modules;
TString LLVMSettings;
EBlockEngineMode BlockEngineMode;
NKikimr::NUdf::ICountersProvider* CountersProvider_;
ETranslationMode TranslationMode_;
ui16 SyntaxVersion_;
Expand All @@ -41,6 +42,7 @@ namespace NYql {
const TUserDataTable& UserData,
const THashMap<TString, TString>& Modules,
TString LLVMSettings,
EBlockEngineMode BlockEngineMode,
NKikimr::NUdf::ICountersProvider* CountersProvider,
ETranslationMode translationMode,
ui16 syntaxVersion,
Expand All @@ -58,6 +60,7 @@ namespace NYql {
, UserData(UserData)
, Modules(Modules)
, LLVMSettings(std::move(LLVMSettings))
, BlockEngineMode(BlockEngineMode)
, CountersProvider_(CountersProvider)
, TranslationMode_(translationMode)
, SyntaxVersion_(syntaxVersion)
Expand Down Expand Up @@ -86,6 +89,7 @@ namespace NYql {
TVector<THashSet<TString>> AllColumns_;
TVector<THashSet<TString>> UsedColumns_;
TString LLVMSettings_;
EBlockEngineMode BlockEngineMode_;
NKikimr::NUdf::ICountersProvider* CountersProvider_;
ui64 NativeYtTypeFlags_;
TMaybe<ui64> DeterministicTimeProviderSeed_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ int main() {
auto factoryOptions = TProgramFactoryOptions();
factoryOptions.SetNativeYtTypeFlags(0);
factoryOptions.SetLLVMSettings("OFF");
factoryOptions.SetBlockEngineSettings("disable");
auto factory = MakeProgramFactory(factoryOptions);
auto program = factory->MakePullListProgram(
inputSpec,
Expand Down
5 changes: 4 additions & 1 deletion ydb/library/yql/tools/purebench/purebench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ int Main(int argc, const char *argv[])
bool showResults;
TString udfsDir;
TString LLVMSettings;
TString blockEngineSettings;
opts.AddHelpOption();
opts.AddLongOption("ndebug", "should be at first argument, do not show debug info in error output").NoArgument();
opts.AddLongOption('b', "blocks-engine", "Block engine settings").StoreResult(&blockEngineSettings).DefaultValue("disable");
opts.AddLongOption('c', "count", "count of input rows").StoreResult(&count).DefaultValue(1000000);
opts.AddLongOption('g', "gen-sql", "SQL query to generate data").StoreResult(&genSql).DefaultValue("select index from Input");
opts.AddLongOption('t', "test-sql", "SQL query to test").StoreResult(&testSql).DefaultValue("select count(*) as count from Input");
Expand All @@ -49,6 +51,7 @@ int Main(int argc, const char *argv[])
auto factoryOptions = TProgramFactoryOptions();
factoryOptions.SetUDFsDir(udfsDir);
factoryOptions.SetLLVMSettings(LLVMSettings);
factoryOptions.SetBlockEngineSettings(blockEngineSettings);
auto factory = MakeProgramFactory(factoryOptions);

NYT::TNode members{NYT::TNode::CreateList()};
Expand Down Expand Up @@ -140,7 +143,7 @@ int main(int argc, const char *argv[]) {
try {
return Main(argc, argv);
} catch (const TCompileError& e) {
Cerr << e.GetIssues();
Cerr << e.what() << "\n" << e.GetIssues();
} catch (...) {
Cerr << CurrentExceptionMessage() << Endl;
return 1;
Expand Down
Loading