-
Notifications
You must be signed in to change notification settings - Fork 21
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
More efficient database unmarshaling #775
Conversation
|
||
val workbenchUtilV = "0.3-0e9d080" | ||
val workbenchUtilV = "0.5-6942040" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upgraded workbenchUtil to not pull in an older version of cats.
@@ -97,7 +97,7 @@ class HttpGoogleDataprocDAO(appName: String, | |||
override def getClusterStatus(googleProject: GoogleProject, clusterName: ClusterName): Future[ClusterStatus] = { | |||
val transformed = for { | |||
cluster <- OptionT(getCluster(googleProject, clusterName)) | |||
status <- OptionT.pure[Future, ClusterStatus]( | |||
status <- OptionT.pure[Future]( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cats API change - OptionT
no longer takes the second type parameter. Otherwise it's equivalent.
(googleProjectDAO.isProjectActive(googleProject.value) |@| googleProjectDAO.isBillingActive(googleProject.value)) | ||
.map(_ && _) | ||
(googleProjectDAO.isProjectActive(googleProject.value), googleProjectDAO.isBillingActive(googleProject.value)) | ||
.mapN(_ && _) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This style is deprecated in cats:
(a |@| b).map(...)
They now recommend:
(a, b).mapN(...)
val errorList = errorRecordOpt.toList | ||
val extList = extensionOpt.toList | ||
val clusterImageList = clusterImageOpt.toList | ||
val scopeList = scopeOpt.toList | ||
Map(clusterRecord -> (instanceList, errorList, labelMap, extList, clusterImageList, scopeList)) | ||
Map(clusterRecord -> (Chain.fromSeq(instanceList), Chain.fromSeq(errorList), labelMap, Chain.fromSeq(extList), Chain.fromSeq(clusterImageList), Chain.fromSeq(scopeList))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's where I'm using Chain
, inside the foldMap
. Hopefully this is more efficient than ListMonoid
. See:
https://typelevel.org/cats/datatypes/chain.html
https://typelevel.org/blog/2018/09/04/chain-replacing-the-list-monoid.html
typelevel/cats#2429
fiab-start failed. jenkins retest |
Cats still isn't happy. From auto tests:
Will investigate. EDIT: probably need to update |
* More efficient database unmarshaling * Update workbenchGoogle to the latest
* More efficient database unmarshaling * Update workbenchGoogle to the latest
* More efficient database unmarshaling * Update workbenchGoogle to the latest
I'm on-call and saw several Leo high CPU alerts on 2/12. I looked at some thread dumps and saw multiple threads here:
A couple things stand out:
ClusterComponent.getActiveClusterByName
. This method is called in 2 places:LeonardoService
methods (create, get, update, delete)ClusterDnsCache
when it repopulates the cache (I suspect in practice it's mostly coming from here).ListMonoid
. Scala lists are notoriously inefficient for everything except prepending.So I made the following changes:
ClusterDnsCache
no longer calls the expensivegetActiveClusterByName
because it doesn't need all the extra join information. I added a new methodgetActiveClusterForDnsCache
which doesn't do any joins.List
toChain
where we are using the list monoid (note to do this I had to upgrade cats). Chain is supposedly much more efficient, though I haven't verified it. See:Unit tests pass, will verify automation tests.
Have you read CONTRIBUTING.md lately? If not, do that first.
I, the developer opening this PR, do solemnly pinky swear that:
In all cases: