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

[FIX] evaluation: Ensure dependency invalidation for array formulas #5209

Closed
wants to merge 2 commits into from

Conversation

rrahir
Copy link
Collaborator

@rrahir rrahir commented Nov 14, 2024

How to reproduce:
-> see the attached test

What is happening?
During the evaluation of SUMIFS, it will fetch its ranges. First it will first fetch an empty range (E4:E7) since MUNIT hasn't been evaluated yet.
Afterwards, it will fetch H4, which in turn will request C4 and therefore force the evaluation of the spreaded function MUNIT.

AT this point, there is a disparity of values because the values of the range (E4:E7) have changed.
To address those situations, the evaluator invalidates the dependencies of all the spreaded zone. Which means marking A1 to be recomputed.

Unfortunately, A1 is still being evaluated and since #4589 (specifically commit 8d22e86) we remove the cell from the queue after we evaluted it.

This revision changes the approach taken in 8d22e86 to allow legitimate invalidations take place while avoiding useless reevaluations.

Task: 4252800

Description:

description of this task, what is implemented and why it is implemented that way.

Task: TASK_ID

review checklist

  • feature is organized in plugin, or UI components
  • support of duplicate sheet (deep copy)
  • in model/core: ranges are Range object, and can be adapted (adaptRanges)
  • in model/UI: ranges are strings (to show the user)
  • undo-able commands (uses this.history.update)
  • multiuser-able commands (has inverse commands and transformations where needed)
  • new/updated/removed commands are documented
  • exportable in excel
  • translations (_t("qmsdf %s", abc))
  • unit tested
  • clean commented code
  • track breaking changes
  • doc is rebuild (npm run doc)
  • status is correct in Odoo

@robodoo
Copy link
Collaborator

robodoo commented Nov 14, 2024

Pull request status dashboard

@LucasLefevre LucasLefevre force-pushed the 17.0-fix-array-recompute-deps-rar branch from c31bc5f to c57d35e Compare November 14, 2024 13:21
How to reproduce:
-> see the attached test

What is happening?
During the evaluation of SUMIFS, it will fetch its ranges.
First it will first fetch an empty range (E4:E7)  since MUNIT hasn't
been evaluated yet.
Afterwards, it will fetch H4, which in turn will request C4
and therefore force the evaluation of the spreaded function MUNIT.

AT this point, there is a disparity of values because the values
of the range (E4:E7) have changed.
To address those situations, the evaluator invalidates the dependencies
of all the spreaded zone. Which means marking A1 to be recomputed.

Unfortunately, A1 is still being evaluated and since #4589 (specifically
commit 8d22e86) we remove the cell from the queue after we evaluted it.

This revision changes the approach taken in 8d22e86 to allow
legitimate invalidations take place while avoiding useless
reevaluations.

Task: 4252800
@rrahir rrahir force-pushed the 17.0-fix-array-recompute-deps-rar branch from 84d917d to ec22cf3 Compare November 14, 2024 14:07
Copy link
Collaborator

@LucasLefevre LucasLefevre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

robodoo r+

@robodoo
Copy link
Collaborator

robodoo commented Nov 15, 2024

@rrahir @LucasLefevre because this PR has multiple commits, I need to know how to merge it:

  • merge to merge directly, using the PR as merge commit message
  • rebase-merge to rebase and merge, using the PR as merge commit message
  • rebase-ff to rebase and fast-forward

@LucasLefevre
Copy link
Collaborator

robodoo rebase-ff

@robodoo
Copy link
Collaborator

robodoo commented Nov 15, 2024

Merge method set to rebase and fast-forward.

robodoo pushed a commit that referenced this pull request Nov 15, 2024
How to reproduce:
-> see the attached test

What is happening?
During the evaluation of SUMIFS, it will fetch its ranges.
First it will first fetch an empty range (E4:E7)  since MUNIT hasn't
been evaluated yet.
Afterwards, it will fetch H4, which in turn will request C4
and therefore force the evaluation of the spreaded function MUNIT.

AT this point, there is a disparity of values because the values
of the range (E4:E7) have changed.
To address those situations, the evaluator invalidates the dependencies
of all the spreaded zone. Which means marking A1 to be recomputed.

Unfortunately, A1 is still being evaluated and since #4589 (specifically
commit 8d22e86) we remove the cell from the queue after we evaluted it.

This revision changes the approach taken in 8d22e86 to allow
legitimate invalidations take place while avoiding useless
reevaluations.

Task: 4252800
Part-of: #5209
Signed-off-by: Lucas Lefèvre (lul) <[email protected]>
robodoo pushed a commit that referenced this pull request Nov 15, 2024
The evaluation of splillable function is complex and required some
bugfix over time. Some of the bugfixes have some side effects difficult
to assess and a specific one is the introduction of infinite in the
evaluation which are hidden behind a ceiling of iterations.

While infinite loops can occur in very specific cases, they are not
common and it makes sense to detect them to spot undesired behaviours.

This revision adds a log in debug mode to avoid spam to capture the
attention of the developper.

closes #5209

Task: 4252800
Signed-off-by: Lucas Lefèvre (lul) <[email protected]>
@LucasLefevre
Copy link
Collaborator

robodoo r-

@LucasLefevre
Copy link
Collaborator

LucasLefevre commented Nov 15, 2024

there's a test which is console.debugging (most probably the test testing there's a max number of iterations.
We can mock console in this test

@rrahir rrahir force-pushed the 17.0-fix-array-recompute-deps-rar branch 3 times, most recently from 5454a99 to 42c1983 Compare November 15, 2024 09:30
The evaluation of splillable function is complex and required some
bugfix over time. Some of the bugfixes have some side effects difficult
to assess and a specific one is the introduction of infinite in the
evaluation which are hidden behind a ceiling of iterations.

While infinite loops can occur in very specific cases, they are not
common and it makes sense to detect them to spot undesired behaviours.

This revision adds a log in warn mode to capture the
attention of the developper.

Task: 4252800
setCellContent(model, "A1", "=MFILL(2,1,D1+1)");
setCellContent(model, "C1", "=MFILL(2,1,B1+1)");
expect(getEvaluatedCell(model, "A1").value).toBe(31);
expect(getEvaluatedCell(model, "B1").value).toBe(31);
expect(getEvaluatedCell(model, "C1").value).toBe(30);
expect(getEvaluatedCell(model, "D1").value).toBe(30);
expect(spy).toHaveBeenCalledWith("Maximum iteration rea ched while evaluating cells");
Copy link
Collaborator

@LucasLefevre LucasLefevre Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Suggested change
expect(spy).toHaveBeenCalledWith("Maximum iteration rea ched while evaluating cells");
expect(spy).toHaveBeenCalledWith("Maximum iteration reached while evaluating cells");

@LucasLefevre LucasLefevre force-pushed the 17.0-fix-array-recompute-deps-rar branch from 42c1983 to a7ab544 Compare November 15, 2024 09:38
@LucasLefevre
Copy link
Collaborator

robodoo r+

robodoo pushed a commit that referenced this pull request Nov 15, 2024
How to reproduce:
-> see the attached test

What is happening?
During the evaluation of SUMIFS, it will fetch its ranges.
First it will first fetch an empty range (E4:E7)  since MUNIT hasn't
been evaluated yet.
Afterwards, it will fetch H4, which in turn will request C4
and therefore force the evaluation of the spreaded function MUNIT.

AT this point, there is a disparity of values because the values
of the range (E4:E7) have changed.
To address those situations, the evaluator invalidates the dependencies
of all the spreaded zone. Which means marking A1 to be recomputed.

Unfortunately, A1 is still being evaluated and since #4589 (specifically
commit 8d22e86) we remove the cell from the queue after we evaluted it.

This revision changes the approach taken in 8d22e86 to allow
legitimate invalidations take place while avoiding useless
reevaluations.

Task: 4252800
Part-of: #5209
Signed-off-by: Lucas Lefèvre (lul) <[email protected]>
robodoo pushed a commit that referenced this pull request Nov 15, 2024
The evaluation of splillable function is complex and required some
bugfix over time. Some of the bugfixes have some side effects difficult
to assess and a specific one is the introduction of infinite in the
evaluation which are hidden behind a ceiling of iterations.

While infinite loops can occur in very specific cases, they are not
common and it makes sense to detect them to spot undesired behaviours.

This revision adds a log in warn mode to capture the
attention of the developper.

closes #5209

Task: 4252800
Signed-off-by: Lucas Lefèvre (lul) <[email protected]>
@robodoo robodoo closed this Nov 15, 2024
@fw-bot fw-bot deleted the 17.0-fix-array-recompute-deps-rar branch November 29, 2024 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants