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

feat: Optimized mandatory attributes #31777

Merged
merged 5 commits into from
Dec 13, 2022

Conversation

johanandren
Copy link
Member

No description provided.

Copy link
Member

@patriknw patriknw left a comment

Choose a reason for hiding this comment

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

LGTM

this(attributeList, attributeList.foldLeft(Map.empty[Class[_], Attributes.MandatoryAttribute]) {
case (acc, attribute) =>
attribute match {
case m: Attributes.MandatoryAttribute if !acc.contains(m.getClass) => acc.updated(m.getClass, m)
Copy link
Member

Choose a reason for hiding this comment

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

is this the most efficient way to build the Map? Maybe it is because we have to use the first attribute in the list and then a MapBuilder can't be used?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, but I have thought about maybe just reverse building it instead with a builder, that way the right value "wins" and lists should anyway mostly be short in this constructor.

It is not super important though, because for the default set of attributes we now invoke this just once when the materializer is created, rather than on each stream materialization like earlier, and then the and-methods are used instead in actual attribute changes on the stream.

Copy link
Member Author

Choose a reason for hiding this comment

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

Rewrote it with a reversed iteration instead anyway, please take a second look.

Copy link
Member Author

Choose a reason for hiding this comment

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

Lol, already forgot I asked for a second look and merged. I'll do a follow up PR if you spot anything.

@patriknw
Copy link
Member

patriknw commented Dec 8, 2022

btw, shall we use the perf: prefix for these things rather than feat:?

@pvlugter
Copy link
Contributor

Looks like related test failures for LinearTraversalBuilderSpec.

@johanandren johanandren merged commit 37ac1b3 into akka:main Dec 13, 2022
@johanandren johanandren deleted the wip-mandatory-attrs-optimization branch December 13, 2022 14:18
@johanandren johanandren added this to the 2.8.0-M2 milestone Dec 13, 2022
johanandren added a commit to johanandren/akka that referenced this pull request Dec 13, 2022
Binary breaking changes, but very unlikely anyone is using those Scala 3
case class of 'Attributes'
ennru pushed a commit that referenced this pull request Dec 14, 2022
Binary breaking changes, but very unlikely anyone is using those Scala 3
case class of 'Attributes'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants