Skip to content

[PERF] evaluation: args definitions at compile time#8806

Open
LucasLefevre wants to merge 6 commits into
masterfrom
master-args-at-compile-time-lul
Open

[PERF] evaluation: args definitions at compile time#8806
LucasLefevre wants to merge 6 commits into
masterfrom
master-args-at-compile-time-lul

Conversation

@LucasLefevre
Copy link
Copy Markdown
Collaborator

Description:

A number of checks and pre/post processing is done for each executed
function.
Some of it can be known at compile time since it only depends on the
function and the number of arguments.

With this commit, we pre-compute a number of things only once at compile
time to minimize what is done when executing the function.

Bunch report

cells imported in
09ccc24: Mean: 2841.65 ms, StdErr: 3.91 ms
c0ed960: Mean: 2758.60 ms, StdErr: 6.32 ms → 🟢 (vs prev: -3%, Δ=-83.05 ms, combined StdErr=7.43 ms, |Δ|/SE=-11.2x; n=20)

evaluate all cells
09ccc24: Mean: 2678.65 ms, StdErr: 8.38 ms
c0ed960: Mean: 2458.64 ms, StdErr: 11.72 ms → 🟢 (vs prev: -8%, Δ=-220.02 ms, combined StdErr=14.41 ms, |Δ|/SE=-15.3x; n=20)

Model created in
09ccc24: Mean: 6470.76 ms, StdErr: 9.44 ms
c0ed960: Mean: 6158.89 ms, StdErr: 14.90 ms → 🟢 (vs prev: -5%, Δ=-311.87 ms, combined StdErr=17.64 ms, |Δ|/SE=-17.7x; n=20)

Large formula dataset

cells imported in
09ccc24: Mean: 2703.84 ms, StdErr: 14.52 ms
c0ed960: Mean: 2704.29 ms, StdErr: 14.18 ms → ⚫ (vs prev: +0%, Δ=+0.45 ms, combined StdErr=20.30 ms, |Δ|/SE=0.0x; n=20)

evaluate all cells
09ccc24: Mean: 400.51 ms, StdErr: 2.94 ms
c0ed960: Mean: 375.49 ms, StdErr: 2.43 ms → 🟢 (vs prev: -6%, Δ=-25.02 ms, combined StdErr=3.81 ms, |Δ|/SE=-6.6x; n=20)

Model created in
09ccc24: Mean: 3441.85 ms, StdErr: 14.57 ms
c0ed960: Mean: 3419.21 ms, StdErr: 14.61 ms → ⚫ (vs prev: -1%, Δ=-22.64 ms, combined StdErr=20.63 ms, |Δ|/SE=-1.1x; n=20)

Other production spreadsheet (heavily vectorized)

⚫ no measureable change anywhere

Yet another production spreadsheet (with some vectorization)

cells imported in
09ccc24: Mean: 491.04 ms, StdErr: 6.53 ms
c0ed960: Mean: 493.73 ms, StdErr: 4.17 ms → ⚫ (vs prev: +1%, Δ=+2.69 ms, combined StdErr=7.75 ms, |Δ|/SE=0.3x; n=20)

evaluate all cells
09ccc24: Mean: 660.53 ms, StdErr: 3.85 ms
c0ed960: Mean: 633.88 ms, StdErr: 3.46 ms → 🟢 (vs prev: -4%, Δ=-26.65 ms, combined StdErr=5.18 ms, |Δ|/SE=-5.1x; n=20)

Model created in
09ccc24: Mean: 1423.05 ms, StdErr: 9.20 ms
c0ed960: Mean: 1396.71 ms, StdErr: 7.02 ms → 🟢 (vs prev: -2%, Δ=-26.33 ms, combined StdErr=11.57 ms, |Δ|/SE=-2.3x; n=20)

Legend:
⚫: no measurable change |Δ|/SE < 2
🔴: slower Δ > 0 and |Δ|/SE >= 2
🟢: faster Δ < 0 and |Δ|/SE >= 2

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
Copy Markdown
Collaborator

robodoo commented May 28, 2026

Pull request status dashboard

@LucasLefevre LucasLefevre force-pushed the master-args-at-compile-time-lul branch from b7f0257 to 95e1ccc Compare May 28, 2026 11:54
@LucasLefevre LucasLefevre changed the title Master args at compile time lul [PERF] evaluation: args definitions at compile time May 28, 2026
@LucasLefevre LucasLefevre force-pushed the master-args-at-compile-time-lul branch 2 times, most recently from 067c316 to 0af8d01 Compare May 28, 2026 12:32
@laa-odoo laa-odoo force-pushed the master-args-at-compile-time-lul branch from 2d5b0b2 to dee5190 Compare May 28, 2026 15:52
@LucasLefevre LucasLefevre force-pushed the master-args-at-compile-time-lul branch from dee5190 to 38b4a91 Compare May 28, 2026 15:56
@laa-odoo laa-odoo force-pushed the master-args-at-compile-time-lul branch 5 times, most recently from 67ed857 to 0bf4d40 Compare June 2, 2026 13:15
@LucasLefevre LucasLefevre force-pushed the master-args-at-compile-time-lul branch from 0bf4d40 to 38b4a91 Compare June 2, 2026 13:55
@laa-odoo laa-odoo force-pushed the master-args-at-compile-time-lul branch from 38b4a91 to 4175a73 Compare June 2, 2026 14:09
Comment thread src/formulas/code_builder.ts Outdated
Comment thread src/formulas/compiler.ts Outdated
Comment thread src/formulas/compiler.ts Outdated
Comment thread src/types/functions.ts Outdated
Comment thread src/types/functions.ts Outdated
@laa-odoo laa-odoo force-pushed the master-args-at-compile-time-lul branch from 0fa9ce0 to 593c0e4 Compare June 4, 2026 08:44
@laa-odoo
Copy link
Copy Markdown
Collaborator

laa-odoo commented Jun 4, 2026

Review taken into account,
thanks @LucasLefevre

laa-odoo and others added 5 commits June 4, 2026 10:47
A number of checks and pre/post processing is done for each executed
function.
Some of it can be known at compile time since it only depends on the
function and the number of arguments.

With this commit, we pre-compute a number of things only once at compile
time to minimize what is done when executing the function.

Bunch report
------------

cells imported in
  09ccc24:  Mean: 2841.65 ms, StdErr: 3.91 ms
  c0ed960:  Mean: 2758.60 ms, StdErr: 6.32 ms → 🟢 (vs prev: -3%, Δ=-83.05 ms, combined StdErr=7.43 ms, |Δ|/SE=-11.2x; n=20)

evaluate all cells
  09ccc24:  Mean: 2678.65 ms, StdErr: 8.38 ms
  c0ed960:  Mean: 2458.64 ms, StdErr: 11.72 ms → 🟢 (vs prev: -8%, Δ=-220.02 ms, combined StdErr=14.41 ms, |Δ|/SE=-15.3x; n=20)

Model created in
  09ccc24:  Mean: 6470.76 ms, StdErr: 9.44 ms
  c0ed960:  Mean: 6158.89 ms, StdErr: 14.90 ms → 🟢 (vs prev: -5%, Δ=-311.87 ms, combined StdErr=17.64 ms, |Δ|/SE=-17.7x; n=20)

Large formula dataset
---------------------

cells imported in
  09ccc24:  Mean: 2703.84 ms, StdErr: 14.52 ms
  c0ed960:  Mean: 2704.29 ms, StdErr: 14.18 ms → ⚫ (vs prev: +0%, Δ=+0.45 ms, combined StdErr=20.30 ms, |Δ|/SE=0.0x; n=20)

evaluate all cells
  09ccc24:  Mean: 400.51 ms, StdErr: 2.94 ms
  c0ed960:  Mean: 375.49 ms, StdErr: 2.43 ms → 🟢 (vs prev: -6%, Δ=-25.02 ms, combined StdErr=3.81 ms, |Δ|/SE=-6.6x; n=20)

Model created in
  09ccc24:  Mean: 3441.85 ms, StdErr: 14.57 ms
  c0ed960:  Mean: 3419.21 ms, StdErr: 14.61 ms → ⚫ (vs prev: -1%, Δ=-22.64 ms, combined StdErr=20.63 ms, |Δ|/SE=-1.1x; n=20)

Other production spreadsheet (heavily vectorized)
-------------------------------------------------

⚫ no measureable change anywhere

Yet another production spreadsheet (with some vectorization)
------------------------------------------------------------

cells imported in
  09ccc24:  Mean: 491.04 ms, StdErr: 6.53 ms
  c0ed960:  Mean: 493.73 ms, StdErr: 4.17 ms → ⚫ (vs prev: +1%, Δ=+2.69 ms, combined StdErr=7.75 ms, |Δ|/SE=0.3x; n=20)

evaluate all cells
  09ccc24:  Mean: 660.53 ms, StdErr: 3.85 ms
  c0ed960:  Mean: 633.88 ms, StdErr: 3.46 ms → 🟢 (vs prev: -4%, Δ=-26.65 ms, combined StdErr=5.18 ms, |Δ|/SE=-5.1x; n=20)

Model created in
  09ccc24:  Mean: 1423.05 ms, StdErr: 9.20 ms
  c0ed960:  Mean: 1396.71 ms, StdErr: 7.02 ms → 🟢 (vs prev: -2%, Δ=-26.33 ms, combined StdErr=11.57 ms, |Δ|/SE=-2.3x; n=20)

Legend:
  ⚫: no measurable change |Δ|/SE < 2
  🔴: slower Δ > 0 and |Δ|/SE >= 2
  🟢: faster Δ < 0 and |Δ|/SE >= 2

Task: 6254300
Remove the layer that was adapting the return value
of the compute formula by directly creating the values
object within each compute function definition.

This simplifies typing by reducing the number of
different return cases that needed to be handled in
the compute functions.

Task: 6254300
Introduce a type-level distinction between formulas that
return a scalar value and formulas that return an array.
Previously, all formulas shared the same return type
signature, making it impossible to enforce correct
usage at compile time.

This distinction will help in future commits to know,
at compile time, what can be vectorized and what cannot.

Task: 6254300
It is no longer necessary to check at each compute function
whether vectorization is required.
Now, the compilation tells us whether a formula needs to be
vectorized or not.

Task: 6254300
@laa-odoo laa-odoo force-pushed the master-args-at-compile-time-lul branch from 593c0e4 to 821c700 Compare June 4, 2026 08:51
…ized args

Instead of storing a boolean array where each index indicates whether
an argument should be vectorized, store only the indices of arguments
that need vectorization. This avoids iterating over all arguments and
directly targets only the relevant ones.

Task: 6254300
@laa-odoo laa-odoo force-pushed the master-args-at-compile-time-lul branch from 821c700 to 28808d6 Compare June 4, 2026 14:19
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