Skip to content

Commit 64e945c

Browse files
Merge 170b5d9 into 89dfce5
2 parents 89dfce5 + 170b5d9 commit 64e945c

File tree

5 files changed

+171
-49
lines changed

5 files changed

+171
-49
lines changed

ydb/library/yql/minikql/comp_nodes/mkql_wide_combine.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "mkql_wide_combine.h"
22
#include "mkql_rh_hash.h"
33

4+
#include <format>
45
#include <ydb/library/yql/minikql/computation/mkql_computation_node_codegen.h> // Y_IGNORE
56
#include <ydb/library/yql/minikql/computation/mkql_llvm_base.h> // Y_IGNORE
67
#include <ydb/library/yql/minikql/computation/mkql_computation_node.h>
@@ -550,17 +551,19 @@ class TSpillingSupportState : public TComputationValue<TSpillingSupportState> {
550551
}
551552

552553
bool CheckMemoryAndSwitchToSpilling() {
554+
std::cerr << std::format("MISHA: {} {} {}\n", AllowSpilling, (bool)Ctx.SpillerFactory, IsSwitchToSpillingModeCondition());
553555
if (AllowSpilling && Ctx.SpillerFactory && IsSwitchToSpillingModeCondition()) {
554-
const auto used = TlsAllocState->GetUsed();
555-
const auto limit = TlsAllocState->GetLimit();
556+
std::cerr << "MISHA spilling enabled" << std::endl;
557+
// const auto used = TlsAllocState->GetUsed();
558+
// const auto limit = TlsAllocState->GetLimit();
556559

557-
YQL_LOG(INFO) << "yellow zone reached " << (used*100/limit) << "%=" << used << "/" << limit;
560+
// YQL_LOG(INFO) << "yellow zone reached " << (used*100/limit) << "%=" << used << "/" << limit;
558561
YQL_LOG(INFO) << "switching Memory mode to Spilling";
559562

560563
SwitchMode(EOperatingMode::Spilling);
561564
return true;
562565
}
563-
566+
std::cerr << "MISHA spilling not enabled" << std::endl;
564567
return false;
565568
}
566569

@@ -722,9 +725,7 @@ class TSpillingSupportState : public TComputationValue<TSpillingSupportState> {
722725
}
723726

724727
bool IsSwitchToSpillingModeCondition() const {
725-
return false;
726-
// TODO: YQL-18033
727-
// return !HasMemoryForProcessing();
728+
return !HasMemoryForProcessing();
728729
}
729730

730731
public:

ydb/library/yql/minikql/comp_nodes/ut/mkql_computation_node_ut.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
void N(NUnitTest::TTestContext&)
4949

5050
#define Y_UNIT_TEST_LLVM(N) Y_UNIT_TEST_TWIN(N, LLVM)
51+
#define Y_UNIT_TEST_LLVM_SPILLING(N) Y_UNIT_TEST_QUAD(N, LLVM, SPILLING)
5152

5253
#define Y_UNIT_TEST_QUAD(N, OPT1, OPT2) \
5354
template<bool OPT1, bool OPT2> void N(NUnitTest::TTestContext&); \
@@ -79,7 +80,7 @@ struct TUdfModuleInfo {
7980
NUdf::TUniquePtr<NUdf::IUdfModule> Module;
8081
};
8182

82-
template<bool UseLLVM>
83+
template<bool UseLLVM, bool EnableSpilling = false>
8384
struct TSetup {
8485
explicit TSetup(TComputationNodeFactory nodeFactory = GetTestFactory(), TVector<TUdfModuleInfo>&& modules = {})
8586
: Alloc(__LOCATION__)
@@ -96,6 +97,8 @@ struct TSetup {
9697
FunctionRegistry = mutableRegistry;
9798
}
9899

100+
Alloc.Ref().ForcefullySetMemoryYellowZone(EnableSpilling);
101+
99102
RandomProvider = CreateDeterministicRandomProvider(1);
100103
TimeProvider = CreateDeterministicTimeProvider(10000000);
101104

ydb/library/yql/minikql/comp_nodes/ut/mkql_test_factory.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <ydb/library/yql/minikql/computation/mkql_computation_node_impl.h>
44
#include <ydb/library/yql/minikql/computation/mkql_computation_node_holders.h>
5+
#include <ydb/library/yql/minikql/computation/mock_spiller_factory_ut.h>
56
#include <ydb/library/yql/minikql/mkql_node_cast.h>
67
#include <ydb/library/yql/minikql/mkql_string_util.h>
78

@@ -51,6 +52,7 @@ class TTestStreamWrapper: public TMutableComputationNode<TTestStreamWrapper> {
5152
}
5253

5354
NUdf::TUnboxedValuePod DoCalculate(TComputationContext& ctx) const {
55+
ctx.SpillerFactory = std::make_shared<TMockSpillerFactory>();
5456
return ctx.HolderFactory.Create<TStreamValue>(Count);
5557
}
5658

@@ -70,7 +72,9 @@ class TTestYieldStreamWrapper: public TMutableComputationNode<TTestYieldStreamWr
7072

7173
TStreamValue(TMemoryUsageInfo* memInfo, TComputationContext& compCtx)
7274
: TBase(memInfo)
73-
, CompCtx(compCtx) {}
75+
, CompCtx(compCtx) {
76+
CompCtx.SpillerFactory = std::make_shared<TMockSpillerFactory>();
77+
}
7478

7579
private:
7680
NUdf::EFetchStatus Fetch(NUdf::TUnboxedValue& result) override {
@@ -102,6 +106,7 @@ class TTestYieldStreamWrapper: public TMutableComputationNode<TTestYieldStreamWr
102106
: TBaseComputation(mutables) {}
103107

104108
NUdf::TUnboxedValuePod DoCalculate(TComputationContext& ctx) const {
109+
105110
return ctx.HolderFactory.Create<TStreamValue>(ctx);
106111
}
107112

0 commit comments

Comments
 (0)