Skip to content

Conversation

LucasLefevre
Copy link
Collaborator

@LucasLefevre LucasLefevre commented Sep 23, 2025

Description:

performance measures: https://www.odoo.com/odoo/documents/d9dGIrjZRTSa9nf153wEIwo9e4c5

Task: 4936229

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 Sep 23, 2025

Pull request status dashboard

@LucasLefevre LucasLefevre force-pushed the master-compact-zone-rtree-lul branch 3 times, most recently from 5e04745 to 2f1fcaf Compare September 26, 2025 09:31
@LucasLefevre LucasLefevre force-pushed the master-compact-zone-rtree-lul branch 4 times, most recently from 7f3c8c5 to 33e3fdc Compare October 3, 2025 08:35
Comment on lines +187 to +201
const rTreeItems: RTreeItem<BoundedRange>[] = [];
for (const sheetId of this.getters.getSheetIds()) {
const cells = this.getters.getCells(sheetId);
for (const cellId in cells) {
const cell = cells[cellId];
if (cell.isFormula) {
const directDependencies = cell.compiledFormula.dependencies;
for (const range of directDependencies) {
if (range.invalidSheetName || range.invalidXc) {
continue;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

A lot more dégueulasse, but with way less array allocations

@LucasLefevre LucasLefevre force-pushed the master-compact-zone-rtree-lul branch 2 times, most recently from aac79fd to deb728a Compare October 6, 2025 12:55
@LucasLefevre LucasLefevre changed the title Master compact zone rtree lul [PERF] evaluation: zonify dependencies Oct 6, 2025
@LucasLefevre LucasLefevre force-pushed the master-compact-zone-rtree-lul branch 3 times, most recently from a559079 to 7b26fbd Compare October 10, 2025 14:09

insert(item: RTreeRangeItem) {
const data = this.rTree.search(item.boundingBox);
const exactBoundingBox = data.find((d) => deepEquals(d.boundingBox, item.boundingBox));
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe replace all deepEquals with a straight comparison since we know the structure of a boundingbox ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems worth it
https://jsperf.app/pifawe

@LucasLefevre LucasLefevre force-pushed the master-compact-zone-rtree-lul branch 2 times, most recently from 6421c4d to ebe5285 Compare October 21, 2025 09:04
This commit improves evaluation time from 5% to 20% on regular spreadsheet,
depending on the spreadsheet. And even from 99% on some pathological cases

Benchmark: https://www.odoo.com/odoo/documents/d9dGIrjZRTSa9nf153wEIwo9e4c5

Let’s say you have two formulas that depend on the same reference:

A1: =C1 
A2: =C1

In the FormulaDependencyGraph, both dependencies are added independently.
Specifically, the R-tree data structure ends up with two separate entries:
C1 -> A1 and C1 -> A2.

Ideally, the internal R-tree structure should group these dependencies into a
single node in the tree:

C1 -> [A1, A2] or even C1 -> [A1:A2] because they can be grouped into a single
zone.

When this pattern occurs frequently, the R-tree becomes huged (and unbalanced)
therefore sub-optimal.
- Huge: lots and lots of individual positions
- Unbalanced: this is common when using individual pivot formulas
(e.g., for spreadsheet pivots), where each PIVOT.VALUE formula depends on the
same range—the pivot dataset.

With this commit, the dependencies R-Tree maps bounding boxes to zones, instead
of bounding boxes to positions.
To take advantage of this grouping, the entire evaluation process now uses
zones as much as possible.

Task: 4936229
@rrahir rrahir force-pushed the master-compact-zone-rtree-lul branch from ebe5285 to c1b1527 Compare October 21, 2025 09:18
@LucasLefevre
Copy link
Collaborator Author

backported in 19.0 #7358

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