Skip to content

parallel any_na - #3609

Closed
jangorecki wants to merge 2 commits into
masterfrom
any_na
Closed

jangorecki wants to merge 2 commits into
masterfrom
any_na

Conversation

@jangorecki

Copy link
Copy Markdown
Member

No description provided.

Comment thread src/utils.c Outdated
uint64_t first[nx]; // unused here
#pragma omp parallel for num_threads(getDTthreads())
for (R_len_t i=0; i<nx; i++) {
any_na_integer(ix[i], inx[i], &bans[i], &first[i], false);

@jangorecki jangorecki May 28, 2019 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last argument false disables parallelism over rows, as we parallelise over columns in this loop. This could eventually compare getDTthreads() and nx to decide. So in case we have 64 cores and just two columns to compute then parallelise over rows should be used

@codecov

codecov Bot commented May 28, 2019 •

Copy link
Copy Markdown

Codecov Report

Merging #3609 into master will decrease coverage by 0.25%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3609      +/-   ##
==========================================
- Coverage   97.79%   97.54%   -0.26%     
==========================================
  Files          66       67       +1     
  Lines       12904    12963      +59     
==========================================
+ Hits        12620    12645      +25     
- Misses        284      318      +34
Impacted Files Coverage Δ
src/init.c 100% <ø> (ø) ⬆️
R/utils.R 90.9% <0%> (-9.1%) ⬇️
src/utils.c 0% <0%> (ø)
src/fwrite.c 97.64% <0%> (ø) ⬆️
R/data.table.R 97.74% <0%> (+0.01%) ⬆️
R/setkey.R 98.34% <0%> (+0.02%) ⬆️
R/IDateTime.R 98.75% <0%> (+0.04%) ⬆️
R/cedta.R 100% <0%> (+12.5%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fa6297c...4d26e53. Read the comment docs.

@codecov

codecov Bot commented May 28, 2019

Copy link
Copy Markdown

Codecov Report

Merging #3609 into master will decrease coverage by 0.3%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3609      +/-   ##
==========================================
- Coverage   97.79%   97.49%   -0.31%     
==========================================
  Files          66       67       +1     
  Lines       12904    12944      +40     
==========================================
  Hits        12620    12620              
- Misses        284      324      +40
Impacted Files Coverage Δ
src/init.c 100% <ø> (ø) ⬆️
R/utils.R 90.9% <0%> (-9.1%) ⬇️
src/utils.c 0% <0%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fa6297c...f8f4cbb. Read the comment docs.

Comment thread src/utils.c Resolved
@jangorecki

jangorecki commented May 29, 2019 •

Copy link
Copy Markdown
Member Author

Some initial benchmarks shows there is no much to gain for atomic input - any_na_integer. It can be up to 42% of the anyNA timing, but the numbers are so tiny that it doesn't change much, and there is always an overhead which can be easily seen on best case scenario. And for list_any_na_integer speed up of course better but still numbers are relatively small.

library(data.table)

any_na_integer = data.table:::any_na_integer

N = 1e1 # to measure overhead

x = sample(N)            ## worst case
system.time(for(i in 1:100) any_na_integer(x))
#   user  system elapsed 
#  0.082   0.000   0.022 
system.time(for(i in 1:100) anyNA(x))
#   user  system elapsed 
#  0.001   0.000   0.002 
x = c(NA,sample(N-1))    ## best case
system.time(for(i in 1:100) any_na_integer(x))
#   user  system elapsed 
#  0.032   0.000   0.005 
system.time(for(i in 1:100) anyNA(x))
#   user  system elapsed 
#  0.002   0.000   0.002 

N = 1e9

setDTthreads(20L) # 50%
x = sample(N)            ## worst case
system.time(any_na_integer(x))
#   user  system elapsed 
#  1.619   2.743   0.301 
system.time(anyNA(x))
#   user  system elapsed 
#  0.588   0.000   0.588 
x = c(NA,sample(N-1))    ## best case
system.time(any_na_integer(x))
#   user  system elapsed 
#  1.838   0.000   0.105 
system.time(anyNA(x))
#   user  system elapsed 
#      0       0       0 

setDTthreads(40L) # 100%
x = sample(N)            ## worst case
system.time(any_na_integer(x))
#   user  system elapsed 
#  3.621   0.511   0.249 
system.time(anyNA(x))
#   user  system elapsed 
#  0.593   0.000   0.594 
x = c(NA,sample(N-1))    ## best case
system.time(any_na_integer(x))
#   user  system elapsed 
#  3.758   0.000   0.111 
system.time(anyNA(x))
#   user  system elapsed 
#      0       0       0 

list_any_na_integer = data.table:::list_any_na_integer

N = 1e8

setDTthreads(20L) # 50%
x = replicate(40, sample(N), simplify=F)            ## worst case
system.time(list_any_na_integer(x))
#   user  system elapsed 
#  6.763   6.859   1.648 
system.time(sapply(x, anyNA))
#   user  system elapsed 
#  2.399   0.404   2.803 
x = replicate(40, c(NA,sample(N-1)), simplify=F)    ## best case
system.time(list_any_na_integer(x))
#   user  system elapsed 
#  4.486   0.000   0.267 
system.time(sapply(x, anyNA))
#   user  system elapsed 
#      0       0       0 

setDTthreads(40L) # 100%
x = replicate(40, sample(N), simplify=F)            ## worst case
system.time(list_any_na_integer(x))
#   user  system elapsed 
#  8.246  21.610   0.931 
system.time(sapply(x, anyNA))
#   user  system elapsed 
#  2.433   0.144   2.577 
x = replicate(40, c(NA,sample(N-1)), simplify=F)    ## best case
system.time(list_any_na_integer(x))
#   user  system elapsed 
#  5.622   0.002   0.144 
system.time(sapply(x, anyNA))
#   user  system elapsed 
#      0       0       0 

Because of the above timings, closing this PR for now, we can come back if it will be needed, for example in #3608.

@jangorecki jangorecki closed this May 29, 2019
@MichaelChirico
MichaelChirico deleted the any_na branch July 8, 2025 17:30
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.

3 participants