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

Improve tilecache performance #3890

Open
jcupitt opened this issue Mar 10, 2024 · 0 comments
Open

Improve tilecache performance #3890

jcupitt opened this issue Mar 10, 2024 · 0 comments

Comments

@jcupitt
Copy link
Member

jcupitt commented Mar 10, 2024

This test prog:

#!/usr/bin/env python3

import sys
import pyvips

image = pyvips.Image.new_from_file(sys.argv[1])

image = image.tilecache(tile_width=image.width,
                        tile_height=256,
                        max_tiles=1,
                        persistent=True)

patches = [image.crop(x, y, min(256, image.width - x), min(256, image.height - y))                    
           for y in range(0, image.height, 256)
           for x in range(0, image.width, 256)]
           
for patch in patches:
    pixel_array = patch.numpy()

With this (7 gb) test tiff:

$ vips bandjoin "st-francis.jpg st-francis.jpg st-francis.jpg" x.tif[tile]

I see:

$ VIPS_CONCURRENCY=1 /usr/bin/time -f %M:%e ./readtile.py x.tif
472656:13.37

If I change this line:

image2 = image.tilecache(tile_width=image.width,

ie. create the tilecache but never use it, I see:

$ VIPS_CONCURRENCY=1 /usr/bin/time -f %M:%e ./readtile.py x.tif
143064:4.51

It looks like the tilecache alone is taking almost 10s of runtime. Can we improve this?

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

No branches or pull requests

1 participant