Re: [gdal-dev] Performance Issue with VRT Pixel Function and Large Number of Source Rasters

2025-04-18 Thread Abdul Raheem Siddiqui via gdal-dev
Pull request here: https://github.com/OSGeo/gdal/pull/12178 There is
potentially more subelements that can go in this top level section but I
was not sure if they would work across all types of pixel functions.

P.S: Is there a reason why SkipNonContributingSources is False by default?
Wouldn't it make more sense to have it set to True by default?

Abdul

On Wed, Apr 16, 2025 at 6:09 PM Even Rouault 
wrote:

>
>
> Thanks for the quick fix Even! *My only remaining concern is that the
> documentation lists SkipNonContributingSources under Python Pixel
> Functions, even though it applies to both C++ and Python Pixel Functions.
> Shouldn't it be elevated to be mentioned more generically under Derived
> Band?*
>
> Indeed. A pull request updating that would be welcome
>
> -- http://www.spatialys.com
> My software is free, but my time generally not.
>
>
___
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev


Re: [gdal-dev] Performance Issue with VRT Pixel Function and Large Number of Source Rasters

2025-04-16 Thread Even Rouault via gdal-dev




Thanks for the quick fix Even! *My only remaining concern is that the 
documentation lists SkipNonContributingSources under Python Pixel 
Functions, even though it applies to both C++ and Python Pixel 
Functions. Shouldn't it be elevated to be mentioned more generically 
under Derived Band?*


Indeed. A pull request updating that would be welcome

--
http://www.spatialys.com
My software is free, but my time generally not.
___
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev


Re: [gdal-dev] Performance Issue with VRT Pixel Function and Large Number of Source Rasters

2025-04-16 Thread Abdul Raheem Siddiqui via gdal-dev
I tried using
true on this
dataset with GDAL 3.9.3, and it drastically sped things up.


Then I tested it on another larger dataset, and the command errored out.
Then I built GDAL from source in a Docker container including Even's patch,
and the previously failing command succeeded. Memory usage was also within
a reasonable range—so everything is now resolved.


I posted this as an answer to my StackExchange question (mentioned earlier
in this email thread) in case others run into the same issue:
https://gis.stackexchange.com/a/491960/142232

Thanks for the quick fix Even! *My only remaining concern is that the
documentation lists SkipNonContributingSources under Python Pixel
Functions, even though it applies to both C++ and Python Pixel Functions.
Shouldn't it be elevated to be mentioned more generically under Derived
Band? *If agreed please let me know and I can attempt updating
documentation.

Thanks for your help.

Abdul Raheem Siddiqui
[email protected]


On Mon, Apr 14, 2025, 11:05 AM Rahkonen Jukka <
[email protected]> wrote:

> Hi,
>
> I got interested in trying what if all the images overlap totally. The
> timings from my test looks good to me, 28 seconds for creating a max raster
> from 1000 single band rasters, 1000x1000 pixels each.  However, I am not
> totally sure if my test is valid so I present it here.
>
> First create 1000 images with gdal_create with different pixel values
>
> for /L %n in (1,1,1000) do gdal_create -outsize 1000 1000 -of gtiff -ot
> int16 -burn %n -a_srs epsg:4326 -a_ullr 20 30 30 20 %n.tif
>
> Then create a prototype of a VRT
>
> gdalbuildvrt alloverlap_max.vrt *.tif
>
> Edit the VRT in a few places:
> - Change SimpleSource into ComplexSource everywhere
> - Add subClass="VRTDerivedRasterBand" and the pixel function:
> 
> max
>
> Finally, convert into GeoTIFF
>
> gdal_translate -of gtiff alloverlap_max.vrt max.tif
>
> The result looks correct, the max value of max.tif is 1000 even the last
> image in the VRT is 999.tif with pixel values=999, and I tried also min
> function and got 1 as expected.
>
> -Jukka Rahkonen-
>
>
> 
> Lähettäjä: gdal-dev käyttäjän Even Rouault via gdal-dev puolesta
> Lähetetty: Maanantai 14. huhtikuuta 2025 16.45
> Vastaanottaja: Abdul Raheem Siddiqui; [email protected]
> Aihe: Re: [gdal-dev] Performance Issue with VRT Pixel Function and Large
> Number of Source Rasters
>
> Abdul,if you add
> true as a child
> element of the  element, and apply patch
> https://github.com/OSGeo/gdal/commit/3dbc60b334ee022f2993dca476b08d5fed01698c
> , "gdal_translate -of GTiff merged.vrt OUTPUT.tif" completes in a few
> minutesCf
> https://gdal.org/en/stable/drivers/raster/vrt.html#using-derived-bands-with-pixel-functions-in-python
> for the doc of SkipNonContributingSourcesEvenLe 14/04/2025 à 06:52, Abdul
> Raheem Siddiqui via gdal-dev a écrit :Dear GDAL Community,I am encountering
> a performance issue when using a VRT consisting of a large number of
> source rasters and built-in C++ pixel function ("max"). I would appreciate
> any guidance on whether some GDAL config option can improve this, or I am
> doing something wrong, or this is a potential optimization opportunity.I
> have A VRT file referencing ~750 individual rasters (Byte data type, avg
> size ~1000x1000 pixels, untiled, and same CRS for all source rasters). The
> VRT uses the built-in “max” pixel function.Running gdal_translate to
> convert the VRT to GTiff takes ~1.5 hours and consumes ~4GB
> RAM.gdal_translate -of GTiff merged.vrt OUTPUT.tifWhen tripling the number
> of source rasters (to ~2250) by duplicating entries in the VRT, processing
> time increases to ~4.5 hours, with RAM usage rising to
> ~11.5GB.gdal_translate -of GTiff merged_3x.vrt OUTPUT.tifExtracting a small
> subset of the VRT via -projwin does not improve performance (still slow,
> ~14GB RAM used).gdal_translate -projwin -146955.241 797044.4497
> -138766.1444 789656.0648 -of GTiff merged_3x.vrt OUTPUT.tifRemoving the
> pixel function makes processing instantaneous, even with 2250
> rasters.Performance is unaffected by --config GDAL_CACHEMAX or -co
> NUM_THREADS=ALL_CPUS.The issue persists across other datasets that I have.
> In fact, it gets really worse when source rasters are relatively larger or
> of Float32 data type.Gdalinfo on one of the source rasters:
> https://pastebin.com/gjHDA2WdData:
> https://drive.google.com/file/d/1LGlzGGZvkPyXvKKgkPVzQGbBw55p5dRd/view?System:
> Windows, 8 CPUs, 32GB RAM (GDAL 3.9.2 via OSGeo4W).Thank you for your time
> and insights. Please reply if you are aware of how performance can be
> improved.Regards, Abdul Siddiqui, [email protected]

Re: [gdal-dev] Performance Issue with VRT Pixel Function and Large Number of Source Rasters

2025-04-15 Thread Even Rouault via gdal-dev

Abdul,

if you add true 
as a child element of the  element, and apply patch 
https://github.com/OSGeo/gdal/commit/3dbc60b334ee022f2993dca476b08d5fed01698c 
, "gdal_translate -of GTiff merged.vrt OUTPUT.tif" completes in a few 
minutes


Cf 
https://gdal.org/en/stable/drivers/raster/vrt.html#using-derived-bands-with-pixel-functions-in-python 
for the doc of SkipNonContributingSources


Even

Le 14/04/2025 à 06:52, Abdul Raheem Siddiqui via gdal-dev a écrit :

Dear GDAL Community,

I am encountering a performance issue when using a VRT consisting of a 
large number of source rasters and built-in C++ pixel function 
("max"). I would appreciate any guidance on whether some GDAL config 
option can improve this, or I am doing something wrong, or this is a 
potential optimization opportunity.


I have A VRT file referencing ~750 individual rasters (Byte data type, 
avg size ~1000x1000 pixels, untiled, and same CRS for all source 
rasters). The VRT uses the built-in “max” pixel function.


Running gdal_translate to convert the VRT to GTiff takes ~1.5 hours 
and consumes ~4GB RAM.

gdal_translate -of GTiff merged.vrt OUTPUT.tif

When tripling the number of source rasters (to ~2250) by duplicating 
entries in the VRT, processing time increases to ~4.5 hours, with RAM 
usage rising to ~11.5GB.

gdal_translate -of GTiff merged_3x.vrt OUTPUT.tif

Extracting a small subset of the VRT via -projwin does not improve 
performance (still slow, ~14GB RAM used).
gdal_translate -projwin -146955.241 797044.4497 -138766.1444 
789656.0648 -of GTiff merged_3x.vrt OUTPUT.tif


*Removing the pixel function makes processing instantaneous, even with 
2250 rasters.*


Performance is unaffected by --config GDAL_CACHEMAX or -co 
NUM_THREADS=ALL_CPUS.


The issue persists across other datasets that I have. In fact, it gets 
really worse when source rasters are relatively larger or of Float32 
data type.


Gdalinfo on one of the source rasters: https://pastebin.com/gjHDA2Wd
*Data:* 
https://drive.google.com/file/d/1LGlzGGZvkPyXvKKgkPVzQGbBw55p5dRd/view?


System: Windows, 8 CPUs, 32GB RAM (GDAL 3.9.2 via OSGeo4W).

Thank you for your time and insights. Please reply if you are aware of 
how performance can be improved.


Regards,

*Abdul Siddiqui, PE*

[email protected]_


*ERT  | *Earth Resources Technology, Inc.

14401 Sweitzer Ln. Ste 300

Laurel, MD 20707

https://www.ertcorp.com


___
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev


--
http://www.spatialys.com
My software is free, but my time generally not.
___
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev


Re: [gdal-dev] Performance Issue with VRT Pixel Function and Large Number of Source Rasters

2025-04-14 Thread Rahkonen Jukka via gdal-dev
Hi,

I got interested in trying what if all the images overlap totally. The timings 
from my test looks good to me, 28 seconds for creating a max raster from 1000 
single band rasters, 1000x1000 pixels each.  However, I am not totally sure if 
my test is valid so I present it here.

First create 1000 images with gdal_create with different pixel values

for /L %n in (1,1,1000) do gdal_create -outsize 1000 1000 -of gtiff -ot int16 
-burn %n -a_srs epsg:4326 -a_ullr 20 30 30 20 %n.tif

Then create a prototype of a VRT

gdalbuildvrt alloverlap_max.vrt *.tif

Edit the VRT in a few places:
- Change SimpleSource into ComplexSource everywhere
- Add subClass="VRTDerivedRasterBand" and the pixel function:

max

Finally, convert into GeoTIFF

gdal_translate -of gtiff alloverlap_max.vrt max.tif

The result looks correct, the max value of max.tif is 1000 even the last image 
in the VRT is 999.tif with pixel values=999, and I tried also min function and 
got 1 as expected.

-Jukka Rahkonen-



Lähettäjä: gdal-dev käyttäjän Even Rouault via gdal-dev puolesta
Lähetetty: Maanantai 14. huhtikuuta 2025 16.45
Vastaanottaja: Abdul Raheem Siddiqui; [email protected]
Aihe: Re: [gdal-dev] Performance Issue with VRT Pixel Function and Large Number 
of Source Rasters

Abdul,if you add true 
as a child element of the  element, and apply patch 
https://github.com/OSGeo/gdal/commit/3dbc60b334ee022f2993dca476b08d5fed01698c , 
"gdal_translate -of GTiff merged.vrt OUTPUT.tif" completes in a few minutesCf 
https://gdal.org/en/stable/drivers/raster/vrt.html#using-derived-bands-with-pixel-functions-in-python
 for the doc of SkipNonContributingSourcesEvenLe 14/04/2025 à 06:52, Abdul 
Raheem Siddiqui via gdal-dev a écrit :Dear GDAL Community,I am encountering a 
performance issue when using a VRT consisting of a large number of source 
rasters and built-in C++ pixel function ("max"). I would appreciate any 
guidance on whether some GDAL config option can improve this, or I am doing 
something wrong, or this is a potential optimization opportunity.I have A VRT 
file referencing ~750 individual rasters (Byte data type, avg size ~1000x1000 
pixels, untiled, and same CRS for all source rasters). The VRT uses the 
built-in “max” pixel function.Running gdal_translate to convert the VRT to 
GTiff takes ~1.5 hours and consumes ~4GB RAM.gdal_translate -of GTiff 
merged.vrt OUTPUT.tifWhen tripling the number of source rasters (to ~2250) by 
duplicating entries in the VRT, processing time increases to ~4.5 hours, with 
RAM usage rising to ~11.5GB.gdal_translate -of GTiff merged_3x.vrt 
OUTPUT.tifExtracting a small subset of the VRT via -projwin does not improve 
performance (still slow, ~14GB RAM used).gdal_translate -projwin -146955.241 
797044.4497 -138766.1444 789656.0648 -of GTiff merged_3x.vrt OUTPUT.tifRemoving 
the pixel function makes processing instantaneous, even with 2250 
rasters.Performance is unaffected by --config GDAL_CACHEMAX or -co 
NUM_THREADS=ALL_CPUS.The issue persists across other datasets that I have. In 
fact, it gets really worse when source rasters are relatively larger or of 
Float32 data type.Gdalinfo on one of the source rasters: 
https://pastebin.com/gjHDA2WdData: 
https://drive.google.com/file/d/1LGlzGGZvkPyXvKKgkPVzQGbBw55p5dRd/view?System: 
Windows, 8 CPUs, 32GB RAM (GDAL 3.9.2 via OSGeo4W).Thank you for your time and 
insights. Please reply if you are aware of how performance can be 
improved.Regards, Abdul Siddiqui, [email protected]  | Earth 
Resources Technology, Inc.14401 Sweitzer Ln. Ste 300Laurel, MD 
20707https://www.ertcorp.com ___
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
-- 
http://www.spatialys.com
My software is free, but my time generally not.
___
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev


Re: [gdal-dev] Performance Issue with VRT Pixel Function and Large Number of Source Rasters

2025-04-14 Thread Rahkonen Jukka via gdal-dev
Hi,

When "max" pixel function is used then GDAL needs to analyze every single pixel 
from every overlapping image for finding out the maximum values.  Without pixel 
functions there is nothing to analyze but the pixels from the last image in a 
pile will beat all the previous pixels.

I would try something like hand made multiprocessing.  Depart the 1000 images 
into 10 vrt files, 100 images in each, and run 10 parallel gdal_translates with 
"max". Then run max again for the 10 interim images. Perhaps you will save more 
than 80% of clock time.

-Jukka Rahkonen-


Lähettäjä: Abdul Raheem Siddiqui
Lähetetty: Maanantai 14. huhtikuuta 2025 16.09
Vastaanottaja: Rahkonen Jukka
Kopio: [email protected]
Aihe: Re: [gdal-dev] Performance Issue with VRT Pixel Function and Large Number 
of Source Rasters

Laurentiu,Bumping GDAL_MAX_DATASET_POOL_SIZE did not make any difference for 
me. My source rasters are of different block sizes but they are relatively 
small. As you have noted, the drastic performance difference with or without 
Pixel Func points to something else not tiling. I agree.AbdulOn Mon, Apr 14, 
2025 at 4:20 AM Rahkonen Jukka  
wrote:Hi,Some previous discussion about the same thing in 
https://gis.stackexchange.com/questions/491309/performent-way-of-merging-multiple-rasters-into-a-single-cog-gtiff-with-gdal-w?With
 untiled images it is not a surprise that small -projwin does not have a great 
effect. But with 1000x1000 pixels sized images and the default tile size 
256x256 splittin images internally into four would probably not make much 
difference anyway.Processing time and memory usage seems to grow linearly when 
the number of files in the VRT is increasing. Maybe this is good news.-Jukka 
Rahkonen-Lähettäjä: gdal-dev käyttäjän 
Abdul Raheem Siddiqui via gdal-dev puolestaLähetetty: Maanantai 14. huhtikuuta 
2025 7.52Vastaanottaja: [email protected]: [gdal-dev] Performance 
Issue with VRT Pixel Function and Large Number of Source RastersDear GDAL 
Community,I am encountering a performance issue when using a VRT consisting of 
a large number of source rasters and built-in C++ pixel function ("max"). I 
would appreciate any guidance on whether some GDAL config option can improve 
this, or I am doing something wrong, or this is a potential optimization 
opportunity.I have A VRT file referencing ~750 individual rasters (Byte data 
type, avg size ~1000x1000 pixels, untiled, and same CRS for all source 
rasters). The VRT uses the built-in “max” pixel function.Running gdal_translate 
to convert the VRT to GTiff takes ~1.5 hours and consumes ~4GB 
RAM.gdal_translate -of GTiff merged.vrt OUTPUT.tifWhen tripling the number of 
source rasters (to ~2250) by duplicating entries in the VRT, processing time 
increases to ~4.5 hours, with RAM usage rising to ~11.5GB.gdal_translate -of 
GTiff merged_3x.vrt OUTPUT.tifExtracting a small subset of the VRT via -projwin 
does not improve performance (still slow, ~14GB RAM used).gdal_translate 
-projwin -146955.241 797044.4497 -138766.1444 789656.0648 -of GTiff 
merged_3x.vrt OUTPUT.tifRemoving the pixel function makes processing 
instantaneous, even with 2250 rasters.Performance is unaffected by --config 
GDAL_CACHEMAX or -co NUM_THREADS=ALL_CPUS.The issue persists across other 
datasets that I have. In fact, it gets really worse when source rasters are 
relatively larger or of Float32 data type.Gdalinfo on one of the source 
rasters: https://pastebin.com/gjHDA2WdData: 
https://drive.google.com/file/d/1LGlzGGZvkPyXvKKgkPVzQGbBw55p5dRd/view?System: 
Windows, 8 CPUs, 32GB RAM (GDAL 3.9.2 via OSGeo4W).Thank you for your time and 
insights. Please reply if you are aware of how performance can be 
improved.Regards,Abdul Siddiqui, [email protected]  | Earth 
Resources Technology, Inc.14401 Sweitzer Ln. Ste 300Laurel, MD 
20707https://www.ertcorp.com
___
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev


Re: [gdal-dev] Performance Issue with VRT Pixel Function and Large Number of Source Rasters

2025-04-14 Thread Abdul Raheem Siddiqui via gdal-dev
Laurentiu,

Bumping GDAL_MAX_DATASET_POOL_SIZE

did
not make any difference for me. My source rasters are of different block
sizes but they are relatively small. As you have noted, the drastic
performance difference with or without Pixel Func points to something else
not tiling. I agree.


Abdul

On Mon, Apr 14, 2025 at 4:20 AM Rahkonen Jukka <
[email protected]> wrote:

> Hi,
>
> Some previous discussion about the same thing in
> https://gis.stackexchange.com/questions/491309/performent-way-of-merging-multiple-rasters-into-a-single-cog-gtiff-with-gdal-w
> ?
>
> With untiled images it is not a surprise that small -projwin does not have
> a great effect. But with 1000x1000 pixels sized images and the default tile
> size 256x256 splittin images internally into four would probably not make
> much difference anyway.
>
> Processing time and memory usage seems to grow linearly when the number of
> files in the VRT is increasing. Maybe this is good news.
>
> -Jukka Rahkonen-
>
> 
> Lähettäjä: gdal-dev käyttäjän Abdul Raheem Siddiqui via gdal-dev puolesta
> Lähetetty: Maanantai 14. huhtikuuta 2025 7.52
> Vastaanottaja: [email protected]
> Aihe: [gdal-dev] Performance Issue with VRT Pixel Function and Large
> Number of Source Rasters
>
> Dear GDAL Community,I am encountering a performance issue when using a VRT
> consisting of a large number of source rasters and built-in C++ pixel
> function ("max"). I would appreciate any guidance on whether some GDAL
> config option can improve this, or I am doing something wrong, or this is a
> potential optimization opportunity.I have A VRT file referencing ~750
> individual rasters (Byte data type, avg size ~1000x1000 pixels, untiled,
> and same CRS for all source rasters). The VRT uses the built-in “max” pixel
> function.Running gdal_translate to convert the VRT to GTiff takes ~1.5
> hours and consumes ~4GB RAM.gdal_translate -of GTiff merged.vrt
> OUTPUT.tifWhen tripling the number of source rasters (to ~2250) by
> duplicating entries in the VRT, processing time increases to ~4.5 hours,
> with RAM usage rising to ~11.5GB.gdal_translate -of GTiff merged_3x.vrt
> OUTPUT.tifExtracting a small subset of the VRT via -projwin does not
> improve performance (still slow, ~14GB RAM used).gdal_translate -projwin
> -146955.241 797044.4497 -138766.1444 789656.0648 -of GTiff merged_3x.vrt
> OUTPUT.tifRemoving the pixel function makes processing instantaneous, even
> with 2250 rasters.Performance is unaffected by --config GDAL_CACHEMAX or
> -co NUM_THREADS=ALL_CPUS.The issue persists across other datasets that I
> have. In fact, it gets really worse when source rasters are relatively
> larger or of Float32 data type.Gdalinfo on one of the source rasters:
> https://pastebin.com/gjHDA2WdData:
> https://drive.google.com/file/d/1LGlzGGZvkPyXvKKgkPVzQGbBw55p5dRd/view?System:
> Windows, 8 CPUs, 32GB RAM (GDAL 3.9.2 via OSGeo4W).Thank you for your time
> and insights. Please reply if you are aware of how performance can be
> improved.Regards,Abdul Siddiqui, [email protected]  | Earth
> Resources Technology, Inc.14401 Sweitzer Ln. Ste 300Laurel, MD 20707
> https://www.ertcorp.com
___
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev


Re: [gdal-dev] Performance Issue with VRT Pixel Function and Large Number of Source Rasters

2025-04-14 Thread Rahkonen Jukka via gdal-dev
Hi,

Some previous discussion about the same thing in 
https://gis.stackexchange.com/questions/491309/performent-way-of-merging-multiple-rasters-into-a-single-cog-gtiff-with-gdal-w?

With untiled images it is not a surprise that small -projwin does not have a 
great effect. But with 1000x1000 pixels sized images and the default tile size 
256x256 splittin images internally into four would probably not make much 
difference anyway.

Processing time and memory usage seems to grow linearly when the number of 
files in the VRT is increasing. Maybe this is good news.

-Jukka Rahkonen-


Lähettäjä: gdal-dev käyttäjän Abdul Raheem Siddiqui via gdal-dev puolesta
Lähetetty: Maanantai 14. huhtikuuta 2025 7.52
Vastaanottaja: [email protected]
Aihe: [gdal-dev] Performance Issue with VRT Pixel Function and Large Number of 
Source Rasters

Dear GDAL Community,I am encountering a performance issue when using a VRT 
consisting of a large number of source rasters and built-in C++ pixel function 
("max"). I would appreciate any guidance on whether some GDAL config option can 
improve this, or I am doing something wrong, or this is a potential 
optimization opportunity.I have A VRT file referencing ~750 individual rasters 
(Byte data type, avg size ~1000x1000 pixels, untiled, and same CRS for all 
source rasters). The VRT uses the built-in “max” pixel function.Running 
gdal_translate to convert the VRT to GTiff takes ~1.5 hours and consumes ~4GB 
RAM.gdal_translate -of GTiff merged.vrt OUTPUT.tifWhen tripling the number of 
source rasters (to ~2250) by duplicating entries in the VRT, processing time 
increases to ~4.5 hours, with RAM usage rising to ~11.5GB.gdal_translate -of 
GTiff merged_3x.vrt OUTPUT.tifExtracting a small subset of the VRT via -projwin 
does not improve performance (still slow, ~14GB RAM used).gdal_translate 
-projwin -146955.241 797044.4497 -138766.1444 789656.0648 -of GTiff 
merged_3x.vrt OUTPUT.tifRemoving the pixel function makes processing 
instantaneous, even with 2250 rasters.Performance is unaffected by --config 
GDAL_CACHEMAX or -co NUM_THREADS=ALL_CPUS.The issue persists across other 
datasets that I have. In fact, it gets really worse when source rasters are 
relatively larger or of Float32 data type.Gdalinfo on one of the source 
rasters: https://pastebin.com/gjHDA2WdData: 
https://drive.google.com/file/d/1LGlzGGZvkPyXvKKgkPVzQGbBw55p5dRd/view?System: 
Windows, 8 CPUs, 32GB RAM (GDAL 3.9.2 via OSGeo4W).Thank you for your time and 
insights. Please reply if you are aware of how performance can be 
improved.Regards,Abdul Siddiqui, [email protected]  | Earth 
Resources Technology, Inc.14401 Sweitzer Ln. Ste 300Laurel, MD 
20707https://www.ertcorp.com
___
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev


Re: [gdal-dev] Performance Issue with VRT Pixel Function and Large Number of Source Rasters

2025-04-14 Thread Laurențiu Nicola via gdal-dev
Hi Abdul,

Can you bump 
https://gdal.org/en/stable/user/configoptions.html#config-GDAL_MAX_DATASET_POOL_SIZE
 and see if it helps? And do all inputs have the same block size of 1048x7? 
Ideally, your inputs and output will all have the same block size or a multiple 
of it, so you could also add -co BLOCKXSIZE=1048 -co BLOCKYSIZE=7.

Note that these should apply just as well when you don't have a pixel function, 
so it's probably not it.

https://github.com/OSGeo/gdal/pull/11850 might also help in the future, but 
you'll need to change your workflow for it.

Laurentiu

On Mon, Apr 14, 2025, at 07:52, Abdul Raheem Siddiqui via gdal-dev wrote:
> Dear GDAL Community,
> 
> I am encountering a performance issue when using a VRT consisting of a large 
> number of source rasters and built-in C++ pixel function ("max"). I would 
> appreciate any guidance on whether some GDAL config option can improve this, 
> or I am doing something wrong, or this is a potential optimization 
> opportunity.
> 
> I have A VRT file referencing ~750 individual rasters (Byte data type, avg 
> size ~1000x1000 pixels, untiled, and same CRS for all source rasters). The 
> VRT uses the built-in “max” pixel function.
> 
> Running gdal_translate to convert the VRT to GTiff takes ~1.5 hours and 
> consumes ~4GB RAM.
> gdal_translate -of GTiff merged.vrt OUTPUT.tif
> 
> When tripling the number of source rasters (to ~2250) by duplicating entries 
> in the VRT, processing time increases to ~4.5 hours, with RAM usage rising to 
> ~11.5GB.
> gdal_translate -of GTiff merged_3x.vrt OUTPUT.tif
> 
> Extracting a small subset of the VRT via -projwin does not improve 
> performance (still slow, ~14GB RAM used).
> gdal_translate -projwin -146955.241 797044.4497 -138766.1444 789656.0648 -of 
> GTiff merged_3x.vrt OUTPUT.tif
> 
> *Removing the pixel function makes processing instantaneous, even with 2250 
> rasters.*
> 
> Performance is unaffected by --config GDAL_CACHEMAX or -co 
> NUM_THREADS=ALL_CPUS.
> 
> The issue persists across other datasets that I have. In fact, it gets really 
> worse when source rasters are relatively larger or of Float32 data type.
> 
> Gdalinfo on one of the source rasters: https://pastebin.com/gjHDA2Wd
> *Data:* 
> https://drive.google.com/file/d/1LGlzGGZvkPyXvKKgkPVzQGbBw55p5dRd/view?
> 
> System: Windows, 8 CPUs, 32GB RAM (GDAL 3.9.2 via OSGeo4W).
> 
> Thank you for your time and insights. Please reply if you are aware of how 
> performance can be improved.
> 
> Regards,
> *Abdul Siddiqui, PE*
> [email protected]_
> 
> *ERT  | *Earth Resources Technology, Inc.
> 14401 Sweitzer Ln. Ste 300
> Laurel, MD 20707
> https://www.ertcorp.com
> 
> 
> ___
> gdal-dev mailing list
> [email protected]
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
> 
___
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev