PIP-Technical-Team / pipapi

What the Package Does (One Line, Title Case)
https://pip-technical-team.github.io/pipapi/
Other
3 stars 0 forks source link

Fix all cache #422

Closed shahronak47 closed 2 months ago

shahronak47 commented 2 months ago

This PR aims at removing future and promises dependencies and other code related to it.

  1. Removes packages dependencies - future, promises , future.callr, future.apply
  2. Don't treat country = "all" and year = "all" differently
  3. Remove is_forked function which checks if the calculation is intensive and uses future and promise for those calls.
  4. Remove the endpoint /n-workers and it's associated tests.
  5. Add vignette with some information about caching debugging
  6. Added test to ensure that we have all the packages imported that we use in the file endpoints.R
shahronak47 commented 2 months ago

Checking the performance on DEV branch vs fix-all-cache branch

DEV branch performance

path1 <- "api/v1/pc-charts?country=all&year=all&povline=1.2&ppp_version=2017&fill_gaps=true"
path2 <- "api/v1/pip?country=all&year=all&povline=5&ppp_version=2017&fill_gaps=false"

tictoc::tic()
d <- httr::GET(local$root_url, 
               port = local$port, 
               path = path1) |> 
  httr::content(encoding = "UTF-8")
tictoc::toc()
61.26 sec elapsed

tictoc::tic()
d <- httr::GET(local$root_url, 
               port = local$port, 
               path = path2) |> 
  httr::content(encoding = "UTF-8")
tictoc::toc()
17.19 sec elapsed

fix-all-cache branch performance

tictoc::tic()
d <- httr::GET(local$root_url, 
               port = local$port, 
               path = path1) |> 
  httr::content(encoding = "UTF-8")
tictoc::toc()
58.28 sec elapsed

tictoc::tic()
d <- httr::GET(local$root_url, 
               port = local$port, 
               path = path2) |> 
  httr::content(encoding = "UTF-8")
tictoc::toc()
16.97 sec elapsed