Skip to content

Commit cbf6da3

Browse files
apronchenkovcopybara-github
authored andcommitted
arolla::CancellationContext
This is a refactoring of the recently introduced `arolla::EvaluationContext::CancellationChecker`. The key changes are as follows: * The context stores the status after a computation has been canceled. Motivation: This allows sharing the context between multiple aggregation accumulators, so that all of them can be cancelled at once. * The rate-limiting logic has been implemented in the base class. Motivation: The compiler can inline it => reduce the overhead. Benchmarks: name cpu/op BM_CancellationContext_10ms_16 1.60ns ± 4% BM_CancellationContext_10ms_4 2.48ns ± 2% BM_CancellationContext_10ms_1 5.63ns ± 1% BM_CancellationContext_10ms_0 11.4ns ± 1% PiperOrigin-RevId: 720239473 Change-Id: I05acded6eeb45cf19c7eed3f151487351f010f59
1 parent 4c1d413 commit cbf6da3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

py/koladata/expr/py_expr_eval.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include "koladata/operators/arolla_bridge.h"
3636
#include "py/arolla/abc/py_aux_binding_policy.h"
3737
#include "py/arolla/abc/py_cached_eval.h"
38-
#include "py/arolla/abc/py_cancellation_checker.h"
38+
#include "py/arolla/abc/py_cancellation_context.h"
3939
#include "py/arolla/abc/py_expr.h"
4040
#include "py/arolla/abc/py_operator.h"
4141
#include "py/arolla/abc/py_qvalue.h"
@@ -62,7 +62,7 @@ using ::arolla::python::AuxBindingPolicyPtr;
6262
using ::arolla::python::DCheckPyGIL;
6363
using ::arolla::python::InvokeOpWithCompilationCache;
6464
using ::arolla::python::ParseArgPyOperator;
65-
using ::arolla::python::PyCancellationChecker;
65+
using ::arolla::python::PyCancellationContext;
6666
using ::arolla::python::QValueOrExpr;
6767
using ::arolla::python::ReleasePyGIL;
6868
using ::arolla::python::SetPyErrFromStatus;
@@ -116,9 +116,9 @@ absl::Nullable<PyObject*> PyEvalExpr(PyObject* /*self*/, PyObject** py_args,
116116

117117
// Set up a mechanism to check if the computation has been interrupted by
118118
// the Python interpreter.
119-
PyCancellationChecker cancellation_checker;
119+
PyCancellationContext cancellation_context;
120120
koladata::expr::EvalOptions eval_options{
121-
.cancellation_checker = &cancellation_checker,
121+
.cancellation_context = &cancellation_context,
122122
};
123123
result_or_error = koladata::expr::EvalExprWithCompilationCache(
124124
expr, input_qvalues, {}, eval_options);

0 commit comments

Comments
 (0)