Skip to content

Conversation

@libenchao
Copy link
Member

…tation for blink planner

What is the purpose of the change

Fix blink planner code generation exceeds 64k java method limitation.

Brief change log

  • Add isSplit field in CodeGeneratorContext
  • Split expressions when exceeds threshold in ExprCodeGenerator
  • Use reuseableLocalVariable in GeneratedExpression.deepCopy

Verifying this change

This change added tests and can be verified as follows:

  • CalcITCase. testLongProjectionList

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): (yes / no)
  • The public API, i.e., is any changed class annotated with @Public(Evolving): (yes / no)
  • The serializers: (yes / no / don't know)
  • The runtime per-record code paths (performance sensitive): (yes / no / don't know)
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Yarn/Mesos, ZooKeeper: (yes / no / don't know)
  • The S3 file system connector: (yes / no / don't know)

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)

@flinkbot
Copy link
Collaborator

flinkbot commented Jan 1, 2020

Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
to review your pull request. We will use this comment to track the progress of the review.

Automated Checks

Last check on commit fdd8856 (Wed Jan 01 15:59:34 UTC 2020)

Warnings:

  • No documentation files were touched! Remember to keep the Flink docs up to date!

Mention the bot in a comment to re-run the automated checks.

Review Progress

  • ❓ 1. The [description] looks good.
  • ❓ 2. There is [consensus] that the contribution should go into to Flink.
  • ❓ 3. Needs [attention] from.
  • ❓ 4. The change fits into the overall [architecture].
  • ❓ 5. Overall code [quality] is good.

Please see the Pull Request Review Guide for a full explanation of the review process.

Details
The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required Bot commands
The @flinkbot bot supports the following commands:

  • @flinkbot approve description to approve one or more aspects (aspects: description, consensus, architecture and quality)
  • @flinkbot approve all to approve all aspects
  • @flinkbot approve-until architecture to approve everything until architecture
  • @flinkbot attention @username1 [@username2 ..] to require somebody's attention
  • @flinkbot disapprove architecture to remove an approval you gave earlier

@flinkbot
Copy link
Collaborator

flinkbot commented Jan 1, 2020

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run travis re-run the last Travis build
  • @flinkbot run azure re-run the last Azure build

@libenchao libenchao changed the title [FLINK-15430][table-planner-blink] Fix Java 64K method compiling limi… [WIP][FLINK-15430][table-planner-blink] Fix Java 64K method compiling limi… Jan 2, 2020
@libenchao
Copy link
Member Author

@flinkbot run travis

@libenchao libenchao changed the title [WIP][FLINK-15430][table-planner-blink] Fix Java 64K method compiling limi… [FLINK-15430][table-planner-blink] Fix Java 64K method compiling limi… Jan 2, 2020
@wuchong
Copy link
Member

wuchong commented Jan 2, 2020

cc @JingsongLi

Copy link
Contributor

@JingsongLi JingsongLi left a comment

Choose a reason for hiding this comment

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

Thanks @libenchao , left two thought:

  • Can we just copy codes from legacy planner? It seems that there are some corner cases in CodeGenerator.makeReusableInSplits.
  • If we just have some codes like boolean $myNullTerm = ..., will lead to compile exception after code splitting?

@libenchao
Copy link
Member Author

@JingsongLi Thanks for the review.

  1. I'll try to align the behavior with old planner, and give you feedback after that.
  2. Yes. I also realized that, and fixed all places I found for now. However, this can only happen when the Expression is longer than TableConfig.maxGeneratedCodeLength.

@libenchao
Copy link
Member Author

@JingsongLi @wuchong I go over the implementation again, and find that it indeed has many corner cases.

  • I changed TableConfig.maxGeneratedCodeLength to 1, and run all the tests in blink planner, 762/6117 tests failed.
  • For comparison, I did the same thing to old planner, and found 21/2321 tests failed.

So, it's indeed not easy to do code split currently. And I propose to narrow down the scope of this simple fix, which just targets long projection list. Then we can just focus on CalcCodeGenerator and add a param allowSplit to ExprCodeGenerator.generateResultExpression.
What's your opinion?

@JingsongLi
Copy link
Contributor

@libenchao Thanks for you updating.

I changed TableConfig.maxGeneratedCodeLength to 1, and run all the tests in blink planner

Good job!

narrow down the scope of this simple fix, which just targets long projection list

+1

val methodName = newName("split")
val method =
s"""
|private void $methodName() throw Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

throws

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the review, fixed.

@JingsongLi
Copy link
Contributor

This temporary fixing looks good to me. Now we limit this fixing to the Calc only. It's not a perfect solution. But it does solve the problem.

@wuchong @KurtYoung What do you think?

Copy link
Member

@wuchong wuchong left a comment

Choose a reason for hiding this comment

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

Thanks @libenchao @JingsongLi . I'm fine with current temporary solution.

I only left a minor comment about the method naming.

/**
* Flag indicating whether split has occurred.
*/
private var isSplit = false
Copy link
Member

Choose a reason for hiding this comment

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

Rename the variable to isCodeSplit to make it clear that the code is splitted?
The comment can also be improved Flag that indicates whether the generated code is split into several methods.

reusableLocalVariableStatements(methodName) = mutable.LinkedHashSet[String]()
}

def setSplit(): Unit = {
Copy link
Member

Choose a reason for hiding this comment

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

enableCodeSplit() or setCodeSplit()? Please also add Javadoc above this method.

@libenchao
Copy link
Member Author

@wuchong Thanks for the review. I've updated the code.

Copy link
Member

@wuchong wuchong left a comment

Choose a reason for hiding this comment

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

LGTM.

@wuchong wuchong merged commit 744ba5d into apache:master Jan 6, 2020
wuchong pushed a commit that referenced this pull request Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants