You could try using the GRASS GIS tool, v.rast.stats to see it is more efficient. In order to get set-up in GRASS with your Location and Mapset, please review the tutorial here and associated 'Getting Started docs'. Once inside your GRASS location,you could run the following commands:
##import your polygon
v.in.ogr input=cbg.shp output=cbg
##import your raster
r.in.gdal input=canopy.tif output=canopy
##calculate univariate statistics for each polygon, including mean
v.rast.stats map=cbg raster=canopy column_prefix=stat_ method=mean
You can also leave the
method empty to calculate a range of default statistics.
Alternatively, you could try to run the tool from within QGIS, see screenshot below:
Regarding your second question concerning
extract_exact, perhaps you need to remove NAs, have you tried:
rasta = raster('canopy.tif')
poly3 = st_read("cbg.shp")
foliage <- exact_extract(rasta, poly3, 'mean', na.rm=TRUE)
More details here
While the approaches outlined above are valid, you may still need to consider tiling (e.g.
gdal_retile.py) your dataset in order to reduce the associated file size of your raster.