Data.table: 쑰인 μž‘μ—…μ΄ 거의 2λ°° 느림

에 λ§Œλ“  2019λ…„ 10μ›” 02일  Β·  29μ½”λ©˜νŠΈ  Β·  좜처: Rdatatable/data.table

μ•ˆλ…•ν•˜μ„Έμš”, ν…ŒμŠ€νŠΈ μ€‘μ΄μ—ˆμŠ΅λ‹ˆλ‹€
data.table_1.10.4-3 + R 버전 3.4.0 (2017-04-21)
λŒ€
data.table_1.12.2 + R 버전 3.6.1(2019-07-05)

μƒˆ 버전 data.table(R?)
λ‚˜λŠ” 주둜 data.table의 버전에 달렀 μžˆλ‹€κ³  μƒκ°ν•©λ‹ˆλ‹€.

rm(list=ls())

library(data.table)
library(tictoc)


aa = data.table(a = seq(1,100), b = rep(0, 100))
bb = data.table(a = seq(1,100), b = rep(1, 100))

#aa[,  a1 := as.character(a)]
#bb[,  a1 := as.character(a)]

setindex(aa, a)
setindex(bb, a)

tic()
for(i in c(1:1000)) {
 # aa[bb, b := i.b, on=.(a, a1)] # test1
  aa[bb, b := i.b, on=.(a)] # test2
}
toc()

# test1
# 3.6.1: 5.5 sec with index
# 3.6.1: 6.87 sec without index
# 3.4.0: 3.02 sec (no index)

# test2
# 3.6.1: 3.82 sec with index
# 3.6.1: 4.44 sec without index
# 3.4.0: 2.48 sec (no index)
High joins performance regression

λͺ¨λ“  29 λŒ“κΈ€

λ‹€μŒμ„ μ‹€ν–‰ν–ˆμŠ΅λ‹ˆλ‹€.

# run_join_time.sh
echo 'hash,time' > 'join_timings.csv'

for HASH in $(git rev-list --ancestry-path 1.10.0..1.12.4 | awk 'NR == 1 || NR % 10 == 0');
do git checkout $HASH && R CMD INSTALL . && Rscript time_join.R $HASH;
done
# time_join.R
library(data.table)
library(microbenchmark)

hash = commandArgs(trailingOnly = TRUE)

aa = data.table(a = seq(1,100), b = rep(0, 100))
bb = data.table(a = seq(1,100), b = rep(1, 100))

fwrite(data.table(
  hash = hash,
  time = microbenchmark(times = 1000L, aa[bb, b := i.b, on=.(a)])$time
), 'join_timings.csv', append = TRUE)

그런 λ‹€μŒμ΄ ν”Œλ‘―μ„ λ§Œλ“€κΈ° μœ„ν•΄ λ‹€μŒμ„ μˆ˜ν–‰ν–ˆμŠ΅λ‹ˆλ‹€.

Screenshot 2019-10-03 at 6 59 11 PM

library(data.table)
times = fread('join_timings.csv')

times[ , date := as.POSIXct(system(sprintf("git show --no-patch --no-notes --pretty='%%cd' %s", .BY$hash), intern = TRUE), by = hash]
times[ , date := as.POSIXct(date, format = '%a %b %d %T %Y %z', tz = 'UTC')]
times[ , date := as.IDate(date)]
setorder(times, date)

tags = system('
for TAG in $(git tag);
  do git show --no-patch --no-notes --pretty="$TAG\t%cd" $TAG;
done
', intern = TRUE)

tags = setDT(tstrsplit(tags, '\t'))
setnames(tags, c('tag', 'date'))
tags[ , date := as.POSIXct(date, format = '%a %b %d %T %Y %z', tz = 'UTC')]
tags[ , date := as.IDate(date)]

times[ , {
  par(mar = c(7.1, 4.1, 2.1, 2.1))
  y = boxplot(I(time/1e6) ~ date, log = 'y', notch = TRUE, pch = '.',
              las = 2L, xlab = '', ylab = 'Execution time (ms)', cex.axis = .8)
  x = unique(date)
  idx = findInterval(tags$date, x)
  abline(v = idx[idx>0L], lty = 2L, col = 'red')
  text(idx[idx>0L], .7*10^(par('usr')[4L]), tags$tag[idx>0L], 
       col = 'red', srt = 90)
  NULL
}]


μ‹œμž‘ν•œ ν›„ λ‹€μŒμ„ μ‚¬μš©ν•˜μ—¬ 이것을 쑰금 κ°„μ†Œν™”ν•  수 μžˆλ‹€λŠ” 것을 κΉ¨λ‹¬μ•˜μŠ΅λ‹ˆλ‹€.

echo 'hash,time,date' > 'join_timings.csv'

for HASH in $(git rev-list --ancestry-path 1.10.0..1.12.4 | awk 'NR == 1 || NR % 10 == 0');
do git checkout $HASH && R CMD INSTALL . --preclean && Rscript time_join.R $HASH $(git show --no-patch --no-notes --pretty='%cd' $HASH);
done
library(data.table)
library(microbenchmark)

args = commandArgs(trailingOnly = TRUE)
hash = args[1L]
date = as.POSIXct(args[2L], format = '%a %b %d %T %Y %z', tz = 'UTC'))

aa = data.table(a = seq(1,100), b = rep(0, 100))
bb = data.table(a = seq(1,100), b = rep(1, 100))

fwrite(data.table(
  hash = hash,
  date = date,
  time = microbenchmark(times = 1000L, aa[bb, b := i.b, on=.(a)])$time
), 'join_timings.csv', append = TRUE)

컀밋 μ‹œκ°„μ„ λ²€μΉ˜λ§ˆν¬μ— 직접 μΆ”κ°€ν•˜λ €λ©΄

Join_timings.txt

μ•ˆλ…• MichaelChirico, λ‚˜λŠ” 두 번 μ½μ—ˆμŠ΅λ‹ˆλ‹€
κ·ΈλŸ¬λ‚˜ 2016λ…„λΆ€ν„° 2019λ…„κΉŒμ§€μ˜ νƒ€μž„λΌμΈμ€ μ •ν™•νžˆ 무엇을 μ˜λ―Έν•©λ‹ˆκΉŒ? 데이터 ν…Œμ΄λΈ” λ²„μ „μž…λ‹ˆκΉŒ?

λ²„μ „λΏλ§Œ μ•„λ‹ˆλΌ νŠΉμ • 컀밋. λ‚΄κ°€ μΆ”κ°€ν•˜λŠ” 것을 μžŠμ€ 쒋은 생각인 λ²„μ „μ˜ 경계λ₯Ό μΆ”κ°€ν•΄ λ³΄κ² μŠ΅λ‹ˆλ‹€.

@MichaelChirico κ·€ν•˜μ˜ κ·Έλž˜ν”„λŠ” 맀우 λ©‹μ Έ λ³΄μž…λ‹ˆλ‹€. λˆ„λ½λœ 것은 이에 λŒ€ν•œ ν•΄μ„μ΄μ—ˆμŠ΅λ‹ˆλ‹€. :) μΆ”μΈ‘ν•˜μ—¬ μƒˆλ‘œμš΄ 병렬 ν¬λ”λŠ” 길이 100의 μž…λ ₯에 λŒ€ν•΄ 이전보닀 λŠλ¦½λ‹ˆλ‹€. 아직 마이크둜초이기 λ•Œλ¬Έμ— μ–΄λŠ IMOκ°€ μ’‹μŠ΅λ‹ˆλ‹€. λ¬Όλ‘  μ˜€λ²„ν—€λ“œλ₯Ό μ€„μ΄λŠ” 것은 κ°€μΉ˜κ°€ μžˆμ§€λ§Œ κ°€μž₯ 일반적인 μ‚¬μš© μ‹œλ‚˜λ¦¬μ˜€μ—μ„œ μš°μ„  μˆœμœ„λŠ” λ¦¬μ†ŒμŠ€λ₯Ό μ€„μ΄λŠ” 것이어야 ν•©λ‹ˆλ‹€. 길이 100 μž…λ ₯에 λŒ€ν•΄ 10000번 λ°˜λ³΅ν•˜λŠ” 것은 ν™•μ‹€νžˆ κ·Έ 쀑 ν•˜λ‚˜κ°€ μ•„λ‹™λ‹ˆλ‹€.

그것은 1.12.0 NEWSλ₯Ό 보고 λ‚˜λ„ μΆ”μΈ‘ν–ˆλ‹€. 단일 μŠ€λ ˆλ“œλ₯Ό λ‹€μ‹œ μ‹€ν–‰ν•˜λ €κ³  ν•©λ‹ˆλ‹€.

@jangorecki , κ°„λ‹¨ν•œ μˆ˜ν•™μ„ μˆ˜ν–‰ν•˜λ©΄ 수천 마이크둜초, 즉 λ°€λ¦¬μ΄ˆμž…λ‹ˆλ‹€.
이 ν…ŒμŠ€νŠΈμ˜ μ˜κ°μ€ 40,000행이 μžˆλŠ” 7-8λ°° ν…Œμ΄λΈ”μ„ μ‘°μΈν•˜λŠ” ν˜„μž¬ ν”„λ‘œμ νŠΈμ˜€μŠ΅λ‹ˆλ‹€.
18μ΄ˆκ°€ 걸리기 μ „, 40초 후에
λ‚΄ ν…ŒμŠ€νŠΈμ—λŠ” 문자 킀도 ν¬ν•¨λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.
3.6+1.12λ₯Ό μ„€μΉ˜ν•œ λ‹€μŒ 3.4+1.10으둜 λ‘€λ°±ν–ˆμŠ΅λ‹ˆλ‹€.
λ‚˜λŠ” 이것이 정상적인 상황이 μ•„λ‹ˆλΌκ³  μƒκ°ν•˜μ—¬μ΄ λ¬Έμ œκ°€ 여기에 μžˆμŠ΅λ‹ˆλ‹€.

λ„€, κ·Έλž˜ν”„λŠ” 정말 ꡉμž₯ν•©λ‹ˆλ‹€. μš°λ¦¬λŠ” 이것을 더 많이 ν•˜κ³  μžλ™ν™”ν•΄μ•Ό ν•©λ‹ˆλ‹€.

κ·ΈλŸ¬λ‚˜ μ›λž˜ λ³΄κ³ μ„œλŠ” R 3.4와 R 3.6을 λΉ„κ΅ν–ˆλŠ”λ° R 3.5κ°€ 쀑간에 μžˆμŠ΅λ‹ˆλ‹€. μš°λ¦¬λŠ” R 3.5κ°€ ALTREP의 REAL(), INTEGER() λ§€ν¬λ‘œμ—μ„œ (μ•½κ°„ 더 무거운) ν•¨μˆ˜λ‘œ 변경을 톡해 data.table에 영ν–₯을 λ―Έμ³€λ‹€λŠ” 것을 μ•Œκ³  μžˆμŠ΅λ‹ˆλ‹€.

@vk111 μ§€κΈˆ CRANμ—μ„œ v1.12.4둜 ν…ŒμŠ€νŠΈλ₯Ό λ‹€μ‹œ μ‹€ν–‰ν•΄ μ£Όμ‹œκ² μŠ΅λ‹ˆκΉŒ? 더 λ‚˜μ€? μš°λ¦¬λŠ” R 3.5+에 λŒ€μ²˜ν•˜κΈ° μœ„ν•΄ 루프 μ™ΈλΆ€μ—μ„œ R APIλ₯Ό κ°€μ Έμ™”μŠ΅λ‹ˆλ‹€. λ‹€μŒ λ‹¨κ³„λ‘œ v1.12.4λ₯Ό μ°ΎλŠ” 방법을 μ•„λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€. 당신은 λ˜ν•œ λ‹Ήμ‹ μ˜ 기계에 λŒ€ν•œ 더 λ§Žμ€ 정보λ₯Ό 포함할 수 μžˆμŠ΅λ‹ˆκΉŒ? 예: 운영 체제, RAM 및 CPU 수.

@matt ν• κ±°μ•Ό

μ•ˆλ…•ν•˜μ„Έμš” @mattdowle ,

IveλŠ” 1.12.4(+R 3.6.1)둜 μ—…λ°μ΄νŠΈν–ˆμŠ΅λ‹ˆλ‹€. 기본적으둜 λ‹¨μœ„ ν…ŒμŠ€νŠΈμ™€ λ‚΄ κΈ°λŠ₯에 λŒ€ν•΄ λ™μΌν•œ μˆ«μžκ°€ μžˆμŠ΅λ‹ˆλ‹€.
μ—¬κΈ°μ„œλŠ” 인덱싱 없이 λ¬Έμžκ°€ μžˆλŠ” 쑰인만 벀치마크둜 κ³ λ €ν•  κ²ƒμž…λ‹ˆλ‹€.
λ‹¨μœ„ ν…ŒμŠ€νŠΈ(첫 번째 κ²Œμ‹œλ¬Όμ—μ„œ μ–ΈκΈ‰ν•œ λŒ€λ‘œ)
3.6.1: 인덱슀 없이 6.87초
3.4.0: 3.02초(인덱슀 μ—†μŒ)

ν”„λ‘œμ νŠΈμ˜ λ‚΄ κΈ°λŠ₯은 λ™μΌν•˜κ²Œ μœ μ§€λ©λ‹ˆλ‹€: 20초 λŒ€ 40초
~14개의 dt 쑰인으둜만 κ΅¬μ„±λ©λ‹ˆλ‹€.
2개의 ν…Œμ΄λΈ” 30,000ν–‰(dt1) 및 366,000ν–‰(dt2)
각각 15μ—΄
ν‚€λŠ” 2개의 λ¬Έμžμ™€ 1개의 μˆ«μžμž…λ‹ˆλ‹€.
쑰인 쀑에 7개의 ν•„λ“œ(dt1μ—μ„œ dt2κΉŒμ§€)λ₯Ό ν• λ‹Ήν–ˆμŠ΅λ‹ˆλ‹€.

λ‚΄ PC:
승리 10 64λΉ„νŠΈ
AMD A8 2.2GHz
8GB RAM

cmd: wmic cpu get NumberOfCores, NumberOfLogicalProcessors/ ν˜•μ‹: λͺ©λ‘
μ½”μ–΄ 수=4
NumberOfLogicalProcessors=4

λΆ„μ„ν•΄μ£Όμ…”μ„œ κ°μ‚¬ν•©λ‹ˆλ‹€

μ•ˆλ…• @mattdowle κ·Έλž˜μ„œ 당신은 이것을 κ³ λ €ν•˜κ³  μžˆμŠ΅λ‹ˆκΉŒ?

방금 λ‹€μ‹œ μ‹€ν–‰ν•œ git bisect 에 λ”°λ₯΄λ©΄ 이 컀밋은 속도 μ €ν•˜μ— λŒ€ν•œ "μœ μ£„"이며 Mattκ°€ 루트λ₯Ό νŒŒμ•…ν•˜λŠ” 데 도움이 될 수 있기λ₯Ό λ°”λžλ‹ˆλ‹€. forder 와 κ΄€λ ¨λ˜μ–΄ μžˆλ‹€λŠ” 사싀은 μš°λ¦¬κ°€ 그것을 μ˜¬λ°”λ₯΄κ²Œ κ³ μ •μ‹œμΌ°λ‹€λŠ” 것을 μƒλŒ€μ μœΌλ‘œ ν™•μ‹ ν•˜κ²Œ ν•©λ‹ˆλ‹€.

https://github.com/Rdatatable/data.table/commit/e59ba149f21bb35098ed0b527505d5ed6c5cb0db

더 μ •ν™•ν•˜κ²Œ:

# run_join_time.sh
R CMD INSTALL . && Rscript time_join.R
# time_join.R
library(data.table)
library(microbenchmark)

aa = data.table(a = seq(1,100), b = rep(0, 100))
bb = data.table(a = seq(1,100), b = rep(1, 100))

summary(microbenchmark(times = 1000L, aa[bb, b := i.b, on=.(a)])$time/1e6)

master/HEAD μ—μ„œ λ‹€μŒ 두 슀크립트λ₯Ό μ‚¬μš©ν•©λ‹ˆλ‹€.

git checkout 1.12.0
git bisect start
git bisect bad
git bisect good 1.11.8

그런 λ‹€μŒ 각 λ°˜λ³΅μ—μ„œ sh run_join_time.sh λ₯Ό μ‹€ν–‰ν•˜κ³  κ²°κ³Όλ₯Ό ν™•μΈν•©λ‹ˆλ‹€. bad 컀밋은 λ‚΄ μ»΄ν“¨ν„°μ—μ„œ λ°˜λ³΅λ‹Ή λŒ€λž΅ .9μ΄ˆκ°€ κ±Έλ Έκ³  good 컀밋은 μ•½ 0.7μ΄ˆμ˜€μŠ΅λ‹ˆλ‹€.

μ•ˆλ…•ν•˜μ„Έμš” Michael, κ°μ‚¬ν•©λ‹ˆλ‹€. ν•˜μ§€λ§Œ 특히 μ„±λŠ₯이 크게 λ–¨μ–΄μ‘ŒμŠ΅λ‹ˆλ‹€.
첫 번째 κ²Œμ‹œλ¬Όμ—μ„œ λ‹¨μœ„ ν…ŒμŠ€νŠΈμ™€ ν•¨κ»˜ 제곡된 문자 킀에 λŒ€ν•΄
μ–΄μ¨Œλ“  λ¬Έμ œκ°€ ν•΄κ²°λ˜μ—ˆλŠ”μ§€ Matt의 확인을 κΈ°λ‹€λ €μ•Ό ν•œλ‹€κ³  μƒκ°ν•©λ‹ˆλ‹€.
μƒˆ 버전이든 μ•„λ‹ˆλ“ 

2019λ…„ 12μ›” 26일 λͺ©μš”일 15:02, Michael Chirico [email protected]
썼닀:

방금 λ‹€μ‹œ μ‹€ν–‰ν•œ git bisect에 λ”°λ₯΄λ©΄ 이 컀밋은
천천히, μž˜ν•˜λ©΄ Mattκ°€ 루트λ₯Ό κ³ μ •ν•˜λŠ” 데 도움이 될 수 μžˆμŠ΅λ‹ˆλ‹€. 그것은
forder와 κ΄€λ ¨λœ 것은 μš°λ¦¬κ°€ 그것을 κ³ μ •μ‹œμΌ°λ‹€λŠ” 것을 μƒλŒ€μ μœΌλ‘œ ν™•μ‹ ν•˜κ²Œ λ§Œλ“­λ‹ˆλ‹€.
λ°”λ₯΄κ²Œ.

e59ba14
https://github.com/Rdatatable/data.table/commit/e59ba149f21bb35098ed0b527505d5ed6c5cb0db

더 μ •ν™•ν•˜κ²Œ:

run_join_time.sh

R CMD μ„€μΉ˜ . && R슀크립트 time_join.R

time_join.R

라이브러리(data.table)
라이브러리(마이크둜벀치마크)

aa = data.table(a = seq(1,100), b = rep(0, 100))
bb = data.table(a = seq(1,100), b = rep(1, 100))

summary(microbenchmark(times = 1000L, aa[bb, b := ib, on=.(a)])$time/1e6)

λ§ˆμŠ€ν„°/HEADμ—μ„œ λ‹€μŒ 두 슀크립트λ₯Ό μ‚¬μš©ν•©λ‹ˆλ‹€.

μžμ‹ 체크 아웃 1.12.0
μžμ‹ 이등뢄 μ‹œμž‘
μžμ‹ 이등뢄 λ‚˜μœ
μžμ‹ 이등뢄 쒋은 1.11.8

그런 λ‹€μŒ 각 λ°˜λ³΅μ—μ„œ sh run_join_time.shλ₯Ό μ‹€ν–‰ν•˜κ³  κ²°κ³Όλ₯Ό ν™•μΈν•©λ‹ˆλ‹€. 그만큼
λ‚˜μœ 컀밋은 λ‚΄ μ»΄ν“¨ν„°μ—μ„œ λ°˜λ³΅λ‹Ή λŒ€λž΅ 0.9μ΄ˆκ°€ κ±Έλ ΈμŠ΅λ‹ˆλ‹€.
쒋은 컀밋 μ•½ .7.

β€”
당신이 μ–ΈκΈ‰λ˜μ—ˆκΈ° λ•Œλ¬Έμ— 이것을 λ°›λŠ” κ²ƒμž…λ‹ˆλ‹€.
이 이메일에 직접 λ‹΅μž₯ν•˜κ³  GitHubμ—μ„œ ν™•μΈν•˜μ„Έμš”.
https://github.com/Rdatatable/data.table/issues/3928?email_source=notifications&email_token=ABRM7MJQITNUZDNYV7NTIX3Q2S2ORA5CNFSM4I4ZPREKYY6HTRKY6EPNVWWK3TUL52HS4DFVREXG43VMVBW63
λ˜λŠ” ꡬ독 μ·¨μ†Œ
https://github.com/notifications/unsubscribe-auth/ABRM7MOTZRFFM2QKVFUHT6LQ2S2ORANCNFSM4I4ZPREA
.

>

μΉœμ• ν•˜λŠ”,
바싀리 μΏ μ¦ˆλ„€μ΄ˆν”„

@vk111 이 λ¬Έμ œκ°€ ν•΄κ²°λ˜μ§€ μ•Šμ€ 경우 λ¬Έμ œκ°€ 아직 ν•΄κ²°λ˜μ§€ μ•Šμ•˜λ‹€κ³  μ•ˆμ „ν•˜κ²Œ κ°€μ •ν•  수 μžˆμŠ΅λ‹ˆλ‹€. μš°λ¦¬λŠ” 무언가λ₯Ό κ³ μΉ  λ•Œλ§ˆλ‹€ κ΄€λ ¨ 문제λ₯Ό λ‹«μŠ΅λ‹ˆλ‹€.

@vk111 setindex setkey λ₯Ό μ‚¬μš©ν•˜μ—¬ μ•½κ°„μ˜ μ‘°μ •μœΌλ‘œ μ™„ν™”ν•  수 μžˆμŠ΅λ‹ˆλ‹€. μ΄λ ‡κ²Œ ν•˜λ©΄ λ‚΄ μ»΄ν“¨ν„°μ—μ„œ ν…ŒμŠ€νŠΈκ°€ 절반 이상 μ€„μ–΄λ“­λ‹ˆλ‹€.

aa = data.table(a = seq(1,100), b = rep(0, 100))
bb = data.table(a = seq(1,100), b = rep(1, 100))

aa[,  a1 := as.character(a)]
bb[,  a1 := as.character(a)]

tic()
for(i in c(1:1000)) {
  aa[bb, b := i.b, on=.(a, a1)] # test1 without key
}
toc()
## 4 sec elapsed

tic()
setkey(aa, a, a1)
setkey(bb, a, a1)

for(i in c(1:1000)) {
  aa[bb, b := i.b] # test2 without key
}
toc()
## 1.46 sec elapsed

image

library(microbenchmark)
library(data.table)

aa = data.table(a = seq(1,100), b = rep(0, 100))
bb = data.table(a = seq(1,100), b = rep(1, 100))

aa[,  a1 := as.character(a)]
bb[,  a1 := as.character(a)]

aa_nokey = copy(aa)
bb_nokey = copy(bb)

tic()
aa_int_key = setkey(copy(aa), a)
bb_int_key = setkey(copy(bb), a)
toc()

tic()
aa_int_char = setkey(copy(aa), a, a1)
bb_int_char = setkey(copy(bb), a, a1)
toc()
int_nokey = function(dt1, dt2){
  dt1[dt2, b := i.b, on=.(a)]
}

int_key = function(dt1, dt2){
  dt1[dt2, b := i.b]
}

int_char_nokey = function(dt1, dt2){
  dt1[dt2, b := i.b, on=.(a, a1)]
}

int_char_key = function(dt1, dt2){
  dt1[dt2, b := i.b]
}

int_char_key_on = function(dt1, dt2){
  dt1[dt2, b := i.b, on=.(a, a1)]
}

boxplot(
  microbenchmark(
    a_no_key = int_nokey(aa, bb),
    a_key = int_key(aa_int_key, bb_int_key),
    a_a1_no_key = int_char_nokey(aa, bb),
    a_a1_key = int_char_key(aa_int_char, bb_int_char),
    a_a1_key_on = int_char_key_on(aa_int_char, bb_int_char)
  )
)

μ•ˆλ…•ν•˜μ„Έμš” Cole, 예, setkey에 λŒ€ν•΄ μ•Œκ³  μžˆμŠ΅λ‹ˆλ‹€. μœ„μ—μ„œ κ°„λ‹¨ν•œ μ„€λͺ…을 μ œκ³΅ν–ˆμŠ΅λ‹ˆλ‹€.
λ‚΄ ν”„λ‘œμ νŠΈμ— 1000개 쑰인의 λͺ©μ μ΄ μ—†μŠ΅λ‹ˆλ‹€. 10-20개 정도 μžˆμŠ΅λ‹ˆλ‹€.
μ‘°μΈν•˜κ³  λ¬Έμ œλŠ” λ‚΄ λ¬Έμžμ—΄μ΄ 맀우 동적이고
20번 setkey와 20번처럼 μ‘°μΈν•˜κΈ° 전에 맀번 setkeyλ₯Ό λ§Œλ“€μ–΄μ•Ό ν•©λ‹ˆλ‹€.
μ‹œκ°„μ΄ κ²°ν•©ν•˜λ―€λ‘œ μ‹œκ°„μ˜ 이득은 2λ°° λ―Έλ§Œμž…λ‹ˆλ‹€.
이 상황에 λŒ€ν•œ 일반적인 ν•΄κ²° λ°©λ²•μœΌλ‘œ μž μ‹œ λ™μ•ˆ 3.4.0을 μ‚¬μš©ν•©λ‹ˆλ‹€.
특히 λ‹€μŒκ³Ό 같은 경우 μƒˆ λ²„μ „μ—μ„œ μˆ˜μ •ν•˜λŠ” 것이 큰 λ¬Έμ œλŠ” 아닐 κ²ƒμž…λ‹ˆλ‹€.
μœ μ£„ 컀밋이 λ°œκ²¬λ˜μ—ˆμŠ΅λ‹ˆλ‹€
그런데 사과와 사과λ₯Ό λΉ„κ΅ν•˜λ©΄ 3.4(1.10)κ°€ 될 것이라고 μƒκ°ν•©λ‹ˆλ‹€.
setkey와 λ™μΌν•œ λ‹¨μœ„ ν…ŒμŠ€νŠΈλ₯Ό μ‚¬μš©ν•˜λŠ” 경우 3.6(1.12)보닀 μ—¬μ „νžˆ λΉ λ¦…λ‹ˆλ‹€.
두 버전 λͺ¨λ‘
즐거운 휴일 λ³΄λ‚΄μ„Έμš”

2019λ…„ 12μ›” 29일 μΌμš”μΌ 14:48 Cole Miller, [email protected] μ“΄:

@vk111 https://github.com/vk111 μΌλΆ€λ‘œ μ™„ν™”ν•  수 μžˆμŠ΅λ‹ˆλ‹€.
setindex λŒ€μ‹  setkeyλ₯Ό μ‚¬μš©ν•˜μ—¬ μ•½κ°„μ˜ μ‘°μ •. μ΄λ ‡κ²Œ ν•˜λ©΄ ν…ŒμŠ€νŠΈκ°€ μ€„μ–΄λ“­λ‹ˆλ‹€.
λ‚΄ μ»΄ν“¨ν„°μ˜ 절반 이상:

aa = data.table(a = seq(1,100), b = rep(0, 100))
bb = data.table(a = seq(1,100), b = rep(1, 100))

aa[, a1 := as.character(a)]
bb[, a1 := as.character(a)]

μ•ˆλ©΄ κ²½λ ¨()
for(i in c(1:1000)) {
aa[bb, b := ib, on=.(a, a1)] # ν‚€κ°€ μ—†λŠ” test1
}
λͺ©μ°¨()

4초 경과

μ•ˆλ©΄ κ²½λ ¨()
μ„ΈνŠΈν‚€(aa, a, a1)
μ„ΈνŠΈν‚€(bb, a, a1)

for(i in c(1:1000)) {
aa[bb, b := ib] # ν‚€κ°€ μ—†λŠ” test2
}
λͺ©μ°¨()

1.46초 경과

[이미지: 이미지]
https://user-images.githubusercontent.com/57992489/71557665-126d7880-2a17-11ea-8664-21a10deb47ca.png

라이브러리(마이크둜벀치마크)
라이브러리(data.table)

aa = data.table(a = seq(1,100), b = rep(0, 100))
bb = data.table(a = seq(1,100), b = rep(1, 100))

aa[, a1 := as.character(a)]
bb[, a1 := as.character(a)]

aa_nokey = 볡사(aa)
bb_nokey = 볡사(bb)

μ•ˆλ©΄ κ²½λ ¨()
aa_int_key = setkey(볡사(aa), a)
bb_int_key = setkey(볡사(bb), a)
λͺ©μ°¨()

μ•ˆλ©΄ κ²½λ ¨()
aa_int_char = setkey(볡사(aa), a, a1)
bb_int_char = setkey(볡사(bb), a, a1)
λͺ©μ°¨()
int_nokey = ν•¨μˆ˜(dt1, dt2){
dt1[dt2, b := ib, on=.(a)]
}

int_key = ν•¨μˆ˜(dt1, dt2){
dt1[dt2, b := ib]
}

int_char_nokey = ν•¨μˆ˜(dt1, dt2){
dt1[dt2, b := ib, on=.(a, a1)]
}

int_char_key = ν•¨μˆ˜(dt1, dt2){
dt1[dt2, b := ib]
}

int_char_key_on = ν•¨μˆ˜(dt1, dt2){
dt1[dt2, b := ib, on=.(a, a1)]
}

μƒμž κ·Έλ¦Ό(
마이크둜 벀치마크(
a_no_key = int_nokey(aa, bb),
a_key = int_key(aa_int_key, bb_int_key),
a_a1_no_key = int_char_nokey(aa, bb),
a_a1_key = int_char_key(aa_int_char, bb_int_char),
a_a1_key_on = int_char_key_on(aa_int_char, bb_int_char)
)
)

β€”
당신이 μ–ΈκΈ‰λ˜μ—ˆκΈ° λ•Œλ¬Έμ— 이것을 λ°›λŠ” κ²ƒμž…λ‹ˆλ‹€.
이 이메일에 직접 λ‹΅μž₯ν•˜κ³  GitHubμ—μ„œ ν™•μΈν•˜μ„Έμš”.
https://github.com/Rdatatable/data.table/issues/3928?email_source=notifications&email_token=ABRM7MPU64YBK7UNT3O3OYDQ3CTBRA5CNFSM4I4ZPREKYY3PNVWWK3TUL52HS4DFVEXG43VMVBW
λ˜λŠ” ꡬ독 μ·¨μ†Œ
https://github.com/notifications/unsubscribe-auth/ABRM7MKSP6LCUJD2HOAG7D3Q3CTBRANCNFSM4I4ZPREA
.

κ΄€λ ¨ν•˜μ—¬ 보λ₯˜ 쀑인 PR #4370이 μžˆμŠ΅λ‹ˆλ‹€. [ κ°€ 일반적으둜 λΆ€κ³Όν•˜λŠ” 더 적은 μ˜€λ²„ν—€λ“œλ‘œ 쑰인을 λ§Œλ“€ 수 μžˆμŠ΅λ‹ˆλ‹€. 예제의 타이밍을 2배둜 μ€„μž…λ‹ˆλ‹€. 데이터가 클수둝 κ°œμ„  사항은 μž‘μ•„μ§€μ§€λ§Œ λ°˜λŒ€λ‘œ 반볡이 λ§Žμ„μˆ˜λ‘ κ°œμ„  사항이 더 μ’‹μŠ΅λ‹ˆλ‹€. 쑰인 μ€‘μ—λŠ” 열을 μ—…λ°μ΄νŠΈν•  수 μžˆλŠ” 방법이 μ—†μŠ΅λ‹ˆλ‹€. 기본적으둜 쑰인 쀑에 열을 μΆ”κ°€ν•œ λ‹€μŒ fcoalesce 와 같은 것을 μ‚¬μš©ν•΄μ•Ό ν•˜μ§€λ§Œ μ„±λŠ₯이 μ’‹μ•„μ•Ό ν•©λ‹ˆλ‹€.
#4386도 λ³‘ν•©λ˜λ©΄ 속도가 μ’€ 더 빨라질 κ²ƒμž…λ‹ˆλ‹€.

library(data.table)
aa = data.table(a = seq(1,100), b = rep(0, 100))
bb = data.table(a = seq(1,100), b = rep(1, 100))
setindex(aa, a)
setindex(bb, a)
p = proc.time()[[3L]]
for (i in c(1:1000)) {
  aa[bb, b := i.b, on=.(a)]
}
proc.time()[[3L]]-p
#[1] 1.1

λ³‘ν•©μž #4370

library(data.table)
aa = data.table(a = seq(1,100), b = rep(0, 100))
bb = data.table(a = seq(1,100), b = rep(1, 100))
setindex(aa, a)
setindex(bb, a)
p = proc.time()[[3L]]
for (i in c(1:1000)) {
  mergelist(list(aa, bb), on="a")
}
proc.time()[[3L]]-p
#[1] 0.696

μ•ˆλ…• Jan, μ•Œμ•˜μ–΄ κ³ λ§ˆμ›Œ

데이터가 클수둝 κ°œμ„ μ€ μž‘μ§€λ§Œ λ°˜λ©΄μ—
더 λ§Žμ€ 반볡, 더 λ‚˜μ€ κ°œμ„ 
μ‹€μ œ λ¬Έμ œλŠ” λΉ… 데이터 및 λͺ‡ 가지 반볡과 관련이 μžˆμŠ΅λ‹ˆλ‹€.
~ μœ„μ—

2020λ…„ 5μ›” 4일 μ›”μš”μΌ, 00:33 Jan Gorecki, [email protected] μ“΄:

보λ₯˜ 쀑인 PR #4370이 μžˆμŠ΅λ‹ˆλ‹€.
https://github.com/Rdatatable/data.table/pull/4370 κ΄€λ ¨λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€. 그것
일반적으둜 λΆ€κ³Όν•˜λŠ” 더 적은 μ˜€λ²„ν—€λ“œλ‘œ 쑰인을 λ§Œλ“€ 수 μžˆμŠ΅λ‹ˆλ‹€. 그것은 κ°μ†Œ
2의 μš”μ†Œλ‘œ 예제의 타이밍. 데이터가 클수둝 μž‘μ•„μ§‘λ‹ˆλ‹€.
κ°œμ„ λ˜μ§€λ§Œ λ°˜λ©΄μ— 반볡이 λ§Žμ„μˆ˜λ‘ 더 μ’‹μŠ΅λ‹ˆλ‹€.
κ°œμ„ . 쑰인 μ€‘μ—λŠ” 열을 μ—…λ°μ΄νŠΈν•  수 μžˆλŠ” 방법이 μ—†μŠ΅λ‹ˆλ‹€. λ„ˆ
기본적으둜 쑰인 쀑에 열을 μΆ”κ°€ν•œ λ‹€μŒ λ‹€μŒκ³Ό 같은 것을 μ‚¬μš©ν•΄μ•Ό ν•©λ‹ˆλ‹€.
fcoalesceμ§€λ§Œ μ„±λŠ₯이 μ’‹μ•„μ•Ό ν•©λ‹ˆλ‹€.
ν•œ 번 더 속도λ₯Ό μ˜¬λ €μ•Ό ν•©λ‹ˆλ‹€. #4386
https://github.com/Rdatatable/data.table/pull/4386 도 λ³‘ν•©λ©λ‹ˆλ‹€.

라이브러리(data.table)aa = data.table(a = seq(1,100), b = rep(0, 100))bb = data.table(a = seq(1,100), b = rep(1, 100))
μ„ΈνŠΈ 인덱슀(aa, a)
setindex(bb, a)p = proc.time()[[3L]]for (i in c(1:1000)) {
aa[bb, b := ib, on=.(a)]
}
proc.time()[[3L]]-p#[1] 1.1

병합 λͺ©λ‘ #4370 https://github.com/Rdatatable/data.table/pull/4370

라이브러리(data.table)aa = data.table(a = seq(1,100), b = rep(0, 100))bb = data.table(a = seq(1,100), b = rep(1, 100))
μ„ΈνŠΈ 인덱슀(aa, a)
setindex(bb, a)p = proc.time()[[3L]]for (i in c(1:1000)) {
병합 λͺ©λ‘(λͺ©λ‘(aa, bb), on="a")
}
proc.time()[[3L]]-p#[1] 0.696

β€”
당신이 μ–ΈκΈ‰λ˜μ—ˆκΈ° λ•Œλ¬Έμ— 이것을 λ°›λŠ” κ²ƒμž…λ‹ˆλ‹€.
이 이메일에 직접 λ‹΅μž₯ν•˜κ³  GitHubμ—μ„œ ν™•μΈν•˜μ„Έμš”.
https://github.com/Rdatatable/data.table/issues/3928#issuecomment-623193573 ,
λ˜λŠ” ꡬ독 μ·¨μ†Œ
https://github.com/notifications/unsubscribe-auth/ABRM7MJR5THRHE3FIXXV3YTRPXWNNANCNFSM4I4ZPREA
.

#4440(μ–΄μ œ 병합됨)이 이 문제λ₯Ό ν•΄κ²°ν•˜λŠ”μ§€ ν™•μΈν–ˆμ§€λ§Œ ν•΄κ²°λ˜μ§€ μ•Šμ€ 것 κ°™μŠ΅λ‹ˆλ‹€. λ‚΄κ°€ 여기에 μ˜€λŠ” 타이밍은 @vk111 이 λ³΄κ³ ν•œ 타이밍과 μƒλ‹Ήνžˆ λ‹€λ₯΄μ§€λ§Œ μ΅œμ‹  개발 버전을 ν…ŒμŠ€νŠΈν•  수 μžˆλ‹€λ©΄ 도움이 될 μ›Œν¬ν”Œλ‘œμ— μ–΄λ–€ 차이가 μžˆλŠ”μ§€ ν™•μΈν•˜μ‹­μ‹œμ˜€.
Windowsλ₯Ό μ‚¬μš© μ€‘μ΄λ―€λ‘œ κ²°κ΅­ #4558에 도움이 될 수 μžˆλŠ” 또 λ‹€λ₯Έ 보λ₯˜ 쀑인 PR이 μžˆμŠ΅λ‹ˆλ‹€.


이것은 각 ν™˜κ²½μ—μ„œ μ‹€ν–‰ν•˜λŠ” 곡톡 μŠ€ν¬λ¦½νŠΈμž…λ‹ˆλ‹€.

library(data.table)
setDTthreads(2) ## vk111 has 4 cores
aa = data.table(a = seq(1,100), b = rep(0, 100))[,  a1 := as.character(a)]
bb = data.table(a = seq(1,100), b = rep(1, 100))[,  a1 := as.character(a)]
setindex(aa, a); setindex(bb, a)
cat("test1\n")
system.time({
for(i in c(1:1000)) {
  aa[bb, b := i.b, on=.(a, a1)] # test1
}})
cat("test2\n")
system.time({
for(i in c(1:1000)) {
  aa[bb, b := i.b, on=.(a)] # test2
}})

λ‹€μŒμ€ ν™˜κ²½μž…λ‹ˆλ‹€.

docker run -it --rm r-base:3.4.0
install.packages("https://cran.r-project.org/src/contrib/Archive/data.table/data.table_1.10.4-3.tar.gz", repos=NULL)
test1
   user  system elapsed 
  0.949   0.007   0.957 
test2
   user  system elapsed 
  0.864   0.000   0.864 
docker run -it --rm r-base:3.6.1
install.packages("https://cran.r-project.org/src/contrib/Archive/data.table/data.table_1.12.2.tar.gz", repos=NULL)
test1
   user  system elapsed 
  2.598   0.047   1.350 
test2
   user  system elapsed 
  2.092   0.016   1.062 



md5-e82041eef8382e88332d077bb608b87c



docker run -it --rm r-base:3.6.1
install.packages("data.table", repos="https://Rdatatable.gitlab.io/data.table")
test1
   user  system elapsed 
  1.174   0.045   1.219 
test2
   user  system elapsed 
  0.981   0.024   1.004 

μ•ˆλ…•ν•˜μ„Έμš”, μ €λŠ” Windows에 μžˆμŠ΅λ‹ˆλ‹€.

2020λ…„ 6μ›” 26일 κΈˆμš”μΌ 13:19 Jan Gorecki, μ•Œλ¦Ό @github.com이 μž‘μ„±ν–ˆμŠ΅λ‹ˆλ‹€.

#4440 https://github.com/Rdatatable/data.table/pull/4440 인지 ν™•μΈν–ˆμŠ΅λ‹ˆλ‹€.
이 문제λ₯Ό ν•΄κ²°ν–ˆμ§€λ§Œ ν•΄κ²°λ˜μ§€ μ•Šμ€ 것 κ°™μŠ΅λ‹ˆλ‹€. 비둝 λ‚΄κ°€ μ–»λŠ” 타이밍
@vk111이 λ³΄κ³ ν•œ 타이밍과 μƒλ‹Ήνžˆ λ‹€λ¦…λ‹ˆλ‹€.
https://github.com/vk111 , κ·Έλž˜μ„œ 졜근 κ°œλ°œμ„ ν…ŒμŠ€νŠΈν•  수 μžˆλ‹€λ©΄
버전을 ν™•μΈν•˜κ³  μ›Œν¬ν”Œλ‘œμ— μ–΄λ–€ 차이가 μžˆλŠ”μ§€ ν™•μΈν•©λ‹ˆλ‹€.
λ„μ›€μ΄λ˜λŠ”.
이것은 각 ν™˜κ²½μ—μ„œ μ‹€ν–‰ν•˜λŠ” 곡톡 μŠ€ν¬λ¦½νŠΈμž…λ‹ˆλ‹€.

라이브러리(data.table)
setDTthreads(2) ## vk111μ—λŠ” 4개의 μ½”μ–΄κ°€ μžˆμŠ΅λ‹ˆλ‹€.saa = data.table(a = seq(1,100), b = rep(0, 100))[, a1 := as.character(a)]bb = data.table(a = seq(1,100), b = rep(1, 100))[, a1 := as.character(a)]
μ„ΈνŠΈ 인덱슀(aa, a); μ„ΈνŠΈ 인덱슀(bb, a)
고양이("test1n")
system.time({for(i in c(1:1000)) {
aa[bb, b := ib, on=.(a, a1)] # test1
}})
고양이("test2n")
system.time({for(i in c(1:1000)) {
aa[bb, b := ib, on=.(a)] # test2
}})

λ‹€μŒμ€ ν™˜κ²½μž…λ‹ˆλ‹€.

도컀 μ‹€ν–‰ -it --rm r- base:3.4.0
install.packages("https://cran.r-project.org/src/contrib/Archive/data.table/data.table_1.10.4-3.tar.gz", repos=NULL)
ν…ŒμŠ€νŠΈ1
μ‚¬μš©μž μ‹œμŠ€ν…œ κ²½κ³Ό
0.949 0.007 0.957
ν…ŒμŠ€νŠΈ2
μ‚¬μš©μž μ‹œμŠ€ν…œ κ²½κ³Ό
0.864 0.000 0.864

도컀 μ‹€ν–‰ -it --rm r- 베이슀:3.6.1
install.packages("https://cran.r-project.org/src/contrib/Archive/data.table/data.table_1.12.2.tar.gz", repos=NULL)
ν…ŒμŠ€νŠΈ1
μ‚¬μš©μž μ‹œμŠ€ν…œ κ²½κ³Ό
2.598 0.047 1.350
ν…ŒμŠ€νŠΈ2
μ‚¬μš©μž μ‹œμŠ€ν…œ κ²½κ³Ό
2.092 0.016 1.062

도컀 μ‹€ν–‰ -it --rm r- 베이슀:3.6.1
install.packages("data.table", repos="https://Rdatatable.gitlab.io/data.table")
ν…ŒμŠ€νŠΈ1
μ‚¬μš©μž μ‹œμŠ€ν…œ κ²½κ³Ό
1.174 0.045 1.219
ν…ŒμŠ€νŠΈ2
μ‚¬μš©μž μ‹œμŠ€ν…œ κ²½κ³Ό
0.981 0.024 1.004

Windowsλ₯Ό μ‚¬μš© μ€‘μ΄λ―€λ‘œ κ²°κ΅­μ—λŠ” 보λ₯˜ 쀑인 또 λ‹€λ₯Έ PR이 μžˆμŠ΅λ‹ˆλ‹€.
도움말 #4558 https://github.com/Rdatatable/data.table/pull/4558 .

β€”
당신이 μ–ΈκΈ‰λ˜μ—ˆκΈ° λ•Œλ¬Έμ— 이것을 λ°›λŠ” κ²ƒμž…λ‹ˆλ‹€.
이 이메일에 직접 λ‹΅μž₯ν•˜κ³  GitHubμ—μ„œ ν™•μΈν•˜μ„Έμš”.
https://github.com/Rdatatable/data.table/issues/3928#issuecomment-650126662 ,
λ˜λŠ” ꡬ독 μ·¨μ†Œ
https://github.com/notifications/unsubscribe-auth/ABRM7MJLU3XRN5YN37ZVLALRYR727ANCNFSM4I4ZPREA
.

@vk111 예, μ •ν™•νžˆ μ œκ°€ μ§ˆλ¬Έν•œ λ‚΄μš©μž…λ‹ˆλ‹€. Windows μ‹œμŠ€ν…œμ—μ„œ ν•΄λ‹Ή 3개의 ꡬ성을 ν™•μΈν•˜κ³  진행 상황이 μžˆλŠ”μ§€ 확인할 수 μžˆλ‹€λ©΄.

κ·ΈλŸ¬λ‚˜ Windows용 pr이 아직 λ³‘ν•©λ˜μ§€ μ•Šμ€ κ²ƒμœΌλ‘œ μ•Œκ³  μžˆμŠ΅λ‹ˆλ‹€.

2020λ…„ 6μ›” 26일 κΈˆμš”μΌ 20:07 Jan Gorecki, μ•Œλ¦Ό @github.com μž‘μ„±:

@vk111 https://github.com/vk111 예, μ •ν™•νžˆ μ œκ°€ μ§ˆλ¬Έν•œ λ‚΄μš©μž…λ‹ˆλ‹€.
Windows μ‹œμŠ€ν…œμ—μ„œ ν•΄λ‹Ή 3개의 ꡬ성을 확인할 수 μžˆλ‹€λ©΄
당신을 μœ„ν•œ 진전이 μžˆλ‹€λ©΄.

β€”
당신이 μ–ΈκΈ‰λ˜μ—ˆκΈ° λ•Œλ¬Έμ— 이것을 λ°›λŠ” κ²ƒμž…λ‹ˆλ‹€.
이 이메일에 직접 λ‹΅μž₯ν•˜κ³  GitHubμ—μ„œ ν™•μΈν•˜μ„Έμš”.
https://github.com/Rdatatable/data.table/issues/3928#issuecomment-650320224 ,
λ˜λŠ” ꡬ독 μ·¨μ†Œ
https://github.com/notifications/unsubscribe-auth/ABRM7MMDOCNAWARCCDRSU23RYTPVFANCNFSM4I4ZPREA
.

4440은 이미 λ³‘ν•©λ˜μ–΄ λͺ¨λ“  OS에 도움이 λ©λ‹ˆλ‹€. #4558은 아직 병합 λŒ€κΈ° μ€‘μž…λ‹ˆλ‹€.

@vk111 #4558도 이미 λ³‘ν•©λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

