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

finagle-memcached: -> 213 #827

Closed
wants to merge 5 commits into from

Conversation

martijnhoekstra
Copy link
Contributor

Problem

no 2.13 for finagle-memcached

Solution

upgrade. Replace javaClientBase.java with equivalent .scala so that the type aliases of collection compat scala.jdk.CollectionConverters._ can be picked up.

Result

a 2.13 build

@martijnhoekstra
Copy link
Contributor Author

I get the same errors with this branch as I get on develop on Windows. I haven't tested on a different platform if these errors are real, I'm assuming they're not.

@martijnhoekstra martijnhoekstra changed the title convert 213 finagle-memcached: -> 213 Jan 29, 2020
@martijnhoekstra
Copy link
Contributor Author

martijnhoekstra commented Jan 29, 2020

Threw in finagle-benchmark as it's just a build change.

@felixbr
Copy link
Contributor

felixbr commented Jan 29, 2020

I looked at the travis-ci errors and all failed build jobs seem to fail during download of sbt-launch.jar

downloading /home/travis/build/twitter/finagle/sbt-launch.jar

The command "./sbt --error ++2.12.8 ci:update finagle-memcached/update" failed 3 times.

I cannot see any particular pattern regarding jdk or scala version and the sbt version should always be 1.2.8 if I see this correctly.

@martijnhoekstra
Copy link
Contributor Author

Yeah, the sbt download seems flaky. This is not the first time tests fail on that.

Copy link
Contributor

@bryce-anderson bryce-anderson left a comment

Choose a reason for hiding this comment

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

I haven't gotten really deep into this but I feel we're going to hit a non-trivial performance regression when dropping the breakOut usages in preference of .toMap and friends. From my reading it looks like 2.13 supports this via Views but they're probably only going to work for 2.13.
One way forward is to just reimplement what breakOut does. Since these use cases all have similar needs, specifically map to this new collection type, could we achieve the same result with a few helper methods?

@martijnhoekstra
Copy link
Contributor Author

martijnhoekstra commented Feb 6, 2020

For the breakout ones, we can go through an Iterator, which should avoid intermediary collection construction.

For the mapValues ones, we can use transform instead, but there is still a potential performance hazard there. That should be fixed when scala/scala#8630 lands in 2.12, but still may be slow in 2.11.

2.12.11 is expected soon(tm) scala/scala-dev#664 -- but of course, end users need to have that running too.

Copy link
Contributor

@yufangong yufangong left a comment

Choose a reason for hiding this comment

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

This looks good to me except Bryce's comments. I did source integration tests and this change passed. I think once we have util, scrooge, finagle, finatra, and twitter-server all cross-building 2.13 we will drop 2.11 support, so I won't be too worry about 2.11 perf.

@martijnhoekstra martijnhoekstra mentioned this pull request Feb 9, 2020
28 tasks
@@ -822,7 +823,7 @@ protected class ConnectedClient(protected val service: Service[Command, Response
def stats(args: Option[String]): Future[Seq[String]] = {
val statArgs: Seq[Buf] = args match {
case None => Seq(Buf.Empty)
case Some(args) => args.split(" ").map(nonEmptyStringToBuf)(breakOut)
case Some(args) => args.split(" ").map(nonEmptyStringToBuf).toSeq
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this also benefit from a .iterator call?

@@ -59,7 +58,7 @@ trait TwemcacheConnectedClient extends TwemcacheClient { self: ConnectedClient =
def getvResult(keys: Iterable[String]): Future[GetsResult] = {
try {
if (keys == null) throw new IllegalArgumentException("Invalid keys: keys cannot be null")
val bufs = keys.map { Buf.Utf8(_) }(breakOut)
val bufs = keys.map { Buf.Utf8(_) }.toSeq
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need a .iterator call?

@@ -44,7 +44,7 @@ object ParserUtils {
segmentStart = segmentEnd + 1
}
}
split
split.toIndexedSeq
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this going to spit out a Vector? If so, that would be pretty bad.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. I pushed an approach in a separate commit that just toSeq's this and changes the return type to Seq (which then propagates forward a bit). I don't see any immediate performance hazards for that.

@hamdiallam
Copy link
Contributor

Merged! 7acd423

@hamdiallam hamdiallam closed this Feb 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

5 participants