R-nvim / R.nvim

Neovim plugin to edit R files
GNU General Public License v3.0
155 stars 16 forks source link

Faster caching #83

Closed jalvesaq closed 6 months ago

jalvesaq commented 6 months ago

Decrease the time to build objls and args files.

jalvesaq commented 6 months ago

I replaced code based on the gbRd from 2012 with a new one, using functions from the tools package that perhaps were not available at the time. The building of cache files is noticeably faster now.

PMassicotte commented 6 months ago

Great! Will try that when I am at the office in few hours!

PMassicotte commented 6 months ago

It works good. But :messages give me some errors:

Why build nvimcom: nvimcom version mismatch                                                                                                                                                               
before_rns.R stdout: * checking for file ‘/home/filoche/.local/share/nvim/lazy/R.nvim/nvimcom/DESCRIPTION’ ...                                                                                            
 OK                                                                                                                                                                                                       
* preparing ‘nvimcom’:                                                                                                                                                                                    
* checking DESCRIPTION meta-information ...                                                                                                                                                               
 OK                                                                                                                                                                                                       
* cleaning src                                                                                                                                                                                            
* checking for LF line-endings in source and make files and shell scripts                                                                                                                                 
* checking for empty or unneeded directories                                                                                                                                                              
* building ‘nvimcom_0.9.32.tar.gz’                                                                                                                                                                        
gcc -I"/usr/share/R/include" -DNDEBUG       -fpic  -g -O2 -ffile-prefix-map=/build/r-base-14Q6vq/r-base-4.3.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 
 -c common.c -o common.o                                                                                                                                                                                  
gcc -I"/usr/share/R/include" -DNDEBUG       -fpic  -g -O2 -ffile-prefix-map=/build/r-base-14Q6vq/r-base-4.3.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 
 -c nvimcom.c -o nvimcom.o                                                                                                                                                                                
gcc -I"/usr/share/R/include" -DNDEBUG       -fpic  -g -O2 -ffile-prefix-map=/build/r-base-14Q6vq/r-base-4.3.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 
 -c rd2md.c -o rd2md.o                                                                                                                                                                                    
(cd apps; make)                                                                                                                                                                                           
make[1]: Entering directory '/tmp/RtmpyPsdKa/R.INSTALL928be37ac7b11/nvimcom/src/apps'cc -pthread -std=gnu99 -O2 -Wall rnvimserver.c utilities.c data_structures.c logging.c ../common.c -o rnvimserver    
gcc -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro -o nvimcom.so common.o nvimcom.o rd2md.o -L/usr/lib/R/lib -lR                                  
make[1]: Leaving directory '/tmp/RtmpyPsdKa/R.INSTALL928be37ac7b11/nvimcom/src/apps'                                                                                                                      

stderr of last completion data building:                                                                                                                                                                  

nvimcom info:                                                                                                                                                                                             
  Rversion: 4.3.3                                                                                                                                                                                         
  version: 0.9.32                                                                                                                                                                                         
  home: /home/filoche/R/x86_64-pc-linux-gnu-library/4.3/nvimcom                                                                                                                                           
Build time:                                                                                                                                                                                               
  methods: 0.20965 + 0.03047                                                                                                                                                                              
  nvimcom: 0.00956 + 0.00337                                                                                                                                                                              
  grDevices: 0.10488 + 0.0362                                                                                                                                                                             
  graphics: 0.10694 + 0.06738                                                                                                                                                                             
  base: 1.21125 + 0.20692                                                                                                                                                                                 
  utils: 0.20027 + 0.17811                                                                                                                                                                                
  datasets: 0.07689 + 0.00257                                                                                                                                                                             
  stats: 0.61305 + 0.19031                                                                                                                                                                                
Time:                                                                                                                                                                                                     
  global setup: 0.000102202                                                                                                                                                                               
  before_rns.R: 2.14307114                                                                                                                                                                                
  unix setup: 1.6582e-05                                                                                                                                                                                  
before_rns.R stderr: Warning in system2(command, args, stdout = NULL, stderr = NULL, ...) :  error in running command   
PMassicotte commented 6 months ago

Other than that, build time is super fast!

jalvesaq commented 6 months ago

The "Warning in system2" doesn't tell what command had errors, and I don't get this message here...

PMassicotte commented 6 months ago

The error is gone now, probably occurred on first cache build.

One error I always had (even with the old nvimr) is this:

image

Do you know where it could occur?

Anyhow, I think we can merge this, good job again!

jalvesaq commented 6 months ago

Thanks!

The error when trying to open _cache/DESCRIPTION happens when rnvimserver tries to read the DESCRIPTION file of an installed package. In this case, of course, _cache is not a package. We have two options:

The warning was supposed to be an alert that something was wrong. More precisely, when completing the first argument of library() you wouldn't get the title and description of a package whose DESCRIPTION file wasn't found. Considering that this part of the code seems to be working well, I think the best option is not to emit the alert. If indeed rnvimserver fails to get the package description, we would depend on users reporting the missing description in the completion menu.

PMassicotte commented 6 months ago

Thank you for your detailed answers, it makes sens now.

Considering that this part of the code seems to be working well, I think the best option is not to emit the alert.

I think it is completely reasonable to do it so!

jalvesaq commented 6 months ago

Done!