From bc374ea8ee866085302335a928c4b556ef882df2 Mon Sep 17 00:00:00 2001 From: Mauricio 'Pacha' Vargas Sepulveda Date: Sat, 10 Aug 2024 16:52:05 -0400 Subject: [PATCH] add cores documentation --- README.Rmd | 33 +++++-- README.md | 30 ++++++- dev/benchmarks_tests_agtpa_capybara_only.R | 2 +- .../get_index_list.cpp | 0 .../test-get_index_list.R | 0 dev/{ => replication}/cudata.rds | Bin dev/{ => replication}/currency_unions_tidy.r | 0 dev/valgrind-kendall-correlation.r | 9 ++ docs/index.html | 82 ++++++++++++++++-- docs/pkgdown.yml | 2 +- docs/reference/apes.html | 2 +- docs/reference/bias_corr.html | 2 +- docs/reference/feglm.html | 4 +- docs/reference/felm.html | 2 +- docs/reference/fenegbin.html | 2 +- docs/reference/fepoisson.html | 2 +- src/00_main.h | 2 +- src/06_glm_offset_fit.cpp | 2 - src/Makevars | 2 +- src/Makevars.win | 2 +- 20 files changed, 150 insertions(+), 30 deletions(-) rename dev/{ => functions_that_i_might_use_later}/get_index_list.cpp (100%) rename dev/{ => functions_that_i_might_use_later}/test-get_index_list.R (100%) rename dev/{ => replication}/cudata.rds (100%) rename dev/{ => replication}/currency_unions_tidy.r (100%) create mode 100644 dev/valgrind-kendall-correlation.r diff --git a/README.Rmd b/README.Rmd index c68bfe7..52daac1 100644 --- a/README.Rmd +++ b/README.Rmd @@ -125,13 +125,34 @@ Memory allocation for the same models | **Capybara** | 27MB | 32MB | 20MB | 23MB | 29MB | 43MB | | Fixest | 44MB | 36MB | 27MB | 32MB | 41MB | 63MB | -# Debugging +## Changing the number of cores -I run `r_valgrind "dev/test_get_alpha.r"` or the corresponding test from the -project's root in a new terminal (bash). +Note that you can edit the `Makevars` file to change the number of cores that +capybara uses, here is an example of how it affects the performance + +| cores | PPML | Trade Diversion | Endogeneity | Reverse Causality | Non-linear/Phasing Effects | Globalization | +|:------|-------:|-----------------:|------------:|------------------:|---------------------------:|--------------:| +| 2 | 1.8s | 16.2s | 7.7s | 9.6s | 13.0s | 24.0s | +| 4 | 1.7s | 16.0s | 7.4s | 9.3s | 12.3s | 23.6s | +| 6 | 0.7s | 2.4s | 2.0s | 2.0s | 2.5s | 4.0s | +| 8 | 0.3s | 2.0s | 1.2s | 1.4s | 1.7s | 3.4s | + +## Testing and debugging + +## Testing + +I use `testthat` (e.g., `devtools::test()`) to compare the results with base R. +These tests are about the correctness of the results. + +### Debuging + +I run `r_valgrind "dev/valgrind-kendall-correlation.r"` or the corresponding +test from the project's root in a new terminal (bash) after running +`devtools::install()`. These tests are about memory leaks (e.g., I use +repeteated computations and sometimes things such as "pi = 3"). This works because I previously defined this in `.bashrc`, to make it work you -need to run `source ~/.bashrc` or reboot: +need to run `source ~/.bashrc` or reboot your computer. ``` function r_debug_symbols () { @@ -209,4 +230,6 @@ When you are ready testing, you need to remove `-UDEBUG` from `src/Makevars`. ## Code of Conduct -Please note that the capybara project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms. +Please note that the capybara project is released with a +[Contributor Code of Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html). +By contributing to this project, you agree to abide by its terms. diff --git a/README.md b/README.md index 6e7f27b..9a0bbbe 100644 --- a/README.md +++ b/README.md @@ -118,13 +118,35 @@ Memory allocation for the same models | **Capybara** | 27MB | 32MB | 20MB | 23MB | 29MB | 43MB | | Fixest | 44MB | 36MB | 27MB | 32MB | 41MB | 63MB | -# Debugging +## Changing the number of cores -I run `r_valgrind "dev/test_get_alpha.r"` or the corresponding test from -the project’s root in a new terminal (bash). +Note that you can edit the `Makevars` file to change the number of cores +that capybara uses, here is an example of how it affects the performance + +| cores | PPML | Trade Diversion | Endogeneity | Reverse Causality | Non-linear/Phasing Effects | Globalization | +| :---- | ---: | --------------: | ----------: | ----------------: | -------------------------: | ------------: | +| 2 | 1.8s | 16.2s | 7.7s | 9.6s | 13.0s | 24.0s | +| 4 | 1.7s | 16.0s | 7.4s | 9.3s | 12.3s | 23.6s | +| 6 | 0.7s | 2.4s | 2.0s | 2.0s | 2.5s | 4.0s | +| 8 | 0.3s | 2.0s | 1.2s | 1.4s | 1.7s | 3.4s | + +## Testing and debugging + +## Testing + +I use `testthat` (e.g., `devtools::test()`) to compare the results with +base R. These tests are about the correctness of the results. + +### Debuging + +I run `r_valgrind "dev/valgrind-kendall-correlation.r"` or the +corresponding test from the project’s root in a new terminal (bash) +after running `devtools::install()`. These tests are about memory leaks +(e.g., I use repeteated computations and sometimes things such as “pi = +3”). This works because I previously defined this in `.bashrc`, to make it -work you need to run `source ~/.bashrc` or reboot: +work you need to run `source ~/.bashrc` or reboot your computer. function r_debug_symbols () { # if src/Makevars does not exist, exit diff --git a/dev/benchmarks_tests_agtpa_capybara_only.R b/dev/benchmarks_tests_agtpa_capybara_only.R index 236574f..d42f37a 100644 --- a/dev/benchmarks_tests_agtpa_capybara_only.R +++ b/dev/benchmarks_tests_agtpa_capybara_only.R @@ -1,7 +1,7 @@ # this is not just about speed/memory, but also about obtaining the same # slopes as in base R -library(capybara) +devtools::load_all() library(dplyr) library(tidyr) library(janitor) diff --git a/dev/get_index_list.cpp b/dev/functions_that_i_might_use_later/get_index_list.cpp similarity index 100% rename from dev/get_index_list.cpp rename to dev/functions_that_i_might_use_later/get_index_list.cpp diff --git a/dev/test-get_index_list.R b/dev/functions_that_i_might_use_later/test-get_index_list.R similarity index 100% rename from dev/test-get_index_list.R rename to dev/functions_that_i_might_use_later/test-get_index_list.R diff --git a/dev/cudata.rds b/dev/replication/cudata.rds similarity index 100% rename from dev/cudata.rds rename to dev/replication/cudata.rds diff --git a/dev/currency_unions_tidy.r b/dev/replication/currency_unions_tidy.r similarity index 100% rename from dev/currency_unions_tidy.r rename to dev/replication/currency_unions_tidy.r diff --git a/dev/valgrind-kendall-correlation.r b/dev/valgrind-kendall-correlation.r new file mode 100644 index 0000000..c70aef2 --- /dev/null +++ b/dev/valgrind-kendall-correlation.r @@ -0,0 +1,9 @@ +# this is also tested in /tests + +set.seed(123) +x <- rnorm(100) +y <- rpois(100, 2) + +for (i in 1:100) { + kendall_cor(x, y) +} diff --git a/docs/index.html b/docs/index.html index 736e433..9b362ff 100644 --- a/docs/index.html +++ b/docs/index.html @@ -90,7 +90,6 @@
-
@@ -254,12 +253,80 @@

Benchmarks +

Changing the number of cores +

+

Note that you can edit the Makevars file to change the number of cores that capybara uses, here is an example of how it affects the performance

+ +++++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
coresPPMLTrade DiversionEndogeneityReverse CausalityNon-linear/Phasing EffectsGlobalization
21.8s16.2s7.7s9.6s13.0s24.0s
41.7s16.0s7.4s9.3s12.3s23.6s
60.7s2.4s2.0s2.0s2.5s4.0s
80.3s2.0s1.2s1.4s1.7s3.4s

-
-

Debugging -

-

I run r_valgrind "dev/test_get_alpha.r" or the corresponding test from the project’s root in a new terminal (bash).

-

This works because I previously defined this in .bashrc, to make it work you need to run source ~/.bashrc or reboot:

+

Testing and debugging +

+
+

Testing +

+

I use testthat (e.g., devtools::test()) to compare the results with base R. These tests are about the correctness of the results.

+
+

Debuging +

+

I run r_valgrind "dev/valgrind-kendall-correlation.r" or the corresponding test from the project’s root in a new terminal (bash) after running devtools::install(). These tests are about memory leaks (e.g., I use repeteated computations and sometimes things such as “pi = 3”).

+

This works because I previously defined this in .bashrc, to make it work you need to run source ~/.bashrc or reboot your computer.

function r_debug_symbols () {
     # if src/Makevars does not exist, exit
     if [ ! -f src/Makevars ]; then
@@ -325,13 +392,14 @@ 

Debugging

Code of Conduct

Please note that the capybara project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

-