You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Failed to allocate counts or TMP when assigning g in gforce #4295
I would imagine median could be very memory hungry, this is why you usually see approx_quantile in "big data" SQL and median itself is dropped entirely.
Do you get the same issue if you try and sort the data by col1? If not, it may be that gmedian is trying to do all three columns at once.
As a workaround, do ft[ , .N, keyby = .(grp, col1)] and get the median from the frequency table, since you said there are far fewer unique values.
The network issue I encountered before... so I packaged the source and have sent it to your email (I assume you are able to access your personal email).
I got a similar problem. When running my R script in a Windows SQL Server (R version 3.5.2 and data.table 1.12.0), the following error occurs: Error in forderv(ans, cols, sort = TRUE, retGrp = FALSE, order = if (decreasing) -order else order, : Failed to allocate TMP or UGRP or they weren't cache line aligned: nth=8 Call: source ... [ -> [.data.table -> eval -> eval -> forder -> forderv
that is called by the following line of forcer.c: src/forder.c:728: if (!TMP || !UGRP /*|| TMP%64 || UGRP%64*/) STOP(_("Failed to allocate TMP or UGRP or they weren't cache line aligned: nth=%d"), nth);
The script joins two data tables (X and Y) with an on=.(Id,date>=start_date,date<=end_date) statement and uses by=.EACHI for the operation. When running the same script on my local RStudio version, there is no error. Do you think setting "Id" and "date" resp. "start_date" and "end_date" as keys in X and Y will prevent the integer overload? Alternatively, would changing by=.EACHI to keyby=.EACHI do the thing?
Do you think setting "Id" and "date" resp. "start_date" and "end_date" as keys in X and Y will prevent the integer overload? Alternatively, would changing by=.EACHI to keyby=.EACHI do the thing?
I don't have experience in MSSQLServer with R but I don't think it will solve your problem. Is it expensive to give a try?
I gave it a try and it did not work out. Do you know what might help here? Could it have to do something with the dependencies between data.table and bit64, since dependencies are sometimes distorted in MSSQL?
Turning off multiple threads did not work. Sometimes, the error changes to "invalid BXL stream", what can be attributed to having not enough memory.
Would you know if the error src/forder.c:728: if (!TMP || !UGRP /*|| TMP%64 || UGRP%64*/) STOP(_("Failed to allocate TMP or UGRP or they weren't cache line aligned: nth=%d"), nth); can be caused by a lack of RAM?
Activity
MichaelChirico commentedon Mar 10, 2020
I would imagine
mediancould be very memory hungry, this is why you usually seeapprox_quantilein "big data" SQL and median itself is dropped entirely.Do you get the same issue if you try and sort the data by
col1? If not, it may be thatgmedianis trying to do all three columns at once.As a workaround, do
ft[ , .N, keyby = .(grp, col1)]and get the median from the frequency table, since you said there are far fewer unique values.shrektan commentedon Mar 10, 2020
Will changing the
mediantostats::medianhelp? It should preventdata.tablefrom optimizing withgforce.renkun-ken commentedon Mar 10, 2020
Disabling gforce or using
stats::medianwill not trigger this error. But I'm still curious about why this occurs?My server memory is 1TB and should be enough to process.
MichaelChirico commentedon Mar 10, 2020
how about
stats::median(c(col1, col2, col3))(just to check if tripling the memory footprint has an impact)renkun-ken commentedon Mar 10, 2020
stats::median(c(col1, col2, col3))works quite normally and nothing special occurs.shrektan commentedon Mar 10, 2020
Well, the error is thrown from
data.table/src/gsumm.c
Lines 114 to 115 in b1b1832
However, I also see the
nrowis declared as anintdata.table/src/gsumm.c
Line 6 in b1b1832
It looks like it will lead to an overflow for 1423657324 * 2...
shrektan commentedon Mar 10, 2020
@renkun-ken Would you mind to have a test? Just cut the row count of your data to
1073741823L/1073741824Lrespectively and try your original code.I'm expecting the first case (1073741823L row) works but the second will fail.
shrektan commentedon Mar 10, 2020
I believe that's the cause. The overflow leads to an infinite memory allocation...
Created on 2020-03-10 by the reprex package (v0.3.0)
renkun-ken commentedon Mar 10, 2020
Yes,
1073741823Lcase works perfectly while1073741824Lcase does not work as you expected.shrektan commentedon Mar 12, 2020
@renkun-ken It would be great if you can verify that PR #4297 does fix this issue, when you have time, of course.
renkun-ken commentedon Mar 12, 2020
@shrektan Thanks! I'll verify it soon.
renkun-ken commentedon Mar 12, 2020
@shrektan sadly too hard to fetch the repo
tried many times but no luck
shrektan commentedon Mar 12, 2020
The network issue I encountered before... so I packaged the source and have sent it to your email (I assume you are able to access your personal email).
renkun-ken commentedon Mar 13, 2020
Thanks for your nice packaging! My git fetch worked magically as I was sleeping last night.
I retried and can confirm that the bug is fixed with the PR. Good work!
BTW, are you suspecting that there are some other similar
intproblems like this?1 remaining item
renkun-ken commentedon Mar 13, 2020
Also BTW, for such bugs that require very large data to reproduce, do we need to build test cases for them?
For this bug, a minimal reproducible example is
but
dtis 18GB and creatingdtcosts 5-10 mins.shrektan commentedon Mar 13, 2020
You can get a faster example by getting rid of the random functions.... just use
rep()andc()... I actually did try to test this.The difficulty is the requirement of a very large amount of memory...
renkun-ken commentedon Mar 13, 2020
I tried
and
Both are much faster but cannot produce the error. 👀
ColeMiller1 commentedon Mar 13, 2020
Instead of
rep(..., each =), remove the each. When the groupings are sorted, the part of code that usesTMPisn't used.steffen-windmueller commentedon May 5, 2020
I got a similar problem. When running my R script in a Windows SQL Server (R version 3.5.2 and data.table 1.12.0), the following error occurs:
Error in forderv(ans, cols, sort = TRUE, retGrp = FALSE, order = if (decreasing) -order else order, : Failed to allocate TMP or UGRP or they weren't cache line aligned: nth=8 Call: source ... [ -> [.data.table -> eval -> eval -> forder -> fordervthat is called by the following line of forcer.c:
src/forder.c:728: if (!TMP || !UGRP /*|| TMP%64 || UGRP%64*/) STOP(_("Failed to allocate TMP or UGRP or they weren't cache line aligned: nth=%d"), nth);The script joins two data tables (X and Y) with an
on=.(Id,date>=start_date,date<=end_date)statement and usesby=.EACHIfor the operation. When running the same script on my local RStudio version, there is no error. Do you think setting "Id" and "date" resp. "start_date" and "end_date" as keys in X and Y will prevent the integer overload? Alternatively, would changingby=.EACHItokeyby=.EACHIdo the thing?Thank you already in advance.
shrektan commentedon May 5, 2020
I don't have experience in MSSQLServer with R but I don't think it will solve your problem. Is it expensive to give a try?
steffen-windmueller commentedon May 5, 2020
I gave it a try and it did not work out. Do you know what might help here? Could it have to do something with the dependencies between data.table and bit64, since dependencies are sometimes distorted in MSSQL?
shrektan commentedon May 5, 2020
In my opinion, it should have nothing to do with bit64 because bit64 has stopped updating for 3 years. I have some (limited) suggestions for you:
data.table::setDTthreads(1L)steffen-windmueller commentedon May 13, 2020
Turning off multiple threads did not work. Sometimes, the error changes to "invalid BXL stream", what can be attributed to having not enough memory.
Would you know if the error
src/forder.c:728: if (!TMP || !UGRP /*|| TMP%64 || UGRP%64*/) STOP(_("Failed to allocate TMP or UGRP or they weren't cache line aligned: nth=%d"), nth);can be caused by a lack of RAM?jangorecki commentedon May 13, 2020
@scharlatan0139 yes, it does look exactly like an error caused by lack of RAM.
Debasis5 commentedon Dec 9, 2020
@shrektan , Is the rightway to import your fix is remotes::install_github("Rdatatable/data.table#fix4295")
I tried this but got an invalid repo error
shrektan commentedon Dec 9, 2020
@Debasis5 It should be
or