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

Very slow on Windows #115

Closed
giswqs opened this issue Aug 3, 2022 · 7 comments
Closed

Very slow on Windows #115

giswqs opened this issue Aug 3, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@giswqs
Copy link
Contributor

giswqs commented Aug 3, 2022

I noticed that localtileserver is very slow on Windows. It took ~13 seconds to generate tiles for this very small GeoTIFF (14 MB). It used to be very fast on Linux. I am not sure what causes the issue.

Animation

from localtileserver import get_leaflet_tile_layer, TileClient
from ipyleaflet import Map

# First, create a tile server from local raster file
client = TileClient('srtm90.tif')

# Create ipyleaflet tile layer from that server
t = get_leaflet_tile_layer(client)

m = Map(center=client.center(), zoom=client.default_zoom)
m.add_layer(t)
m

env

--------------------------------------------------------------------------------
  Date: Wed Aug 03 16:17:46 2022 Eastern Daylight Time

                     OS : Windows
                 CPU(s) : 16
                Machine : AMD64
           Architecture : 64bit
                    RAM : 31.7 GiB
            Environment : Jupyter

  Python 3.10.4 | packaged by conda-forge | (main, Mar 30 2022, 08:38:02) [MSC
  v.1916 64 bit (AMD64)]

        localtileserver : 0.5.11
                  flask : 2.1.3
          flask_caching : 1.10.1
             flask_cors : 3.0.10
            flask_restx : 0.5.1
               requests : 2.28.1
               werkzeug : 2.1.2
                  click : 8.1.3
          server_thread : 0.2.0
                 scooby : 0.5.12
            large_image : 1.15.1
large_image_source_gdal : 1.15.1
             cachetools : 4.2.4
                    PIL : 9.2.0
                 psutil : 5.9.1
                  numpy : 1.23.1
             palettable : 3.3.0
                 pyproj : 3.3.1
             osgeo.gdal : 3.4.2
             ipyleaflet : 0.17.0
             jupyterlab : 3.4.4
              traitlets : 5.3.0
                shapely : 1.8.2
                 folium : 0.12.1.post1
             matplotlib : 3.5.2
--------------------------------------------------------------------------------
@giswqs
Copy link
Contributor Author

giswqs commented Aug 3, 2022

For reference, using the localtileserver binder, it takes less than two seconds to generate tiles.

@giswqs
Copy link
Contributor Author

giswqs commented Aug 3, 2022

I also noticed that the spinning wheel is staying a bit longer than it should be. It can be a bit annoying to keep seeing the spinning wheel. Can it be turned off?

Animation

@banesullivan
Copy link
Owner

I also noticed that the spinning wheel is staying a bit longer than it should be. It can be a bit annoying to keep seeing the spinning wheel. Can it be turned off?

I added this recently -- I'd like to keep it as I think it is valuable and it does accurately correspond to tiles loading. To disable it, simply pass show_loading=False when calling get_leaflet_tile_layer() or set that property on the leaflet.TileLayer: https://ipyleaflet.readthedocs.io/en/latest/layers/tile_layer.html#ipyleaflet.leaflet.TileLayer.show_loading

@banesullivan
Copy link
Owner

banesullivan commented Aug 4, 2022

I noticed that localtileserver is very slow on Windows

I'll try to look into this when I have a chance. Timing the full execution of that script isn't very insightful, so I'll have to dig into each part of the script to figure out what's taking so long. Is it the import that takes a while or is it opening the raster, or what?... this will require more investigative work.

Further, how Python is running on the host windows machine can significantly impact performance, such as if it is running under the linux subsystem.

@banesullivan
Copy link
Owner

banesullivan commented Aug 4, 2022

My windows machine is happy today, so I'm looking into this. I've at least narrowed it down to the get_leaflet_tile_layer() for the most part (ipyleaflet rendering the tiles also takes a few seconds).

Collecting the metadata for this raster seems to be the culprit and specifically when it's done through the rest interface.

I have a feeling there are a few things that need to be optimized and this will require me to really dig into this. To be honest, Windows is a pain for me to work on and I can't promise I'll get to this anytime soon

@banesullivan
Copy link
Owner

What I may do is change the implementation a bit under the hood to generally optimize the TileClient methods (regardless of OS) as I've been wanting to but again, this is something I can't give a timeline on as this is a fun little hobby project. It will likely come after/during #108

@banesullivan banesullivan added the bug Something isn't working label Aug 4, 2022
@banesullivan
Copy link
Owner

I've done most of the refactoring/optimization that I wanted to and this doesn't seem actionable any further. I'm hoping that whatever issue you were having have magically resolved themselves by switching to using rasterio instead of GDAL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants