When does it make sense to use vips_tilecache? #4395
Unanswered
prasadbandodkar
asked this question in
Q&A
Replies: 2 comments
-
Hello @prasadbandodkar, You'd need to share a specific benchmark I could run -- it's very hard to give advice on performance tuning without a real example.
|
Beta Was this translation helpful? Give feedback.
0 replies
-
I made a tiny demo: #!/usr/bin/env python3
import sys
import pyvips
sigma = int(sys.argv[3])
cache = int(sys.argv[4])
image = pyvips.Image.new_from_file(sys.argv[1], access='sequential')
image = image.gaussblur(sigma)
if cache:
tile_width = 128
tile_height = 128
# number of tiles for two complete lines of output
tiles_across = int(1 + (image.width / tile_width))
tiles_down = int(1 + (256 / tile_height))
max_tiles = tiles_across * tiles_down
print(f"using cache with max_tiles = {max_tiles}")
image = image.tilecache(tile_width=tile_width,
tile_height=tile_height,
max_tiles=max_tiles,
access='sequential',
threaded=True)
image = image.gaussblur(sigma)
image.write_to_file(sys.argv[2]) Without a cache, the second I see:
So the cache makes it about 2x faster in this case, and it runs in less memory. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a few large images that I am processing using some custom
VipsOperations
. The output image tiles of these operations depend on the neighboring tiles like this (T is target, N is neighboring tiles):From some of my trials I found:
vips_tilecache
, the pipeline runs slowly but it hardly uses any RAM.vips_tilecache
with defaulttile_width
andtile_height
it is same as above.tile_height
andtile_width
to 2048 the images are processed much faster, but sometimes it runs out of memory (even whenmax_tiles ~= 100
)I am using the tiles to perform some processing using opencv functions.
I have the following questions:
1: Should I add
vips_tilecache
after the input image or after the output image?2: What does
persistent
mean in the optional parameters in thevips_tilecache
function? Does it mean it would hold on to the tiles even when no longer needed by the operation?3: If I want the operation to run as fast as possible, will I always keep the
threaded
option on?4. Should
max_tiles
depend ontile_height
andtile_width
parameters? If so, is there a good back of the envelop calculation to determine it's value?My objective is to run the pipeline as fast as possible and for it use all system resources (full CPU and RAM) at it's disposable. Any help would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions