improve %chin% performance
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Refactor
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- r
- Domain
- performance
Research direction
Start with the discussion in pull request 5168 and locate the implementation of %chin% in the data.table source. Benchmark the current behavior for length-one and small inputs, including allocation of expressions such as c("one", "two"), then compare any change against the larger-input path; done means a measured performance improvement without regressions.
Written by the indexing model from the issue text.
Description
Follow-up to https://github.com/Rdatatable/data.table/pull/5168#discussion_r807656380
const SEXP *td = STRING_PTR(PROTECT(coerceUtf8IfNeeded(table))) is always calling PROTECT even in the most common case that no coerce is needed. I don't know how much time PROTECT adds.
if (xlen==1) case is good for when length(x)==1. That could be extended to a double-loop for length(x)<=5, say, and only use the relatively heavier truelength approach for larger input.
Note that in data.table internals at R level where we use x %chin% c("one", "two") then that c("one","two") is an allocation and is probably happening on each call (it's possible the R compiler to byte code optimizes that but I'd be surprised if it does). So for decision making w.r.t. data.table internals (whether to use %chin% or ||), the benchmark needs to include the c("one","two")rather than timing %chin% in isolation, iiuc.
- Dominant language
- R
- Stars
- 3.9k
- Forks
- 1.1k
- Avg merge
- 14h 4m
- Merged PRs (30d)
- 4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Rdatatable/data.table
-
as.data.table() recurses without end on a survival::Surv object (or any data.frame carrying one) Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Rdatatable/data.table#7887 ·
-
consistency tests
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Rdatatable/data.table#7853 · 3 comments ·
-
internals
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Rdatatable/data.table#6938 · 1 comment ·
-
encoding fread
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Rdatatable/data.table#5179 · 8 comments ·
-
documentation programming
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Rdatatable/data.table#3199 · 3 comments ·
All issues in Rdatatable/data.table
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
r-lib/pkgdepends#485 · 3 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
beginners blocker
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enviPathR OpenBuild Error Build OK Build Warning policies-accepted pre-review precheck-passed
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Bioconductor/BiocContributions#207 · 6 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
datacarpentry/semester-biology#1255 ·