μ•ˆλ…•ν•˜μ„Έμš” Jan, μ΅œκ·Όμ— 쑰언을 λ°›μ•˜μŠ΅λ‹ˆλ‹€ - #4419
λ‚΄ λ¬Έμ œμ™€ κ΄€λ ¨λœ https://github.com/Rdatatable/data.table/issues/4419
κ·Έλž˜μ„œ λ‚˜λŠ” λ¬Έμžκ°€ κ²°ν•© 된이 μ •ν™•ν•œ μ½”λ“œλ₯Ό 가지고 μžˆμ§€ μ•ŠμŠ΅λ‹ˆλ‹€.
ν•˜μ§€λ§Œ μ–΄μ¨Œλ“  이 κ°œμ„  사항에 λŒ€ν•΄ κ°μ‚¬λ“œλ¦½λ‹ˆλ‹€. λ§Žμ€ 도움이 될 것이라고 ν™•μ‹ ν•©λ‹ˆλ‹€.
미래의 μ‚¬λžŒλ“€μ€ 그것이 더 λ‚˜μ€ μ„±λŠ₯을 가지고 μžˆλ‹€κ³  λ―ΏλŠ”λ‹€λ©΄ λ‚˜λ³΄λ‹€
κ·Έλƒ₯ 병합해야 ν•  것 κ°™μ•„μš”
κ°μ‚¬ν•©λ‹ˆλ‹€

ΠΏΡ‚, 26 июн. 2020λ…„ Π² 20:29, μ–€ κ³ λ ˆν‚€ μ•Œλ¦Ό @github.com :

4440 https://github.com/Rdatatable/data.table/pull/4440 은 이미

λͺ¨λ“  OS에 λŒ€ν•œ 병합 및 도움말. #4558
https://github.com/Rdatatable/data.table/pull/4558 은 아직 보λ₯˜ μ€‘μž…λ‹ˆλ‹€.
병합.

β€”
당신이 μ–ΈκΈ‰λ˜μ—ˆκΈ° λ•Œλ¬Έμ— 이것을 λ°›λŠ” κ²ƒμž…λ‹ˆλ‹€.
이 이메일에 직접 λ‹΅μž₯ν•˜κ³  GitHubμ—μ„œ ν™•μΈν•˜μ„Έμš”.
https://github.com/Rdatatable/data.table/issues/3928#issuecomment-650330154 ,
λ˜λŠ” ꡬ독 μ·¨μ†Œ
https://github.com/notifications/unsubscribe-auth/ABRM7MIN2P7BXMKG74Z7EKTRYTSIJANCNFSM4I4ZPREA
.

--
μΉœμ• ν•˜λŠ”,
바싀리 μΏ μ¦ˆλ„€μ΄ˆν”„

@vk111 μ–ΈκΈ‰ν•œ PR은 이미 λ³‘ν•©λ˜μ—ˆμŠ΅λ‹ˆλ‹€. λ¬Έμ œλŠ” 이 λ¬Έμ œκ°€ ν•΄κ²°λ˜μ—ˆκ±°λ‚˜ μ΅œμ†Œν•œ κ°œμ„ λ˜μ—ˆλŠ”μ§€ μ—¬λΆ€λ₯Ό μ•„λŠ” κ²ƒμž…λ‹ˆλ‹€. λ³‘ν•©λœ PR은 이 문제λ₯Ό ν•΄κ²°ν•˜λ €κ³  μ‹œλ„ν•˜μ§€ μ•Šμ•˜μ§€λ§Œ 관련이 μžˆμœΌλ―€λ‘œ 도움이 될 수 μžˆμŠ΅λ‹ˆλ‹€.

μ²˜μŒμ— 보고된 μ΅œμ†Œν•œμ˜ μ˜ˆκ°€ 문제λ₯Ό μ œλŒ€λ‘œ λ“œλŸ¬λ‚΄μ§€ μ•Šμ•˜μŠ΅λ‹ˆλ‹€. @vk111 https://github.com/Rdatatable/data.table/issues/3928#issuecomment -538681316을 기반으둜 여기에 λ¬Έμ œκ°€ μžˆμŒμ„ λΆ„λͺ…νžˆ λ³΄μ—¬μ£ΌλŠ” 예제λ₯Ό κ΅¬μ„±ν–ˆμŠ΅λ‹ˆλ‹€.

install.packages("https://cran.r-project.org/src/contrib/Archive/data.table/data.table_1.10.4-3.tar.gz", repos=NULL)
install.packages("https://cran.r-project.org/src/contrib/Archive/data.table/data.table_1.12.2.tar.gz", repos=NULL)
install.packages("data.table", repos="https://Rdatatable.gitlab.io/data.table")
library(data.table)
setDTthreads(2L)
set.seed(108)
n2 = 1:366000
n1 = sample(n2, 30000)
d1=data.table(id1=paste0("id",sample(n1)), id2=paste0("id",sample(n1)), v1=n1)
d2=data.table(id1=paste0("id",sample(n2)), id2=paste0("id",sample(n2)), v2=n2)
system.time(d2[d1, v1 := i.v1, on=c("id1","id2")])



md5-e82041eef8382e88332d077bb608b87c



# 3.4.0: 1.10.4-3
   user  system elapsed 
  0.144   0.000   0.144 
# 3.4.0: 1.12.2
   user  system elapsed 
  0.611   0.003   0.451 
# 3.4.0: 1.12.9
   user  system elapsed 
  0.611   0.000   0.452 



md5-e82041eef8382e88332d077bb608b87c



# 4.0.0: 1.10.4-3
   user  system elapsed 
  0.203   0.008   0.211 
# 4.0.0: 1.12.9
   user  system elapsed 
  0.812   0.004   0.644 

verboseλŠ” bmerge forderv 에 λŒ€ν•œ 호좜인 Calculated ad hoc index in 0.611s elapsed (0.769s cpu) 에 λŒ€λΆ€λΆ„μ˜ μ‹œκ°„μ„ μ†ŒλΉ„ν–ˆμŒμ„ λ³΄μ—¬μ€λ‹ˆλ‹€.

예, μ •ν™•νžˆ
그런데 이 ν…ŒμŠ€νŠΈμ—μ„œ κ°œμ„ μ΄ μ—†λŠ” 것 κ°™μŠ΅λ‹ˆκΉŒ?

2020λ…„ 6μ›” 30일 ν™”μš”μΌ 00:45 Jan Gorecki, μ•Œλ¦Ό @github.com μž‘μ„±:

μ²˜μŒμ— 보고된 μ΅œμ†Œν•œμ˜ μ˜ˆμ œκ°€ μ œλŒ€λ‘œ λ…ΈμΆœλ˜μ§€ μ•ŠλŠ” κ²½μš°κ°€ λ°œμƒν•©λ‹ˆλ‹€.
문제. @vk111 https://github.com/vk111 #3928(λŒ“κΈ€) κΈ°μ€€
https://github.com/Rdatatable/data.table/issues/3928#issuecomment-538681316
여기에 λ¬Έμ œκ°€ μžˆμŒμ„ λΆ„λͺ…νžˆ λ³΄μ—¬μ£ΌλŠ” 예λ₯Ό κ΅¬μ„±ν–ˆμŠ΅λ‹ˆλ‹€.

라이브러리(data.table)
setDTthreads(2L)
set.seed(108)n2 = 1:366000n1 = sample(n2, 30000)d1=data.table(id1=paste0("id",sample(n1)), id2=paste0("id",sample(n1)) ), v1=n1)d2=data.table(id1=paste0("id",sample(n2)), id2=paste0("id",sample(n2)), v2=n2)
system.time(d2[d1, v1 := i.v1, on=c("id1","id2")])

3.4.0: 1.10.4-3

μ‚¬μš©μž μ‹œμŠ€ν…œ κ²½κ³Ό
0.144 0.000 0.144

3.4.0: 1.12.2

μ‚¬μš©μž μ‹œμŠ€ν…œ κ²½κ³Ό
0.611 0.003 0.451

3.4.0: 1.12.9

μ‚¬μš©μž μ‹œμŠ€ν…œ κ²½κ³Ό
0.611 0.000 0.452

4.0.0: 1.12.9

μ‚¬μš©μž μ‹œμŠ€ν…œ κ²½κ³Ό
0.812 0.004 0.644

β€”
당신이 μ–ΈκΈ‰λ˜μ—ˆκΈ° λ•Œλ¬Έμ— 이것을 λ°›λŠ” κ²ƒμž…λ‹ˆλ‹€.
이 이메일에 직접 λ‹΅μž₯ν•˜κ³  GitHubμ—μ„œ ν™•μΈν•˜μ„Έμš”.
https://github.com/Rdatatable/data.table/issues/3928#issuecomment-651408089 ,
λ˜λŠ” ꡬ독 μ·¨μ†Œ
https://github.com/notifications/unsubscribe-auth/ABRM7MPQHSOEGLXS625BU3TRZEKSBANCNFSM4I4ZPREA
.

κ°œμ„ λ˜μ§€ μ•Šμ•˜μœΌλ©° μ—¬μ „νžˆ λ¬Έμ œμž…λ‹ˆλ‹€.
파기 ν›„ 병λͺ© ν˜„μƒμ΄ λ°œκ²¬λ˜μ—ˆμŠ΅λ‹ˆλ‹€.
https://github.com/Rdatatable/data.table/blob/ba32f3cba38ec270587e395f6e6c26a80be36be6/src/forder.c#L282
더 λ‚˜μ•„κ°€...
이 λ£¨ν”„λŠ” 60%λ₯Ό λ‹΄λ‹Ήν•©λ‹ˆλ‹€.
https://github.com/Rdatatable/data.table/blob/ba32f3cba38ec270587e395f6e6c26a80be36be6/src/forder.c#L242 -L245
그리고 30%
https://github.com/Rdatatable/data.table/blob/ba32f3cba38ec270587e395f6e6c26a80be36be6/src/forder.c#L252 -L258

R λ‚΄λΆ€(ν•¨μˆ˜κ°€ μ•„λ‹Œ 맀크둜 CHAR() )λ₯Ό μ‚¬μš©ν•˜λŠ” 것이 도움이 λ˜λŠ”μ§€ ν™•μΈν•˜λ €κ³  μ‹œλ„ν–ˆμ§€λ§Œ 도움이 λ˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.


훨씬 더 μ΅œμ†Œν•œμ˜ 예, forderv νƒ€μ΄λ°λ§Œ, R 4.0μ—μ„œλ§Œ

install.packages("https://cran.r-project.org/src/contrib/Archive/data.table/data.table_1.10.4-3.tar.gz", repos=NULL)
library(data.table)
setDTthreads(1L)
set.seed(108)
n2 = 1:366000
d2=data.table(id1=paste0("id",sample(n2)), id2=paste0("id",sample(n2)), v2=n2)
system.time(data.table:::forderv(d2, c("id1","id2")))
install.packages("data.table", repos="https://Rdatatable.gitlab.io/data.table")
library(data.table)
setDTthreads(1L)
set.seed(108)
n2 = 1:366000
d2=data.table(id1=paste0("id",sample(n2)), id2=paste0("id",sample(n2)), v2=n2)
system.time(data.table:::forderv(d2, c("id1","id2")))



md5-e82041eef8382e88332d077bb608b87c



# 4.0.2: 1.10.4-3
   user  system elapsed 
  0.198   0.000   0.198 
# 4.0.2: 1.12.9
   user  system elapsed 
  0.393   0.000   0.392 

μ—¬κΈ°μ—μ„œ R λ‚΄λΆ€(ν•¨μˆ˜κ°€ μ•„λ‹Œ 맀크둜인 CHAR())λ₯Ό μ‚¬μš©ν•˜λŠ” 것이 도움이 λ˜λŠ”μ§€ ν™•μΈν•˜λ €κ³  μ‹œλ„ν–ˆμ§€λ§Œ 도움이 λ˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

R이 더 이상 κ·Έλ ‡κ²Œν•˜μ§€ μ•ŠκΈ° λ•Œλ¬Έμž…λ‹ˆλ‹€. USE_RINTERNALSλ₯Ό μ‚¬μš©ν•˜λ©΄ INTEGER, REAL 및 CHAR도 μ—¬μ „νžˆ 인라인 ν•¨μˆ˜λΌκ³  κ°€μ •ν•©λ‹ˆλ‹€. λ‹€μ‹œ λ§ν•΄μ„œ, ALTREPλ₯Ό ν—ˆμš©ν•˜κΈ° μœ„ν•΄ μ΅œμ‹  λ²„μ „μ˜ Rμ—μ„œ USE_RINTERNALS의 이점(즉, κΈ°λŠ₯ λŒ€μ‹  맀크둜)이 μ œκ±°λ˜μ—ˆμŠ΅λ‹ˆλ‹€. λ‚˜λŠ” 그것이 λ§€ν¬λ‘œμΈμ§€, ν•¨μˆ˜μΈμ§€, 인라인 ν•¨μˆ˜μΈμ§€ κ·Έ 자체둜 차이λ₯Ό λ§Œλ“ λ‹€κ³  μƒκ°ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. μž‘μ—… λ‹¨μœ„ λ‚΄μ—μ„œ R이 μˆ˜ν–‰ν•˜λŠ” μž‘μ—…μž…λ‹ˆλ‹€. μ˜ˆμ „μ—λŠ” USE_RINTERNALSκ°€ 이λ₯Ό 맀크둜둜 λ§Œλ“€κ³  직접적인 λ©”λͺ¨λ¦¬ 쑰회(λ²‘ν„°μ˜ 헀더λ₯Ό κ³ λ €ν•œ λ°°μ—΄ μ—­μ°Έμ‘°)μ˜€κΈ° λ•Œλ¬Έμ— 속도가 더 λΉ¨λžμŠ΅λ‹ˆλ‹€. 그것은 맀우 κ°€λ²Όμš΄ μž‘μ—… λ‹¨μœ„μ˜€μŠ΅λ‹ˆλ‹€. μš”μ¦˜ Rμ—λŠ” ALTREPλ₯Ό 검사할 λΆ„κΈ°κ°€ ν•˜λ‚˜ 이상 있으며 λΆ„κΈ° μ˜ˆμΈ‘μ„ μ‚¬μš©ν•˜λ”λΌλ„ μΆ”κ°€ μž‘μ—…μ΄ μΆ”κ°€λ˜κ±°λ‚˜ ν”„λ¦¬νŽ˜μΉ˜λ₯Ό λ°©μ§€ν•©λ‹ˆλ‹€. λ‹€μ‹œ 말해, R은 이제 μ΄λŸ¬ν•œ 인라인 ν•¨μˆ˜ 내뢀에 μ½”λ“œκ°€ 쑰금 더 λ§ŽμŠ΅λ‹ˆλ‹€. λ‚˜λŠ” 벀치마크 증거가 μ—†κ³  단지 그것을 λ³΄λŠ” 것에 κΈ°μ΄ˆν•œ 이둠일 λΏμž…λ‹ˆλ‹€.

κ·Όλ³Έ 원인은 cradix_r μ—μ„œ λ‹€μŒ λΆ„κΈ°λ₯Ό μ œκ±°ν•˜λŠ” 것일 수 μžˆμŠ΅λ‹ˆλ‹€.
https://github.com/Rdatatable/data.table/blob/76bb569fd7736b5f89471a35357e6a971ae1d424/src/forder.c#L780 -L783
이제 길이 2의 μž…λ ₯μ—λŠ” 단락이 μ—†μŠ΅λ‹ˆλ‹€.
κΈ°λŠ₯이 μž‘λ™ 방식 μΈ‘λ©΄μ—μ„œ 많이 λ³€κ²½λ˜μ—ˆκΈ° λ•Œλ¬Έμ— μ§€κΈˆ ν•΄λ‹Ή λΆ„κΈ°λ₯Ό λ°°μΉ˜ν•˜λŠ” 방법이 λͺ…ν™•ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

이 νŽ˜μ΄μ§€κ°€ 도움이 λ˜μ—ˆλ‚˜μš”?
0 / 5 - 0 λ“±κΈ‰