Skip to content

Conversation

@Aras14HD
Copy link
Collaborator

We had three 100% cpu spikes before, all were due to nested operations, with 9e99999999 at the base.

After some investigation, I found the root cause to be the cloning of the top exponent number every op.
After I changed that to move, the example I used to test went down to ~1s total time.

As that is still slow, I changed the integer construction limit to 10000000 (one order of magnitude less, switches to approximate earlier).

The latest hours long problem was due to the copying of that top exponent thousands of times. I limited the steps to 10 for now.

@Aras14HD Aras14HD force-pushed the fix-long-calc-huge-input branch from 0996602 to 507bd17 Compare December 21, 2025 14:05
remove unnecessary clones (move instead, for towers)
limit number of listed steps
@Aras14HD Aras14HD force-pushed the fix-long-calc-huge-input branch from 507bd17 to e25a024 Compare December 21, 2025 14:07
@Aras14HD
Copy link
Collaborator Author

If we want to have not much of a change (other than keeping the biggest step), we could set the limit to 30.

@Aras14HD Aras14HD linked an issue Dec 21, 2025 that may be closed by this pull request
@tolik518
Copy link
Owner

tolik518 commented Dec 21, 2025

As long as it doesn't use up all the memory I'm fine with it :D

Upper limit of memory shouldn't be more than 10GB though, as I run lots of other stuff on my machine.

I should introduce a memory limit in the docker-compose file I think

Edit: assign me if it's ready for review btw

@Aras14HD
Copy link
Collaborator Author

So an individual integer should be at most on the order of 10^10000000, which is <4MiB, that times 30 gives <119MiB, less than 1GiB. One could still write a comment full of individual factorials, which would be 909, 9 of which would be <4MiB, 90 of which would be <400KiB and 810 of which would be <40KiB, together gives <<105MiB.

Lowering the construction limit further (possible with config) would proportionally lower that RAM use as well.

@Aras14HD Aras14HD requested a review from tolik518 December 21, 2025 14:54
@tolik518 tolik518 merged commit 971f15d into tolik518:master Dec 21, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bot used max memory + CPU

2 participants