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: Drop the usages of SupervisedGraphStageLogic to reduce allocation. #864

Merged
merged 1 commit into from
Dec 28, 2023

Conversation

He-Pin
Copy link
Member

@He-Pin He-Pin commented Dec 23, 2023

Motivation:
There is a allocation of Some in SupervisedGraphStageLogic and for performance reason, I want to remove that.
I can choose the Option[T] to OptionVal[T], but that will cause the problem if the user specified function return null.
So I choose to drop the usage of SupervisedGraphStageLogic.

Result:
Reduce allocation, but repeated code.

Status: Mima file is not added yet, open for discussion, and I think should remove the SupervisedGraphStageLogic too.

@He-Pin He-Pin marked this pull request as draft December 23, 2023 13:04
@laglangyue
Copy link
Contributor

I have reviewed some of your PRs, but due to my lack of familiarity with the project, I did not comment. But I noticed that there is a '=str' in the title all of them, and I don't quite understand what it means.

@He-Pin
Copy link
Member Author

He-Pin commented Dec 23, 2023

I have reviewed some of your PRs, but due to my lack of familiarity with the project, I did not comment. But I noticed that there is a '=str' in the title all of them, and I don't quite understand what it means.

I was using the old style, maybe chore nowadays ?

=means I added no api change, and str is abbr for stream module. BTW, I see you from China, are you in the wechat group ?

@He-Pin He-Pin marked this pull request as ready for review December 23, 2023 17:00
@mdedetrich
Copy link
Contributor

Im with @pjfanning here, I would rather drop this convention (i.e. =str) because no one else is doing it so it kind of defeats the point.

For me, simple git commit messages with active tense as well as making sure commits are atomic as possible is whats most important, i.e. general guidelines as from https://reflectoring.io/meaningful-commit-messages/

@mdedetrich
Copy link
Contributor

but that will cause the problem if the user specified function return null.

Is this a legitimate issue, I mean we can do behavioural changes if its well justified?

@He-Pin
Copy link
Member Author

He-Pin commented Dec 24, 2023

but that will cause the problem if the user specified function return null.

Is this a legitimate issue, I mean we can do behavioural changes if its well justified?

I think we can't, if I change to make use of OptionVal, then it will just ignore the value and do nothing, which was a Some(null) and throw an NPE.

and I will update the commit message then.eg perf:xxx

@He-Pin He-Pin changed the title =str Drop the usages of SupervisedGraphStageLogic to reduce allocation. perf: Drop the usages of SupervisedGraphStageLogic to reduce allocation. Dec 24, 2023
@He-Pin He-Pin force-pushed the SupervisedGraphStageLogicOpt branch from 6ce93e0 to 6d7c5f3 Compare December 24, 2023 06:03
@laglangyue
Copy link
Contributor

I was using the old style, maybe chore nowadays ?
=means I added no api change, and str is abbr for stream module. BTW, I see you from China, are you in the wechat group ?

yeah, I am in Hangzhou,Zhejiang, and I am newcommner for pekko/akka,I plan to introduce Pekko into my project in future.
it's my wechatId laglangyue, could you invite me to join the wechat group.
I am not picky about style, and just a simple question.

@He-Pin
Copy link
Member Author

He-Pin commented Dec 24, 2023

@laglangyue Are you using Pekko at work too, welcome and you are welcome to review this PR too.

@laglangyue
Copy link
Contributor

I don't have a deep understanding of akka/pekko, so I can't comment on this PR.

@laglangyue Are you using Pekko at work too, welcome and you are welcome to review this PR too.

Copy link
Member

@Roiocam Roiocam left a comment

Choose a reason for hiding this comment

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

My first thought is that this is a trade-off between abstraction and performance.

Too much duplicate code is not good to maintenance and code readability.

Considering that other Operators (such as Fold) in Ops also use inline instead of SupervisedGraphStageLogic, I will not be too picky about the duplicate code brought by this PR.

@He-Pin
Copy link
Member Author

He-Pin commented Dec 26, 2023

Thank you both from China Scala community to review this, I was plan to add onErrorReturn and OnErrorResume and OnErrorComplete operators, which need very handy control around the supervision.

@He-Pin He-Pin force-pushed the SupervisedGraphStageLogicOpt branch from 6d7c5f3 to 9370504 Compare December 27, 2023 04:05
@He-Pin He-Pin requested review from Roiocam and laglangyue December 27, 2023 04:15
@He-Pin
Copy link
Member Author

He-Pin commented Dec 28, 2023

@mdedetrich @pjfanning ping~

@mdedetrich
Copy link
Contributor

Too much duplicate code is not good to maintenance and code readability.

I wouldn't be surprised if the inliner (i.e. #857) will automatically do some of these performance improvements, unfortunately it would only work for Scala 2

Copy link
Contributor

@mdedetrich mdedetrich left a comment

Choose a reason for hiding this comment

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

lgtm

@He-Pin He-Pin merged commit 09023ce into apache:main Dec 28, 2023
18 checks passed
@He-Pin He-Pin deleted the SupervisedGraphStageLogicOpt branch December 28, 2023 07:56
@He-Pin He-Pin added this to the 1.2.0 milestone Dec 30, 2024
@He-Pin He-Pin added the t:stream Pekko Streams label Dec 30, 2024
@He-Pin He-Pin removed this from the 1.2.0 milestone Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t:stream Pekko Streams
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants