-
Notifications
You must be signed in to change notification settings - Fork 70
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
Exponential growth in precision causing memory usage to spike as of 3.1.2 #222
Comments
@smidwap Thank you for reporting this issue. I'll investigate the details. |
We are running into this issue; would it be possible to merge and release this fix? |
@Confusion I'm working on this issue in #240. But the work is temporarily paused now because I'm too busy. Could you please use 3.1.1 until it's fixed? I'm sorry for the inconvenience. |
Downgrading to 3.1.1 will re-introduce the segfaults from #220 (which in my opinion is less preferred than memory spikes). We'll try to downgrade to 3.1.0 until this is fixed. |
I don't usually +1 but any chance there's a fix coming for this? We've had to avoid all future patches until this is fixed and would love to keep up |
I have some ideas for workarounds that I haven't been able to test yet:
|
Future patches are blocked by this issue. Kindly asking to re-assess the severity |
@alexshagov I'm sorry for the inconvenience. I'm still too busy to make progress on #240 in my personal time. Now, I can only handle minor bug fixes and review pull requests to decide whether to merge or reject them. This situation is likely to continue for more than a year. I'd be eager to review and incorporate the patch if someone else could fix this bug. |
I upgraded to BigDecimal 3.1.2 to pull in the fix to #220, which was causing crashes in our Rails app. However, I believe the fix applied in 127a1b5 created the potential for exponential growth in the number of digits a BigDecimal can have. The result is that certain calculations can eat up all available memory (several gigs) and crash the process.
Take the following as an example, which outputs the number of digits from the calculation:
In 3.1.1, this calculation produces 119 digits.
In 3.1.2, this calculation produces 23,033 digits.
Moreover, if
Array.new(10)
is grown toArray.new(20)
, 3.1.1 produces 209 digits, whereas 3.1.2 produces 23,592,953.The runaway growth in digits and resulting memory spike could be solved by rounding the result in inject's block like so:
But others may run into this same surprise. We've also run into
PG::NumericValueOutOfRange
exceptions from postgres since upgrading to 3.1.2, and my hunch is the same root issue is at play.Let me know if I can provide any more details.
The text was updated successfully, but these errors were encountered: