-
-
Notifications
You must be signed in to change notification settings - Fork 482
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
Unoptimal memory complexity of sage.matrix.berlekamp
#36172
Comments
5 tasks
vbraun
pushed a commit
to vbraun/sage
that referenced
this issue
Sep 4, 2023
Fix sagemath#36172. Reduced berlekamp_massey memory consumption by replacing a dictionary with temporary variables. The memory consumption of the line highlighted below reduced from 42MB to 4MB (probably inaccurate, but significant enough). ```python from memory_profiler import profile from sage.matrix.berlekamp_massey import berlekamp_massey @Profile def gen_data(): p = random_prime(2**64) ls = [GF(p).random_element() for _ in range(20000)] berlekamp_massey(ls); # <--- this line gen_data() ``` I am not sure if I have to include extra doctests or not, or how to test memory consumptions, since the time complexity is also O(n^2). ### 📝 Checklist - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation accordingly. URL: sagemath#36173 Reported by: grhkm21 Reviewer(s): grhkm21, Kwankyu Lee
vbraun
pushed a commit
to vbraun/sage
that referenced
this issue
Sep 5, 2023
Fix sagemath#36172. Reduced berlekamp_massey memory consumption by replacing a dictionary with temporary variables. The memory consumption of the line highlighted below reduced from 42MB to 4MB (probably inaccurate, but significant enough). ```python from memory_profiler import profile from sage.matrix.berlekamp_massey import berlekamp_massey @Profile def gen_data(): p = random_prime(2**64) ls = [GF(p).random_element() for _ in range(20000)] berlekamp_massey(ls); # <--- this line gen_data() ``` I am not sure if I have to include extra doctests or not, or how to test memory consumptions, since the time complexity is also O(n^2). ### 📝 Checklist - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation accordingly. URL: sagemath#36173 Reported by: grhkm21 Reviewer(s): grhkm21, Kwankyu Lee
vbraun
pushed a commit
to vbraun/sage
that referenced
this issue
Sep 10, 2023
Fix sagemath#36172. Reduced berlekamp_massey memory consumption by replacing a dictionary with temporary variables. The memory consumption of the line highlighted below reduced from 42MB to 4MB (probably inaccurate, but significant enough). ```python from memory_profiler import profile from sage.matrix.berlekamp_massey import berlekamp_massey @Profile def gen_data(): p = random_prime(2**64) ls = [GF(p).random_element() for _ in range(20000)] berlekamp_massey(ls); # <--- this line gen_data() ``` I am not sure if I have to include extra doctests or not, or how to test memory consumptions, since the time complexity is also O(n^2). ### 📝 Checklist - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation accordingly. URL: sagemath#36173 Reported by: grhkm21 Reviewer(s): grhkm21, Kwankyu Lee
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The code here is unoptimal:
sage/src/sage/matrix/berlekamp_massey.py
Lines 90 to 98 in 6695bec
For example, the following code uses a lot of memory:
To be more specific, the dictionaries are not necessarily and only
f[j - 2]
andf[j - 1]
are used every time, same fors
. So they can be stored as temporary variables.Additional Information
I am fixing it.
Checklist
The text was updated successfully, but these errors were encountered: