Skip to content

Conversation

@ben-schwen
Copy link
Member

@ben-schwen ben-schwen commented Jan 15, 2026

Towards #7594

Implements case 1) of outer transformations as e.g. sqrt(min(a)) and mean(x)^2

The GForce rewrite made this a charm 😃

@ben-schwen ben-schwen added the GForce issues relating to optimized grouping calculations (GForce) label Jan 15, 2026
# Outer transformations that can wrap GForce-optimizable expressions
# e.g., sqrt(min(x)) should be optimized to sqrt(gmin(x))
# for the moment we only include unary functions
.gforce_outer_trans = c("sqrt", "abs", "sign", "floor", "ceiling",
Copy link
Member

Choose a reason for hiding this comment

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

what goes wrong if we just let any generic foo() through here? As long as the "innermost" function is GForce-able

Copy link
Member Author

Choose a reason for hiding this comment

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

Things like min(min(x)) should already be quite problematic...

Copy link
Member Author

Choose a reason for hiding this comment

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

Our own test suite dislikes e.g. .Internal(mean(x))

test(2363.03, optimize=1:2, dt[, sqrt(abs(min(y))), by=x, verbose=TRUE], output=out)
test(2363.04, optimize=1:2, dt[, sqrt(min(y)) + 1, by=x, verbose=TRUE], output=out)
test(2363.05, optimize=1:2, dt[, floor(mean(y)), by=x, verbose=TRUE], output=out)
# Transformation around non-GForce expression should NOT optimize
Copy link
Member

Choose a reason for hiding this comment

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

add one for nesting non-GForce calls too

@github-actions
Copy link

github-actions bot commented Jan 15, 2026

No obvious timing issues in HEAD=gforce_outer_transformations
Comparison Plot

Generated via commit b40b684

Download link for the artifact containing the test results: ↓ atime-results.zip

Task Duration
R setup and installing dependencies 3 minutes and 2 seconds
Installing different package versions 22 seconds
Running and plotting the test cases 4 minutes and 4 seconds

@codecov
Copy link

codecov bot commented Jan 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.00%. Comparing base (0216983) to head (b40b684).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7600   +/-   ##
=======================================
  Coverage   99.00%   99.00%           
=======================================
  Files          87       87           
  Lines       16893    16893           
=======================================
  Hits        16725    16725           
  Misses        168      168           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

"cos", "sin", "tan", "acos", "asin", "atan",
"cosh", "sinh", "tanh", "acosh", "asinh", "atanh",
"is.na", "is.nan", "is.finite", "is.infinite")

Copy link
Contributor

Choose a reason for hiding this comment

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

Hello:
By setdiff(methods::getGroupMembers("Math"), .gforce_outer_trans) you can add:

"trunc" "cummax" "cummin" "cumprod" "cumsum"
"cospi" "sinpi" "tanpi"
"gamma" "lgamma" "digamma" "trigamma"

Note "log" can take "base = ..." as first argument. trunc can take ... also.

Copy link
Member Author

Choose a reason for hiding this comment

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

The cumulative functions won't work. Maybe unary functions was too unprecise. I have added an "elementwise".

Binary functions will optimize as long ppl provide constantish parameters and not variables for the parameters, e.g. log(min(x), 2) works while t<-2; log(min(x), 2) does not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GForce issues relating to optimized grouping calculations (GForce)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants