Skip to content
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

Reduce Frequency of Garbage Collection #78

Open
brodieG opened this issue Sep 7, 2017 · 1 comment
Open

Reduce Frequency of Garbage Collection #78

brodieG opened this issue Sep 7, 2017 · 1 comment
Milestone

Comments

@brodieG
Copy link
Owner

brodieG commented Sep 7, 2017

Clearly qassert triggers way fewer GCs:

> gcinfo(TRUE)
[1] TRUE
> simple_vet <- function(x) vet(numeric(2L) && !anyNA(.), x, stop=TRUE)
> nums <- runif(2)
> for(i in 1:5e4) simple_vet(nums)
Garbage collection 206 = 155+20+31 (level 0) ... 
35.8 Mbytes of cons cells used (38%)
16.4 Mbytes of vectors used (32%)
Garbage collection 207 = 156+20+31 (level 0) ... 
35.8 Mbytes of cons cells used (38%)
16.4 Mbytes of vectors used (32%)
Garbage collection 208 = 157+20+31 (level 0) ... 
35.8 Mbytes of cons cells used (38%)
16.5 Mbytes of vectors used (32%)
Garbage collection 209 = 157+21+31 (level 1) ... 
35.8 Mbytes of cons cells used (38%)
16.4 Mbytes of vectors used (32%)
Garbage collection 210 = 158+21+31 (level 0) ... 
35.8 Mbytes of cons cells used (38%)
16.4 Mbytes of vectors used (32%)
Garbage collection 211 = 159+21+31 (level 0) ... 
35.8 Mbytes of cons cells used (38%)
16.4 Mbytes of vectors used (32%)
Garbage collection 212 = 160+21+31 (level 0) ... 
35.8 Mbytes of cons cells used (38%)
16.4 Mbytes of vectors used (32%)
Garbage collection 213 = 161+21+31 (level 0) ... 
35.8 Mbytes of cons cells used (38%)
16.4 Mbytes of vectors used (32%)
Garbage collection 214 = 162+21+31 (level 0) ... 
35.8 Mbytes of cons cells used (38%)
16.4 Mbytes of vectors used (32%)
Garbage collection 215 = 163+21+31 (level 0) ... 
35.8 Mbytes of cons cells used (38%)
16.4 Mbytes of vectors used (32%)
Garbage collection 216 = 164+21+31 (level 0) ... 
35.8 Mbytes of cons cells used (38%)
16.4 Mbytes of vectors used (32%)
Garbage collection 217 = 165+21+31 (level 0) ... 
35.8 Mbytes of cons cells used (38%)
16.4 Mbytes of vectors used (32%)
Garbage collection 218 = 166+21+31 (level 0) ... 
35.8 Mbytes of cons cells used (38%)
16.4 Mbytes of vectors used (32%)
Garbage collection 219 = 167+21+31 (level 0) ... 
35.8 Mbytes of cons cells used (38%)
16.4 Mbytes of vectors used (32%)
> simple_2 <- function(x) qassert(x, "N2")
> for(i in 1:5e4) simple_qassert(nums)
Error in simple_qassert(nums) : could not find function "simple_qassert"
> for(i in 1:5e4) simple_2(nums)
Garbage collection 220 = 168+21+31 (level 0) ... 
35.8 Mbytes of cons cells used (38%)
16.5 Mbytes of vectors used (32%)
@brodieG brodieG added this to the 0.2.0 milestone Sep 7, 2017
@brodieG
Copy link
Owner Author

brodieG commented Mar 3, 2020

Part of the issue is we use R_alloc to initialize strings for every possible step an error could occur, which creates dozens of likely unnecessary allocations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant