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 memory usage #56

Closed
geospatial-jeff opened this issue Jun 24, 2020 · 1 comment · Fixed by #57
Closed

Reduce memory usage #56

geospatial-jeff opened this issue Jun 24, 2020 · 1 comment · Fixed by #57

Comments

@geospatial-jeff
Copy link
Owner

geospatial-jeff commented Jun 24, 2020

Aiocogeo uses ~4x more memory than rio tiler when reading a single tile:

Line #    Mem usage    Increment   Line Contents
================================================
    44    115.3 MiB    115.3 MiB   @profile
    45                             def main():
    46    125.7 MiB     10.4 MiB       asyncio.run(_aiocogeo())
    47    128.5 MiB      2.8 MiB       rio_tile()

The culprit is the call to skimage.resize when resampling the image:

Line #    Mem usage    Increment   Line Contents
================================================
   292    118.9 MiB    118.9 MiB       @profile
   293                                 def _postprocess(
   294                                     self, arr: NpArrayType, img_tiles: TileMetadata, out_shape: Tuple[int, int]
   295                                 ) -> NpArrayType:
   296                                     """Wrapper around ``_clip_array`` and ``_resample`` to postprocess the partial read"""
   297    118.9 MiB      0.0 MiB           return self._resample(
   298    126.5 MiB      7.6 MiB               self._clip_array(arr, img_tiles), img_tiles=img_tiles, out_shape=out_shape
   299                                     )
@geospatial-jeff
Copy link
Owner Author

Its much better with PIL.Image.resize

Line #    Mem usage    Increment   Line Contents
================================================
   298    118.4 MiB    118.4 MiB       @profile
   299                                 def _postprocess(
   300                                     self, arr: NpArrayType, img_tiles: TileMetadata, out_shape: Tuple[int, int]
   301                                 ) -> NpArrayType:
   302                                     """Wrapper around ``_clip_array`` and ``_resample`` to postprocess the partial read"""
   303    118.4 MiB      0.0 MiB           return self._resample(
   304    118.9 MiB      0.5 MiB               self._clip_array(arr, img_tiles), img_tiles=img_tiles, out_shape=out_shape
   305                                     )

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

Successfully merging a pull request may close this issue.

1 participant