-
-
Notifications
You must be signed in to change notification settings - Fork 147
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
Improve performance for creating crdt.TreeNode #939
Conversation
The time complexity of creating crdt.TreeNode is O(N^2), potentially causing performance bottlenecks. It's optimized to O(n).
WalkthroughThe recent changes enhance the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- api/converter/from_pb.go (1 hunks)
Additional comments not posted (3)
api/converter/from_pb.go (3)
586-587
: InitializedepthTable
map with root node.The
depthTable
map is initialized to store the most recently processed node at each depth, starting with the root node.
589-589
: UsedepthTable
for direct parent node access.The
depthTable
map is used to directly access the parent node based on its depth, eliminating the need for nested loops.
594-594
: UpdatedepthTable
with the current node.After processing each node, the current node is added to the
depthTable
, ensuring that the parent can be quickly accessed in subsequent iterations.
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.
Thanks for your contribution.
It would be good to add a benchmark test to measure Tree Performance. How about adding tree_editing_bench_test.go
and adding the test code you wrote before?
In order to check the performance of the tree, a tree_editing_bench_test file was added and a tree converting test was implemented.
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.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- test/bench/tree_editing_bench_test.go (1 hunks)
Additional context used
GitHub Check: bench
test/bench/tree_editing_bench_test.go
[failure] 53-53:
undefined: api
Additional comments not posted (5)
test/bench/tree_editing_bench_test.go (5)
1-20
: Header and package declaration are correct.The build constraints and licensing information are standard and correctly declared.
21-27
: Import statements are correct.The imported packages are necessary and correctly used in the file.
29-31
: BenchmarkTreeEditing function is correct.The function correctly sets up the benchmark by calling
BenchmarkTreeConverting
.
33-50
: BenchmarkTreeConverting function is correct.The function correctly sets up and runs multiple benchmarks with different vertex counts.
68-74
: TreeConverting function is correct.The function correctly sets up and runs the benchmark for converting protobuf tree nodes to
crdt.TreeNode
.
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- test/bench/tree_editing_bench_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- test/bench/tree_editing_bench_test.go
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.
LGTM. 👍
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- test/bench/tree_editing_bench_test.go (1 hunks)
Files skipped from review due to trivial changes (1)
- test/bench/tree_editing_bench_test.go
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- test/bench/tree_editing_bench_test.go (1 hunks)
Files skipped from review due to trivial changes (1)
- test/bench/tree_editing_bench_test.go
The time complexity of creating crdt.TreeNode is O(N^2), potentially causing performance bottlenecks. It's optimized to O(n). While this may not be a significant issue currently, there is a risk that as the number of tree nodes in the protobuf increases, operations will scale quadratically, potentially causing performance bottlenecks. --------- Co-authored-by: JiHwan Yim <raararaara@gmail.com> Co-authored-by: Youngteac Hong <susukang98@gmail.com>
I've cleaned up the benchmark code a little more. Please refer to the commit below. |
The time complexity of creating crdt.TreeNode is O(N^2), potentially causing performance bottlenecks. It's optimized to O(n). While this may not be a significant issue currently, there is a risk that as the number of tree nodes in the protobuf increases, operations will scale quadratically, potentially causing performance bottlenecks. --------- Co-authored-by: JiHwan Yim <raararaara@gmail.com> Co-authored-by: Youngteac Hong <susukang98@gmail.com>
What this PR does / why we need it:
The time complexity of creating crdt.TreeNode is O(N^2), potentially causing performance bottlenecks. It's optimized to O(n).
While this may not be a significant issue currently, there is a risk that as the number of tree nodes in the protobuf increases, operations will scale quadratically, potentially causing performance bottlenecks.
Which issue(s) this PR fixes:
Addresses #930
Special notes for your reviewer:
Does this PR introduce a user-facing change?:
Additional documentation:
Checklist:
Summary by CodeRabbit
Summary by CodeRabbit
Improved Performance
Code Readability