-
Notifications
You must be signed in to change notification settings - Fork 162
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
Optimize SaveEventDelegate#preSaveCheck by removing if possible the recursion #854
Comments
Something like that
|
Apparently the |
Nope, definitiv not. But I like the idea and the delegate class needed some love anyway. While technical, the both the following approaches are DFS:
you can see how the order differs a tiny bit.
I have a solution and the main point to it are two changes, which I write down in the PR. |
michael-simons
added a commit
that referenced
this issue
Oct 26, 2020
This change avoids the recursive depth first iteration of nodes when visiting and testing them if we should fire a pre-save event. To make this work, dirty must be fixed in two places: - Checking for relationship entities trigges an ID creation to early (compare GH-831, 1805999) - we must ensure that we check only for existing previous relationships that are actually touched by the object whos dirtyness is checked Furthermore, the change avoids a lot of checks for the native id of the changed object and treats collections now correctly. This closes #854.
michael-simons
added a commit
that referenced
this issue
Oct 29, 2020
This change avoids the recursive depth first iteration of nodes when visiting and testing them if we should fire a pre-save event. To make this work, dirty must be fixed in two places: - Checking for relationship entities trigges an ID creation to early (compare GH-831, 1805999) - we must ensure that we check only for existing previous relationships that are actually touched by the object whos dirtyness is checked Furthermore, the change avoids a lot of checks for the native id of the changed object and treats collections now correctly. This closes #854.
michael-simons
added a commit
that referenced
this issue
Oct 29, 2020
This change avoids the recursive depth first iteration of nodes when visiting and testing them if we should fire a pre-save event. To make this work, dirty must be fixed in two places: - Checking for relationship entities trigges an ID creation to early (compare GH-831, 1805999) - we must ensure that we check only for existing previous relationships that are actually touched by the object whos dirtyness is checked Furthermore, the change avoids a lot of checks for the native id of the changed object and treats collections now correctly. This closes #854.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected Behavior
The recursion algorithm implemented in preSaveCheck might not be necessary and might be transformed into a loop on a stack/deque.
Context
On a project I'm working on we have performance issues. We made the exercise to profile the application to fix the bottleneck.
We have identified the aforementionned methods as responsible of a fraction of the time taken (not negligible).
On graph with entities with many bidir relationships it can lead to deep stack trace.
Please let me know if it makes sense. If so I can submit a pull request.
Your Environment
The text was updated successfully, but these errors were encountered: