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

[PERF] evaluation: faster spreading invalidation #4203

Closed
wants to merge 1 commit into from

Conversation

LucasLefevre
Copy link
Collaborator

@LucasLefevre LucasLefevre commented May 13, 2024

Description:

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

Task: : 3925565

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 May 13, 2024

@LucasLefevre LucasLefevre force-pushed the master-faster-invalidate-spread-lul branch from 129c140 to e3bf587 Compare May 13, 2024 13:58
@laa-odoo
Copy link
Collaborator

ok IMO
@anhe-odoo what do you think ?
It allows to divide the computation time of invalidateSpreading by 10

@LucasLefevre LucasLefevre changed the title m [PERF] evaluation: faster spreading invalidation May 13, 2024
@LucasLefevre LucasLefevre force-pushed the master-faster-invalidate-spread-lul branch 4 times, most recently from 7dd07f8 to 11ec7e7 Compare May 14, 2024 06:16
@LucasLefevre LucasLefevre changed the base branch from master to saas-17.2 May 14, 2024 06:17
@LucasLefevre LucasLefevre force-pushed the master-faster-invalidate-spread-lul branch from 11ec7e7 to 8005562 Compare May 14, 2024 06:20
Copy link
Contributor

@anhe-odoo anhe-odoo left a comment

Choose a reason for hiding this comment

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

@laa-odoo @LucasLefevre : two small comments but else LGTM :) Nice improvement !

const arrayFormulaPosition = this.getArrayFormulaSpreadingOn(position);
if (arrayFormulaPosition) {
// ignore the formula spreading on the position. Keep only the blocked ones
arrayFormulaPositions.delete(arrayFormulaPosition);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can remove it directly from arrayFormulas instead of adding it in arrayFormulaPositions and then remove it from the same set ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Problem is that arrayFormulas is typed as Iterable<CellPosition> (which I think is a good think because it makes it decoupled from the internal implementation). So we can't just remove a position from it.

src/plugins/ui_core_views/cell_evaluation/evaluator.ts Outdated Show resolved Hide resolved
Since 0467161 `getCellsDependingOn` is much faster but has a higher
fixed cost overhead because it instanciates a `BinaryGrid`. It is very
fast to use but a bit costly to create (it creates a 2d array proporional
to the size of sheets). If you do it 10k times, it starts to add up...

In `invalidateSpreading`, `getCellsDependingOn` was called once for each
child position (which can be a lot if the formula spreads on a lot of cells).
With this commit, it's called only once, with all positions batched.

For the same reason, `getArrayFormulasBlockedBy` is also batched in this
commit.

The speed improvement spent in `invalidateSpreading` is ~10x faster.

Task: 3925565
@LucasLefevre LucasLefevre force-pushed the master-faster-invalidate-spread-lul branch from 8005562 to 8f29eeb Compare May 14, 2024 07:31
@rrahir
Copy link
Collaborator

rrahir commented May 14, 2024

@robodoo r+

robodoo pushed a commit that referenced this pull request May 14, 2024
Since 0467161 `getCellsDependingOn` is much faster but has a higher
fixed cost overhead because it instanciates a `BinaryGrid`. It is very
fast to use but a bit costly to create (it creates a 2d array proporional
to the size of sheets). If you do it 10k times, it starts to add up...

In `invalidateSpreading`, `getCellsDependingOn` was called once for each
child position (which can be a lot if the formula spreads on a lot of cells).
With this commit, it's called only once, with all positions batched.

For the same reason, `getArrayFormulasBlockedBy` is also batched in this
commit.

The speed improvement spent in `invalidateSpreading` is ~10x faster.

closes #4203

Task: 3925565
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
@robodoo robodoo closed this May 14, 2024
@fw-bot fw-bot deleted the master-faster-invalidate-spread-lul branch May 28, 2024 12:46
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.

None yet

5 participants