-
Notifications
You must be signed in to change notification settings - Fork 863
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
Debug radixcache: refactor recursive helper methods #3029
base: main
Are you sure you want to change the base?
Debug radixcache: refactor recursive helper methods #3029
Conversation
cb2dfd7
to
2cc5089
Compare
cc @xiezhq-hermann @hnyls2002 Can you help review this? |
Thank you for the contribution, can you make the change minimal and to the point? For example, put the style-wise change in a separated PR if needed. |
2cc5089
to
d02f0d0
Compare
@xiezhq-hermann Sorry for the inconvenience caused to you due to the extensive code refactoring. To minimize the impact, I made minimal changes and pushed a new commit. I believe this will serve as a better starting point for the review. Additionally, we can enhance the elegance of the code in the following two aspects, which can be done in another PR:
|
3c8ce57
to
1ecc9ef
Compare
635c8a3
to
4885b90
Compare
clean code and debug logic error |
6d95ee7
to
4447c79
Compare
Replace recursive implementations with iterative ones using stacks in `_match_prefix_helper`, `_print_helper`, and `_total_size_helper` to prevent potential stack overflow issues. Simplify the return value handling in `_match_prefix_helper` by removing the list parameter and returning a tuple directly. Streamline the `_insert_helper` logic with a while loop for better readability and maintainability. These changes improve performance and reliability while maintaining the same functionality.
4447c79
to
b39aaae
Compare
@xiezhq-hermann Would you please help me review this? I fixed some logic errors in this PR, the code should be good now. |
typo fix
Motivation
Currently radixcache is implemented by several recursive functions, which may cause PYTHON Stack overflow problem when tree hits a certain depth. You may reproduce this issue by following code.
Related Issue: #813
#1499 fixed one of recursive function but NOT ALL: .
Modifications
Replace recursion functions with loop or stack in radix_cache.py
Checklist