-
Notifications
You must be signed in to change notification settings - Fork 18
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
Fix performance problem at login #464
Conversation
Will this be good enough for your production server for now, or do we need to investigate further at the moment? |
@@ -29,15 +29,15 @@ object Main extends App with LiveCore with KnoraService { | |||
//Kamon.start() | |||
|
|||
/* Check and wait until all actors are running */ | |||
checkActorSystem | |||
checkActorSystem() |
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.
Did you do that because the method has side-effects? http://docs.scala-lang.org/style/method-invocation.html
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.
Yes.
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.
IntelliJ pointed it out as a style recommendation.
|
||
val arglist = args.toList | ||
|
||
if (arglist.contains("loadDemoData")) StartupFlags.loadDemoData send true | ||
if (arglist.contains("allowResetTriplestoreContentOperationOverHTTP")) StartupFlags.allowResetTriplestoreContentOperationOverHTTP send true | ||
|
||
/* Start the HTTP layer, allowing access */ | ||
startService | ||
startService() |
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.
see above
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.
Yes.
groupInfo <- (responderManager ? GroupInfoByIRIGetRequest(groupIri, None)).mapTo[GroupInfoResponseV1] | ||
res = (groupInfo.group_info.belongsToProject, groupIri) | ||
} yield res | ||
Await.result(resFuture, 1.seconds) |
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.
Did that blocking Await
have any effect slowing down the application?
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.
Not as far as I could tell.
case response: ResourceContextResponseV1 => compareResourceCompoundContextResponses(received = response, expected = ResourcesResponderV1SpecContextData.expectedBookResourceContextResponse) | ||
case response: ResourceContextResponseV1 => | ||
val responseAsJson = response.toJsValue | ||
assert(responseAsJson == ResourcesResponderV1SpecContextData.expectedBookResourceContextResponse, "book context response did not match") |
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.
If I understand correctly, the correct ordering of the dependent pages (according to their seqnum
) is part of the query. So a 1:1 comparison is good.
I am just mentioning this because there are some tests in which the results have to be ordered according to the same pattern before they are compared (the ordering does not matter for the correctness of the results).
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 test always assumed that the order was fixed.
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.
Yes, that is absolutely correct. I justed wanted to make sure that this is what we want.
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.
I guess so, since the SPARQL query has:
ORDER BY ?seqnum ?sourceObject ?isPreview
Do you have any idea what could explain that the first login takes about three times longer than any subsequent one? |
I believe that the first login loads and caches data from the triplestore, which is reused in subsequent logins. |
Sounds reasonable. So why couldn't we load that data in the cache when the application is started? |
I guess we could. You'd have to ask @subotic, he wrote this code. |
Hey @subotic, could we cache data needed for authentication when webapi is started? |
In any case, I suspect that would require a non-trivial reworking of the code, so if we do it, it should be done in another pull request. Meanwhile, can we merge this one? |
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.
mörtsch
could you make an issue for the caching so we do not forget? thx. |
Opened #468. |
We probably could. This would require creating a |
I will move my last comment to the new issue. |
This fixes a performance problem caused by the use of
MessageUtil.toSource
in debugging output inProjectsResponderV1
. Also:app.triplestore.profile-queries
that outputs SPARQL queries and the amount of time they take.ResourcesResponderV1SpecContextData
to load the expected book context response from a file in JSON format, rather than including it in the source code, to keep IntelliJ IDEA from running out of memory when compiling it. This makes it easier to run a profiler in IntelliJ.Authenticator.authenticateCredentials()
(Creation of session id on login #290).Future.sequence
instead ofAwait.result
inPermissionsResponderV1.permissionsDataGetV1()
.Vector
andSeq
instead ofList
inPermissionsResponderV1
.FakeTriplestore
and into a utility class,FileUtil
.I'll document how to profile Knora in VisualVM using its IntelliJ IDEA plugin in another pull request.
Fixes #443.
Fixes #290.