-
Notifications
You must be signed in to change notification settings - Fork 58
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
getOrCreateEditingContextEventProcessor hits the database on every invocation #3638
Comments
Bug: #3638 Signed-off-by: Pierre-Charles David <[email protected]>
I'm not sure we can avoid this, at least not as simply as what the current PR does. When deleting a project, Even though we publish a Note that the problem is more general than "just" This means that most interactions that seem inoccuous like clicking on an element in a diagram to get it's palette require (at least) one round trip to the database. |
Note that have two different (but partially redundant?) paths used to test if an editing context with a given id exists. Both are invoked in a simple interaction like clicking on the background of a diagram and both call to the DB (with different queries): One is in The second is in |
For this part of the problem, it might actually just be enough to add: this.editingContextEventProcessorRegistry.disposeEditingContextEventProcessor(input.projectId().toString()); in |
Bug: #3638 Signed-off-by: Pierre-Charles David <[email protected]>
See #3901 for MutationDeleteProjectDataFetcher cleanup. Otherwise, after discussion with @sbegaudeau we decided to keep the database lookup in place despite the potential performance hit as it ensures better consistency between the runtime data and the database, especially when mechanisms from e.g. #3897 are used. |
EditingContextEventProcessorRegistry#getOrCreateEditingContextEventProcessor
is invoked on every input to find (and create/load if necessary) the editing context event processor to dispatch the input to. It's on the critical path of almost every operation.Currently the first thing it does is to test:
before looking into the currently loaded event processors (
this.editingContextEventProcessors.get(editingContextId)
).The
existsById
call ends up inSemanticDataSearchService.existsByProject
, which will search into the database:This means we hit the DB at least once for every input. In the nominal case, we will only receive requests for already loaded editing context. Once a project is loaded, it will probably receive thousands of inputs before becoming inactive and being disposed.
On my machine where PostgreSQL is running locally, just this test costs about 7ms. It's probably more when the DB is on a remote host (though I have not measured).
Technically, changing the order of the test (look for an already loaded editing context in the fast patch) could change the semantics if the project has just been removed from the database and its editing context event processor not yet disposed/removed, thought I'm not even sure this can happen.
The text was updated successfully, but these errors were encountered: