(core) Replace compute stack and frames with _current_node and _current_row_id

Summary:
This is an attempt to optimise Engine._use_node. It doesn't seem to actually improve overall performance significantly, but it shouldn't make it worse, and I think it's an improvement to the code.

It turns out that there's no need to track a stack of compute frames any more. The only time we get close to nested evaluation, we set allow_evaluation=False to prevent it actually happening. So there's only one 'frame' during actual evaluation, which means we can get rid of the concept of frames entirely. This allows simplifying the code and letting the computer do less work in general.

Test Plan: this

Reviewers: dsagal

Reviewed By: dsagal

Subscribers: dsagal

Differential Revision: https://phab.getgrist.com/D3310
This commit is contained in:
Alex Hall
2022-03-10 22:34:21 +02:00
parent f02174eb7e
commit 2d0978559b
3 changed files with 104 additions and 135 deletions

View File

@@ -125,17 +125,17 @@ class BaseLookupMapColumn(column.BaseColumn):
the current frame to the returned records. Returns an empty set if no records match.
"""
key = tuple(_extract(val) for val in key)
current_frame = self._engine.get_current_frame()
if current_frame:
rel = self._get_relation(current_frame.node)
rel._add_lookup(current_frame.current_row_id, key)
engine = self._engine
if engine._current_node:
rel = self._get_relation(engine._current_node)
rel._add_lookup(engine._current_row_id, key)
else:
rel = None
# The _use_node call both brings LookupMapColumn up-to-date, and creates a dependency on it.
# Relation of None isn't valid, but it happens to be unused when there is no current_frame.
row_ids = self._row_key_map.lookup_right(key, set())
self._engine._use_node(self.node, rel, row_ids)
engine._use_node(self.node, rel, row_ids)
if not row_ids:
row_ids = self._row_key_map.lookup_right(key, set())