Skip to content

Conversation

@raunaqmorarka
Copy link
Member

Description

Avoid constructing new PageProjectionWork object per page

Additional context and related issues

Release notes

(x) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text:

## Section
* Fix some things. ({issue}`issuenumber`)

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR simplifies the compiled page projection by avoiding the construction of new PageProjectionWork objects per page. Instead of using a factory method handle to create instances, it now reuses a single PageProjectionWork instance and passes parameters directly to the process method.

  • Modified PageProjectionWork interface to accept parameters directly in the process method
  • Changed GeneratedPageProjection to store and reuse a single PageProjectionWork instance
  • Updated the code generation to pass block fields and parameters directly rather than storing them as instance fields

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
PageProjectionWork.java Updated interface to accept parameters directly in process method
PageFunctionCompiler.java Modified code generation to create reusable PageProjectionWork instances and pass parameters directly
GeneratedPageProjection.java Simplified to store and reuse a single PageProjectionWork instance instead of using factory method handles

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@wendigo
Copy link
Contributor

wendigo commented Sep 2, 2025

Do you have benchmarks?

@raunaqmorarka
Copy link
Member Author

Do you have benchmarks?

I'm not expected much gain, its mainly to simplify the code

@wendigo
Copy link
Contributor

wendigo commented Sep 2, 2025

Error:    TestArrayFunctions.testArrayConstructor:62 » QueryFailed Failed to execute query; there may be too many columns used or expressions are too complex

@raunaqmorarka
Copy link
Member Author

Error:    TestArrayFunctions.testArrayConstructor:62 » QueryFailed Failed to execute query; there may be too many columns used or expressions are too complex

Seems the max parameters allowed came down slightly just because of using a method parameter instead of class field to pass an argument. Fixed that now by avoiding that change

Copy link
Member

@lukasz-stec lukasz-stec left a comment

Choose a reason for hiding this comment

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

lgtm

Avoid constructing new PageProjectionWork object per page
@raunaqmorarka raunaqmorarka merged commit 0fa04ac into trinodb:master Sep 2, 2025
88 of 95 checks passed
@raunaqmorarka raunaqmorarka deleted the page-compiler-simplify branch September 2, 2025 18:58
@github-actions github-actions bot added this to the 477 milestone Sep 2, 2025
Variable to = scope.declareVariable("to", body, add(thisVariable.getField(selectedPositions).invoke("getOffset", int.class), thisVariable.getField(selectedPositions).invoke("size", int.class)));
for (int i = 0; i < inputChannels.size(); i++) {
int channel = inputChannels.get(i);
body.append(thisVariable.setField(blockFields.get(i), page.invoke("getBlock", Block.class, constantInt(channel))));
Copy link
Member

Choose a reason for hiding this comment

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

Looks like those fields are never cleared, so between executions, the last used blocks will be referenced here and thus non-eligible for GC

Copy link
Member Author

Choose a reason for hiding this comment

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

right, i was thinking that the PageProjection instance itself would go out of scope once the operator is done.
but on 2nd thought, operators can be blocked, how about we add a clear method to PageProjectionWork which nullifies the blocks ?

Copy link
Member Author

Choose a reason for hiding this comment

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

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

Development

Successfully merging this pull request may close these issues.

3 participants