Skip to main content

Performance

GeoBrix picks the implementation level for each function. You do not choose a level. The compute decides, and GeoBrix says why when it falls back to another level.

This page has two parts. The first part lists what 0.6.0 streamlined. The second part shows how each level performs, by function family. The later sections cover reads from virtual tiles and how the Python functions run on Spark.

For the method behind the numbers, see Benchmarking. For where each function runs, see Availability by surface.

What 0.6.0 streamlined​

Each item below has the measurement behind it. The release notes list the breaking changes.

  • Readers and writers. Python everywhere. The Scala readers and writers are retired because the bytes-free Python path was faster.
  • Raster tile functions. The Python implementation is the default. A JVM companion stays only where it measured at least 1.2x faster on a dedicated cluster. gbx_rst_gridfrompoints lost its JVM form, because it measured slower.
  • Grid functions. The JVM (Catalyst) form stays for the BNG and custom-grid functions that have one, where it measured at least 1.2x faster. Those are the cell scalars, tessellate, the rings, polyfill, the explodes and the cell fill. gbx_bng_eastnorthasbng lost its JVM form, because the Python batch form is faster. H3 and quadbin use the Python form, except gbx_h3_cellfill.
  • Aggregates and generators. Each compute has its own route. Aggregates by compute lists them.
  • Rust. A compute kernel is used only where it measured clearly faster than the Python form. Today that is gbx_bng_eastnorthasbng and the triangulation of the TIN functions.
  • SQL registration. One registrar, written in Python. register(spark) installs every function, and the compute chooses the level.

Performance by level​

This page measures three levels. It writes lightweight for the Python level and heavyweight for the JVM level, as The levels defines them.

LevelWhat you installWhere it runs
Python (lightweight)The env wheel. No JAR.Serverless, standard, dedicated, and a SQL warehouse through Unity Catalog Python functions
JVM (heavyweight)The env wheel and the GeoBrix JARDedicated clusters. Standard access mode only where a Java handler exists.
UC functionsgbx.uc.installSQL warehouses and any compute that reads Unity Catalog

GeoBrix keeps a JVM level only where it is at least 1.2x faster than the best Python form. The test runs on a dedicated cluster at 4x or 16x the base row count, and the output must decode the same. The JAR then makes the JVM level the default. A function with no measurement yet runs at the Python level, except a few. Functions the JAR speeds up lists every function that runs the JVM level by default.

Every function not on that page runs at the Python level. Compare times within one compute only. A Serverless time describes per-task behavior, not speed against a fixed cluster.

Python level (no JAR)​

The Python level runs every function on every compute. It is the default for most functions. Functions the JAR speeds up lists the exceptions.

Function familyWhat runsMeasured result
Accessors and statistics that return an ARRAY<...>, MAP<...> or STRUCT<...>Arrow scalar UDFThe only form. The JVM form was faster on a materialized tile (gbx_rst_avg took 0.59x and 0.65x the Python time at 4x and 16x rows). Such a function can sit under explode or inline, where the SQL function that sends a virtual tile to the Python level is refused, so the JVM form could not be the default. It is no longer shipped.
Band math, spectral indices and canopy heightGDAL raster calc in the workerThe JVM form ran gdal_calc.py in a subprocess for each row. The Python form is the default on every compute, and the JVM form is no longer shipped.
gbx_rst_transform, gbx_rst_resample, gbx_rst_resample_to_resGDAL raster reproject in the workerThe JVM form ran at 0.71x (transform), 1.18x and 0.84x (resample) and 1.10x and 1.01x (resample_to_res) the speed. It is no longer shipped.
gbx_rst_to_webmercator, gbx_rst_resample_to_sizeGDAL raster reproject in the workerThe JVM form ran at 0.98x the speed at 4x rows. It is no longer shipped.
Terrain (aspect, hillshade, TRI, TPI, roughness, color relief)GDAL algorithm in the workerThe JVM form was 1.05x to 1.17x faster at 16x rows, under the 1.2x bar. The JVM color relief could not read a color table on a Volume. It is no longer shipped.
gbx_rst_crs, gbx_rst_format, gbx_rst_height, gbx_rst_memsize, gbx_rst_numbands, gbx_rst_pixelheight, gbx_rst_pixelwidth, gbx_rst_rotation, gbx_rst_scalex, gbx_rst_scaley, gbx_rst_skewx, gbx_rst_skewy, gbx_rst_srid, gbx_rst_upperleftx, gbx_rst_upperlefty, gbx_rst_width, gbx_rst_rastertoworldcoordx, gbx_rst_rastertoworldcoordy, gbx_rst_worldtorastercoordxArrow scalar UDFBoth forms spend most of the time reading the tile. The JVM form was between 1.05x and 1.2x faster at 4x and 16x rows, under the 1.2x bar. It is no longer shipped.
gbx_rst_band, gbx_rst_setsrid, gbx_rst_setcrs, gbx_rst_getsubdatasetPythonThe JVM form ran at 0.43x and 0.46x (band), 0.39x and 0.28x (setsrid), 0.38x and 0.37x (setcrs), and 0.53x and 0.45x (getsubdataset) the speed at 4x and 16x rows. It is no longer shipped.
gbx_rst_slope, gbx_rst_mapalgebra, gbx_rst_transformcrsGDAL algorithm in the workerThe JVM form took 0.97x to 1.15x the time at 4x and 16x rows for slope and map algebra. For gbx_rst_transformcrs it took 0.99x and 0.78x, but returned NULL tiles under load where the Python forms returned none. It is no longer shipped
gbx_st_crs, gbx_st_setcrs, gbx_h3_cell_bbox, gbx_rst_frombands, gbx_rst_asformat, gbx_rst_convolve, gbx_rst_initnodata, gbx_rst_updatetypePythonNo JVM form ran 1.2x faster at 4x or 16x rows. The JVM form ran at 0.59x the speed (crs, at 4x rows) and 0.34x and 0.52x (convolve, at 4x and 16x rows). It is no longer shipped.
gbx_rst_buildoverviewsGDAL overviews in the workerThe Python form was 2.2x faster than the JVM form, which wrote the overviews in a sidecar file the tile bytes did not carry. It is no longer shipped.
gbx_rst_percentile_stretch, gbx_rst_filter, gbx_rst_xyzpyramid, gbx_rst_derivedbandPythonThe JVM output differed from the session function, so the JVM form is no longer shipped. The JVM stretch differed by up to 1.24 levels on an 8-bit tile.
gbx_rst_fillnodataGDAL fill in the workerThe JVM form ran at 0.32x and 0.18x the speed at 4x and 16x rows. It is no longer shipped.
gbx_rst_proximityExact Euclidean distance in PythonThe JVM form ran at 1.0x and 1.16x the speed at 4x and 16x rows. It is no longer shipped.
gbx_rst_summaryGDAL raster info with statisticsThe JVM form wrote no band statistics, so its output differed. It is no longer shipped.
Edits on virtual tilesHeader only, no pixel read1.1x to 12.5x faster than on a materialized tile
Grouped raster aggregatesGrouped-aggregate UDFSee Aggregates by compute
Vector tiles (gbx_st_asmvt)mapbox-vector-tile1.7x to 2.9x faster than the former JVM aggregate, which is no longer shipped
PMTiles archive aggregateGrouped-aggregate UDFAbout 1.07x the JVM time, inside run-to-run noise
Quadbin and the custom-grid arraysPython cell mathAt parity with the JVM form, 0.9x to 1.3x
gbx_rst_binpoints, gbx_rst_cog_convert, gbx_rst_align_toPythonThe JVM form took 1.1x to 1.9x the time at 4x and 16x rows, and is no longer shipped
gbx_rst_gridfrompointsPythonThe JVM form took 1.8x and 1.9x the time at 4x and 16x rows, and is no longer shipped
gbx_rst_combineavg and the six other gbx_rst_combine* functionsPythonThe JVM form took 1.08x and 1.49x the time of the best Python form at 4x and 16x rows (131.56 s against 122.16 s, and 576.44 s against 387.95 s), and is no longer shipped. For many tiles per key, combine_by_key took 261.07 s at 16x rows
gbx_rst_bng_tessellatePythonThe JVM form took 0.97x and 1.03x the time at 4x and 16x rows (1591.42 s against 1540.71 s at 16x), a tie, and is no longer shipped
gbx_bng_eastnorthasbngSQL function, then a Python batch formThe JVM form took 1.17x and 1.35x the time of the Python batch form at 4 and 16 million rows, and is no longer shipped. On a standard cluster the Java UDF took 3.24 s against 1.70 s at 4 million rows
Other familiesPer-function UDFNot yet measured: the Python level

Source: a dedicated cluster (one driver and four m5d.2xlarge workers, DBR 19). Rows are multiples of each function's base row count.

JVM level (with the JAR)​

The JAR is the default for these functions on a dedicated cluster. Each is at least 1.2x faster than the best Python form at 4x or 16x rows, with the same decoded output. Times are seconds per run. Lower is faster.

These are the measurements. Functions the JAR speeds up lists every function that runs on the JVM by default.

FunctionJVM 4x / 16x (s)Best Python 4x / 16x (s)JVM is faster by
gbx_st_transformcrs5.78 / 20.2533.17 / 128.795.7x / 6.4x
gbx_rst_fromcontent3.13 / not run14.09 / not run4.5x at 4x
gbx_st_triangulate1.49 / 2.712.40 / 6.701.6x / 2.5x
gbx_st_interpolateelevationbbox2.41 / 5.453.08 / 9.881.28x / 1.81x
gbx_bng_tessellateexplode13.47 / 54.6932.23 / 120.812.4x / 2.2x
gbx_bng_tessellate14.31 / 57.5830.51 / 126.402.1x / 2.2x
gbx_bng_cellfill2.21 / 5.953.11 / 8.131.4x / 1.4x
gbx_bng_kring10.62 / 78.1312.90 / 99.151.21x / 1.27x
gbx_rst_bng_rasterize_agg, cell inputnot run / 5.96not run / 14.772.5x at 16x
gbx_rst_bng_rasterize_agg, group inputnot run / 8.42not run / 16.982.0x at 16x

A later run re-measured gbx_bng_cellfill, gbx_bng_kring and the rasterize aggregate. Its figures replace the single-sample figures of an earlier run.

A further run re-measured gbx_rst_fromcontent, gbx_st_triangulate and gbx_st_interpolateelevationbbox against the Python form that moves tiles in Arrow batches, as medians of five iterations. gbx_rst_fromcontent passed at 4x, so 16x was not run.

A later pass timed every other JVM form at 1x and 4x rows on the same cluster, with the same decoded output. These 16 functions passed the 1.2x line at 4x rows, so they run on the JVM by default too:

FunctionJVM 1x / 4x (s)Best Python 1x / 4x (s)JVM is faster by
gbx_custom_polyfill0.48 / 0.682.03 / 6.654.2x / 9.8x
gbx_custom_kring0.72 / 1.343.33 / 10.914.6x / 8.1x
gbx_custom_kloop0.79 / 1.994.12 / 14.815.2x / 7.4x
gbx_bng_geomkring5.28 / 17.4624.60 / 104.244.7x / 6.0x
gbx_st_legacyaswkb0.61 / 0.972.35 / 5.663.9x / 5.8x
gbx_custom_geomkringexplode4.13 / 14.3916.99 / 73.474.1x / 5.1x
gbx_bng_polyfill0.80 / 2.483.98 / 12.545.0x / 5.1x
gbx_custom_geomkloop3.81 / 13.6316.40 / 68.884.3x / 5.1x
gbx_custom_geomkloopexplode3.94 / 14.2016.81 / 71.214.3x / 5.0x
gbx_bng_geomkloop4.57 / 17.1624.85 / 86.005.4x / 5.0x
gbx_custom_geomkring5.37 / 14.1016.77 / 69.743.1x / 4.9x
gbx_rst_custom_rasterize_agg1.56 / 2.026.78 / 9.104.4x / 4.5x
gbx_rst_quadbin_rasterize_agg0.96 / 1.392.36 / 3.342.5x / 2.4x
gbx_rst_h3_rasterize_agg2.96 / 1.723.24 / 3.861.1x / 2.2x
gbx_custom_cellfill0.91 / 1.591.54 / 3.331.7x / 2.1x
gbx_bng_kloop2.04 / 6.693.81 / 11.301.9x / 1.7x

gbx_rst_tilexyz runs on the JVM by default too. It was measured against the Python form that moves tiles in Arrow batches, with the same decoded output:

FunctionJVM 4x / 16x (s)Best Python 4x / 16x (s)JVM is faster by
gbx_rst_tilexyz1.71 / 4.752.14 / 5.801.25x / 1.22x

A virtual, NULL or error tile goes to the Python form, which returns a transparent image for it.

The same pass found nine JVM forms under the line, so the JAR no longer holds them. A later pass found five more: gbx_rst_band, gbx_rst_setsrid, gbx_rst_setcrs, gbx_rst_getsubdataset and gbx_rst_tri. A pass against the Arrow Python form found 19 raster accessors under the line. See Which functions run where.

The same JAR also serves these functions, measured on earlier runs by the time the JVM form takes as a fraction of the Python form:

FunctionJVM time as a fraction of PythonCompute
The five BNG *explode generators0.37 to 0.67Dedicated
gbx_h3_cellfill0.57Dedicated

Two raster accessors that return one value run on the JVM for a materialized tile. They were measured against the Python form that moves tiles in Arrow batches:

FunctionJVM is faster byCompute
gbx_rst_boundingbox1.27x at 4x rowsDedicated
gbx_rst_worldtorastercoordy1.22x at 16x rowsDedicated

A virtual tile goes to the Python form, because the JVM level reads bytes only. The other 19 accessors that return one value stayed under the 1.2x bar against that form, so they run the Python form only. The accessors and statistics that return an ARRAY<...>, MAP<...> or STRUCT<...> have no JVM form.

Standard access mode runs Spark Connect, which cannot load a Catalyst expression. No function has a JVM level there.

The functions not listed above have no cluster measurement of the JVM level. Most of them run the Python level. The BNG and custom-grid cell scalars run the JVM first too. In the same pass their JVM forms were 2.0x to 18x faster at 4x rows.

The Rust kernel for BNG cells​

gbx_bng_eastnorthasbng also has a Rust kernel in the env wheel. It beats the Python form by more than 2x on dedicated compute, so it stays. The ratios below compare the Python form with the Rust form.

Compute1 million rows4 million rows16 million rows
Dedicated8.0x12.4x12.3x

The Rust form runs at the cost of moving the rows, so these ratios are a lower bound on the kernel gain.

Rust for raster decode

Rust did not clear its bar for raster decode: the Python decode ran at 1.03x on dedicated and 0.97x on standard. GeoBrix continues to assess where Rust can help further.

The Rust kernel for TIN triangulation​

gbx_st_triangulate, gbx_st_interpolateelevationbbox and gbx_st_interpolateelevationgeom triangulate with a Rust port of JTS 1.20 in the env wheel. It gives the JVM level's triangles exactly, in both modes. Without the Rust module, the Python level takes SciPy's triangles where they are provably the only Delaunay triangulation. Otherwise it runs a pure-Python port of JTS.

A grid is the slow case for the pure-Python port, because its points lie four to a circle. The times below are seconds for one triangulation, in one process on Linux aarch64. Each input has one break line of 20 vertices.

InputModeRustPure PythonJVM
5,000 random pointsconstrained0.0170.0230.034
5,000 random pointsconforming0.0080.0300.021
100,000 random pointsconstrained0.670.800.67
100,000 random pointsconforming0.471.690.81
40,000-point gridconstrained0.229.90.26
40,000-point gridconforming0.2611.10.39
250,000-point gridconstrained1.81456.5
250,000-point gridconforming1.815210.8
1,000,000-point gridconstrained13.0not run42.5
1,000,000-point gridconforming19.3not run78.8

The pure-Python port was not run on the 1,000,000-point grid, because the 250,000-point grid took over 60 seconds. The elevation functions sample Z in batches through a triangle index, at the same Z as before.

UC functions​

A Unity Catalog function runs on a SQL warehouse or any compute that reads the catalog. The Unity Catalog functions page lists the functions and how to install them.

  • Without the JAR. Each function is a Unity Catalog Python function.
  • With the JAR. gbx_bng_kring, gbx_bng_aswkb and gbx_bng_centroid run as Unity Catalog Scala functions when the install folder holds the JAR of this wheel. They are verified on a SQL warehouse.

A Scala function that needs GDAL is not proven on Unity Catalog. GeoBrix does not offer GDAL raster functions on Unity Catalog with the JAR.

MeasureResult
Cost of an empty statement (SELECT 1)0.53 to 0.63 s
One Python function call over 1 million rowsAbout 10.3 to 11 s per statement (median)
Same function, Python against Scala, 1 million rows15.4 s against 10.7 s
Scala BNG function at environment version 6, X-Small PRO warehouse11.2 to 11.6 s per 1 million rows
Aggregate that collects tiles in the functionPasses with 10 tiles of 512 by 512 (4.2 MB each). 50 tiles fail with out-of-memory.

The first three rows come from separate runs. Do not subtract one from another.

Unity Catalog functions refuse input they cannot read correctly, and each refusal carries a Fix: line.

  • A geometry whose SRID does not match the function: BNG functions need 27700, and quadbin and H3 functions need 4326.
  • A BINARY value passed where a GEOMETRY is expected. Use st_geomfromwkb(wkb, srid).
  • A CRS in a form other than an integer SRID, EPSG:<n> or ESRI:<n>.

Data that a function cannot serve gives NULL. The session raises an error for some of the same data. For example, gbx_quadbin_polyfill raises in a session when the polygon needs more than 1,000,000 cells, and gives NULL on Unity Catalog.

Raw files do not reach Unity Catalog through functions. Read them with a session reader, write a Delta table, and query the table.

Grouped merge and combine​

The aggregates gbx_rst_merge_agg and gbx_rst_combineavg_agg stream their group under the worker read cap. The cap is 64 MiB on Serverless and 256 MiB on classic compute.

  • A result over the cap refuses. The error carries the VRT-mosaic Fix:. Keep the tiles as files on a Volume. Build the mosaic with rasterx.helpers.mint_vrt, or use the cog_gbx writer in mosaic mode. Then read the VRT.
  • Members that do not fit in memory. Pass virtual tiles (the readers' default): they merge as files, whatever the group size. Tiles with bytes must fit the task, or use merge_by_key, which keeps them in scratch files.
  • Members on different CRS or pixel size. Bring them to one grid first with gbx_rst_transform and gbx_rst_resample_to_res.
  • A combine over the cap. Retile first with gbx_rst_retile, or use combine_by_key.

The array form, gbx_rst_combineavg(collect_list(tile)) and the six other gbx_rst_combine* functions, receives a whole group as one row. The rows cross to Python as Arrow batches, so the executor's JVM heap does not hold the tiles. A task still holds every group of its shuffle partition at once. That is the encoded tiles in the batch, plus a few times their size in Python. With large groups (tens of MB per tile, many groups per task), use one of two routes. On a classic cluster, give the shuffle more partitions. Or use combine_by_key (avg or max), which reads a key's tiles one at a time. Serverless fixes the shuffle width, so use combine_by_key or retile there.

combine_by_key and merge_by_key (in rasterx.helpers) shuffle by key and fold each group once. merge_by_key hands each tile to the merge as it arrives, so a key's memory does not follow its tile count. It shuffles with repartition(N, keys), where N is num_partitions or the session's task slots (at least 64). At 1,000 groups on dedicated compute:

RouteMergeCombine
Helper (merge_by_key, combine_by_key)48.2 s59.7 s
Python aggregate67.9 s129.6 s
JVM aggregate96.3 s62.5 s

These times were measured before the Python aggregates streamed their groups, and before merge_by_key stopped holding its groups. The helper's peak execution memory was 40.3 GB for the merge, against 7.4 GB for the Python aggregate. On Serverless, merge_by_key(method="vrt") finished 1,000 groups in 28 minutes, before the shuffle had a fixed width. The streamed aggregates and the new shuffle are not yet measured there.

retile_virtual is not the large-raster path. It ran 1.16x slower than the plain retile on a dedicated cluster (58.4 s against 50.4 s) and ran out of memory on Serverless.

Aggregates by compute​

The default is the same on every compute: the grouped aggregate. On a dedicated cluster with the JAR, gbx_rst_bng_rasterize_agg runs its JVM form, which is the fastest route measured. For large groups, a different route worked best on each compute. The measured columns are ratios to the Python grouped aggregate on the same compute. Lower is faster. Do not compare a ratio from one compute with another.

Dedicated (one driver and four m5d.2xlarge workers, DBR 19)

AggregateRouteMeasured
Merge, tiles with bytesGrouped aggregate.The finalize route took 3.2x the time at 250 tiles and 0.60x at 1,000 tiles (single sample). At 4,000 tiles only the finalize route finished (310.5 s). A group with one hot key of about 2.9 GB fails on the grouped aggregate and the finalize route, at the 2 GiB Arrow buffer.
Merge, tiles by referenceGrouped aggregate.At 250 and 1,000 tiles the finalize route took 1.03x and 0.88x the time. The table function took 0.63x and 1.24x.
Rasterize canvases, 16 million cellsGrouped aggregate (JVM form on the JAR).JVM form 0.46x. Finalize route 0.92x. Tree of partial merges 1.23x. Table function 2.71x. With the cells as input, the JVM form took 0.40x.

Standard

AggregateRouteMeasured
MergeGrouped aggregate. The finalize route is 1.7x slower.Not re-measured.
Rasterize canvasesGrouped aggregate. The twin matches it (0.96x).Not re-measured.

Serverless (per-task behavior; no seconds beside the other computes)

AggregateRouteMeasured
Merge, tiles with bytesFinalize route (0.98x of grouped). It collects the group, then merges once.Fails at every size tried: the group passes the 1 GiB task limit, or the Python worker exits.
Merge, tiles by referenceFinalize route.The grouped aggregate and the finalize route ran within 2% of each other at 250 tiles. Larger sizes were not run.
Rasterize canvasesTree of partial merges for large groups. The finalize route runs out of memory at 16x. The twin (1.08x) serves the rest.At 16 million cells the tree took 1.6x and the finalize route 6.9x the grouped aggregate's time.

The scalar twins serve the finalize route for rasterize on every compute. A twin takes the whole group as one array, ARRAY<STRUCT<cellid, value>>, for example collect_list(struct(cellid, value)). It returns the same GeoTIFF bytes as the aggregate. A repeated cell burns its largest value. A NULL value in a typed column never wins against a number. A NULL cell id is skipped.

Scalar twinAggregate it matchesCell ids
gbx_rst_bng_rasterizegbx_rst_bng_rasterize_aggSTRING, for example 'TQ3080'
gbx_rst_h3_rasterizegbx_rst_h3_rasterize_aggBIGINT
gbx_rst_quadbin_rasterizegbx_rst_quadbin_rasterize_aggBIGINT
gbx_rst_custom_rasterizegbx_rst_custom_rasterize_aggBIGINT, with the grid as the second argument

A twin holds the group in one value. Use it for a group that is already collected. Do not use it for a group of millions of cells.

For large groups, two table functions stream the group one row at a time. They read TABLE(...) PARTITION BY (key):

  • gbx_rst_merge_tvf merges each key's tiles into one mosaic.
  • gbx_rst_bng_rasterize_tvf burns each key's BNG cells onto one canvas.

Both need less memory than the grouped aggregate and produce the same pixels. Neither runs on Serverless, whose table-function engine fails PARTITION BY once a task holds more than one row: call the aggregate there. A key whose mosaic is too large to build raises with the VRT-mosaic Fix:.

Some aggregates have no twin. They are session aggregates, called with GROUP BY:

  • gbx_bng_cellunion_agg and gbx_bng_cellintersection_agg, whose scalar names are two-argument chip functions.
  • gbx_h3_cellfill, gbx_quadbin_cellfill, gbx_bng_cellfill, gbx_custom_cellfill, gbx_st_asmvt and gbx_st_coverage*.
  • gbx_pmtiles_agg, whose archive can reach 100 MiB.

Generators in SQL​

On every compute a generator is a table function. Call it with LATERAL:

SELECT z, x, y, tile
FROM your_table,
LATERAL gbx_rst_h3_rastertogridavg(tile, 8); -- one row per H3 cell at resolution 8

Virtual tile read performance​

Key takeaways
  • Deferred edits run 1.5–12× faster on virtual tiles — metadata operations (set-CRS/SRID/nodata/band-select) complete without pixel I/O. Chain several deferred edits before a terminal step to materialize once and pay pixel cost only at the end.
  • Open amortization is the lever — grouping same-source windows (via ORDER BY path or repartitioning) cuts per-tile open cost from ~multiple-seconds to ~2 ms per window. Without amortization (per-tile-open), stream reads grow expensive with file size; FUSE becomes viable.
  • FILE-on ≈ FILE-off for reads on dedicated clusters — FILE is a governance/access mechanism, not a per-tile read optimization. Amortization (grouped executor) is the performance lever. FILE is available on Serverless too, in a workspace with the File type preview.
  • COG + amortization beats FUSE — byte-range stream reads are 10–290× faster than FUSE for windowed COGs when opens are amortized. Choose COG format and group by source path for best throughput.

Virtual tiles are read on demand. Reading cost is dominated by opening the source raster, not by the pixel read itself. A pipeline that reads many tiles from the same source raster should open that source once. It should amortize the cost across all its windows, not open the source once per tile.

Two access modes: stream and FUSE​

GeoBrix's virtual tile reader supports two access modes:

ModePer-open costTypical per-window costMemory per open sourceBest for
Byte-range stream (.open())Scales with file size and layout~2 ms (COG, with amortization)RAM ≈ source file sizeGrouped reads on small-to-moderate files
FUSE (.as_local_file())Flat ~7 ms at any size~124 ms (cold read baseline)Low — reads only requested bytes lazilyLarge files, per-tile-open, RAM-constrained workers

When the open cost is amortized across multiple windows from the same source, byte-range stream reads are 10–290× faster than FUSE for windowed COG reads. Without amortization (one open per tile), FUSE's flat open cost wins: stream's per-open header parse grows with file size and becomes prohibitive at scale.

You don't choose stream vs FUSE — GeoBrix does, automatically, per source. The reader inspects each source's size and layout and picks the access mode that's correct for it. This table is what GeoBrix does for you, not a decision you make:

Source (per file)GeoBrix auto-selectsWhy
Tiled / COG, ≤ 256 MiBbyte-range streamrandom-window reads are efficient on a tiled layout; the source buffers into executor RAM
Large (over 256 MiB) or stripedFUSE (lazy)fetches only the bytes each window needs — no whole-file RAM, safe at any size
stream or FUSE open failsstaging fallback (temp file)correctness over speed

The 256 MiB stream cutoff (GBX_STREAM_MAX_BYTES) is an optional environment override — the default handles the common cases, so you normally set nothing.

Executor RAM is auto-managed by a byte-budgeted LRU cache — you don't size or clear it. Open sources are held in a per-partition LRU keyed by source path, capped at a byte budget (GBX_LRU_MAX_BYTES, default 4 GiB). Stream handles count their buffered size against the budget; FUSE handles count only a small nominal (they don't buffer the file). When the budget would be exceeded, the least-recently-used source is evicted and closed. So a partition never blows executor RAM no matter how many sources it touches. Repeated windows from an already-open source are ~2 ms cache hits (the amortization in the next section).

Why the auto-rules look the way they do — the striped-file trap GeoBrix sidesteps

Opening a large source via byte-range buffers it into executor RAM. For a large striped GeoTIFF, parsing the strip-offset table over byte-range can reach 47–54 seconds per open at 10 GB. The open consumes 10 GB of executor RAM. That is exactly why GeoBrix routes large or striped sources to FUSE (lazy, low-RAM) automatically rather than streaming them. For best windowed-read throughput, prefer COGs — a tiled COG under the threshold takes the fast stream path and amortizes across its windows.

Sidecar files and folder listings​

When GDAL opens a raster it looks for the raster's sidecar files: external overviews (.ovr), masks (.msk), .aux.xml metadata and world files (.tfw, .wld). By default it lists the whole folder to find them, at every open. On a Volume that listing gets slower the more files share the folder. For a folder of 745 GeoTIFFs on a Serverless worker it took from 0.3 s to 10 s per open in our runs. It took about 2 s for 5,000 files and about 14.5 s for 40,000. Checking each sidecar by name instead (GDAL's GDAL_DISABLE_READDIR_ON_OPEN=TRUE, 5 to 7 names an open) costs about as much as a small listing. That is because a check for a file that does not exist is slow too. Unlike the listing, the cost does not grow with the folder.

The Python level lists a folder once per Python worker. It lists the folder when the worker opens a second, different file of it. A folder where the worker opens only one file, however often, is never listed. From then on the worker uses the listing to decide, for each open, where GDAL looks:

  • No file in the folder can be a sidecar of this one. The file is also a GeoTIFF, PNG, JPEG, JPEG 2000, netCDF, HDF or GRIB file (.tif, .tiff, .png, .jpg, .jpeg, .jp2, .nc, .h5, .he5, .hdf, .grib, .grb, .grb2, .grib2, in any case). GDAL then looks for none. On a Serverless worker an open of a fresh file in the 745-file folder took a median of about 165 ms this way. The same open took about 415 ms with the checks by name.
  • The file has sidecars GDAL finds by name (for example x.tif.ovr, x.tif.aux.xml, x.tfw): GDAL checks the names.
  • Anything else. This includes a sidecar whose name mixes case, such as x.Tfw. It also includes another file with the same name and a different extension. It also includes a vendor metadata file such as METADATA.DIM or *_MTL.txt in the folder. In these cases GDAL lists the folder itself and matches names in any case, as it does by default.
  • A file of any other kind has its sidecars checked by name. This covers a VRT (also one named .xml), a GDAL tile index, a .SAFE, .json or HFA .img dataset, a .zarr, or an unknown extension. Such a file may open other files that have sidecars of their own.

Before a folder is listed, GDAL checks sidecars by name. The open that lists a folder waits for the listing. On a Serverless worker that is about 0.5 s for 1,000 files and 14.5 s for 40,000. A Volume returns a folder's names only once it has fetched them all. The worker lists a folder once, whatever its size, up to 100,000 files. Each file then takes the mode its own sidecars call for. So a file with no sidecar in a folder of 10,000 files opens with no sidecar look-up. In that folder the checks by name cost a 10,000-tile read 1.7 to 3.1 times the time of the same read with no look-up. A folder over GDAL's own listing limit never gives the NO choice. That limit is GDAL_READDIR_LIMIT_ON_OPEN, 1,000 unless you set it, and GDAL counts . and .. in it. GDAL would list such a folder at every open and then drop the listing, so the open checks sidecars by name instead. A folder of more than 100,000 files is not listed, and its files are opened with the checks by name. Tiles read with raster_gbx from such a folder skip that listing too. The reader counts the files of each folder when it plans the read. It puts the count of a folder over 100,000 in each tile's metadata (path_folder_files). The count only ever spares the listing; it never makes GDAL skip the sidecar look-up. A file missing from the listing (written after it) has the worker list the folder again. That happens at most once every 10 seconds per folder, and no sooner than 10 times the time the last listing took. The same wait holds for a folder whose listing the worker dropped to save memory. A sidecar added to a folder after a worker listed it is not seen until the folder is listed again or the worker restarts. To pick up a new world file or overview at once, start a new job, or set GDAL_DISABLE_READDIR_ON_OPEN yourself. Files read through a cloud path (/vsis3/, s3://, ...) are opened with the checks by name. The check GeoBrix makes before it reads a Volume file directly never looks for sidecars.

The setting reaches the rest of the Python process. Importing the Python implementation (anything that imports databricks.labs.gbx.core.crs) sets GDAL_DISABLE_READDIR_ON_OPEN=TRUE in the environment of the whole Python process, unless it is set already. Your own rasterio, GDAL (osgeo) or Fiona code in that process, and the programs it starts (gdalinfo, tippecanoe), then check sidecars by name too. The vector readers are not affected. GDAL's shapefile driver uses no folder listing either way. It looks a shapefile's .prj up by name (lower-case extension, then upper-case). For rasters, two kinds of file are then found only with GDAL's listing. One is a sidecar whose name mixes case (x.Tfw). The other is a vendor metadata file (METADATA.DIM, *_MTL.txt, DIM_*.XML) whose name differs in case from the one GDAL builds. To keep GDAL's own behavior, set GDAL_DISABLE_READDIR_ON_OPEN=NO. Set YES for the checks by name without the per-file choice. Set the value in the environment of the Python workers before GeoBrix is imported there, as an environment variable of the cluster or the job. A notebook's os.environ or a rasterio.Env on the driver does not reach the workers.

Your value decides every open. If you set GDAL_DISABLE_READDIR_ON_OPEN before the import (any value, TRUE included), or in a rasterio.Env around your own reads in the same process, GeoBrix makes no per-file choice. GDAL uses your value. The value NO gives its own listing at each open, YES or TRUE gives the checks by name, and EMPTY_DIR ignores sidecars. A GDAL configuration option set to TRUE later (for example with gdal.SetConfigOption) cannot be told apart from GeoBrix's own value, so the per-file choice still applies then.

A rasterio.Env that names the option fixes it for the process. When the outermost rasterio.Env entered with GDAL_DISABLE_READDIR_ON_OPEN exits, rasterio sets the value it found on entry as a GDAL configuration option for the whole process. From then on that option, not the environment variable, decides, and a later change of the environment variable has no effect. Set the environment variable before the first such rasterio.Env.

Per-partition open-amortization (the grouped executor)​

GeoBrix's grouped executor holds a small per-partition LRU cache of open stream handles, keyed by source path. The first access for a source in a partition opens it (cache miss). All subsequent windows from that source in the same partition are cache hits (~2 ms each). When tiles are sorted by source path within each partition, even a partition holding several sources fully amortizes at LRU size ~2.

Measured on a 647 MB COG corpus (15 sources × 12 windows = 180 tiles):

Write layoutRead approachOpensTotal time
Scattered (no alignment)Dumb (as-written)135173 s
ORDER BY pathDumb (as-written)1537 s
ORDER BY pathSmart (re-partition)1511 s

To enable amortization after a join or reshape that has scattered tiles across partitions, re-align before processing:

df = df.repartition(n, "tile.path").sortWithinPartitions("tile.path")

Size n for parallelism, not for file count:

  • Classic clusters (fixed workers): n ≈ 3–5× total worker cores — e.g. 20 workers × 4 cores → n ≈ 100
  • Serverless (elastic workers): n is the parallelism signal; smaller values pull in fewer workers, larger pull in more

Do not set n = number_of_files for large corpora — over-partitioning produces tiny tasks and scheduling overhead.

MANAGED vs EXTERNAL: identical read performance​

A tile column declared FILE MANAGED and one declared FILE EXTERNAL perform identically for reads. Both resolve to the same underlying paths; the open-cost and windowed-read cost are indistinguishable. The choice between MANAGED and EXTERNAL is about governance and lifecycle, not read speed. MANAGED tiles carry governed lifecycle (tied to the table) and content_type detection; EXTERNAL tiles reference files managed independently in a Volume. Choose based on governance requirements, not on any expected read-latency difference.

Write-side layout for efficient reads​

The GeoBrix writer optionally lays tiles out source-aligned at write time, so the reader can amortize for free on the first read. No re-partition step is required after a normal read-write round trip.

Write strategyEffect on reads
INSERT … ORDER BY tile.pathImmediate physical grouping — dumb reads amortize without any re-partition
CLUSTER BY (tile.path) on the table + periodic OPTIMIZEDurable layout after Delta applies liquid clustering
CLUSTER BY (tile.path) on the initial insert only (no OPTIMIZE)May not be grouped yet — combine with ORDER BY in the INSERT for insert-time grouping
No alignmentScattered — requires explicit repartition + sortWithinPartitions on every read
Avoid partitionBy("tile.path")

tile.path is high-cardinality — one value per source file. Using it as a Delta partition column creates thousands of partition directories, causing metadata explosion and slow query planning. Use ORDER BY and CLUSTER BY instead.

FILE type and path_mode​

FILE is available on Databricks Runtime 19 dedicated clusters and Serverless, in a workspace with the File type preview. When it is, the tile struct's path_mode field records how the virtual tile was stored:

path_modeMeaning
nullMaterialized tile (raster bytes present), or a plain FUSE-path virtual tile
"external"FILE EXTERNAL virtual tile — opened via byte-range stream
"managed"FILE MANAGED virtual tile — opened via byte-range stream; lifecycle governed by the table

On runtimes without FILE support, path_mode is always null and virtual tiles use the FUSE path. These runtimes are DBR 17/18, the Databricks Container Service image, and any compute in a workspace without the File type preview. Behavior there is correct and unchanged. Writers default to file_mode="fuse"; pass "auto" or "external" to opt in to FILE.


How the Python functions run​

The Python level picks a Spark execution shape for each function. Fan-out generators use streaming UDTFs. Aggregators use grouped-aggregate Arrow UDFs. Per-tile transforms use Arrow scalar UDFs.

Streaming UDTFs​

A Python UDTF (User-Defined Table Function) is a class with an eval method that yields rows. Spark calls it as a LATERAL table function. One input row fans out to any number of output rows without buffering the whole result.

This shape fits generator operations, where one input tile produces many output rows. Buffering all rows in a list would hold the whole result in worker memory. Streaming with yield releases each row as soon as it exists.

The generators that stream:

FamilyFunctions
Tilinggbx_rst_retile, gbx_rst_tooverlappingtiles, gbx_rst_maketiles, gbx_rst_separatebands, gbx_rst_xyzpyramid
Vectorizegbx_rst_polygonize
Raster to gridgbx_rst_{h3,quadbin,bng,custom}_rastertogrid*
Tessellategbx_rst_{h3,quadbin,bng}_tessellate, gbx_bng_tessellateexplode
BNG explodesgbx_bng_{kring,kloop,geomkring,geomkloop}explode
Vector tiles and TINgbx_st_asmvt_pyramid, gbx_st_triangulate, gbx_st_interpolateelevationbbox, gbx_st_interpolateelevationgeom

Grouped-aggregate UDFs​

A grouped-aggregate pandas_udf works on one group at a time. Spark shuffles the rows for a key to one worker. It calls the UDF once with all values in the group and gets one result.

This shape fits aggregators, which reduce many rows to one output per key, such as one merged raster or one vector tile. They sit inside a standard .groupBy(...).agg(...) call.

FamilyFunctions
Rastergbx_rst_merge_agg, gbx_rst_combineavg_agg, gbx_rst_frombands_agg, gbx_rst_derivedband_agg, gbx_rst_rasterize_agg, gbx_rst_gridfrompoints_agg, gbx_rst_binpoints_agg, gbx_rst_dtmfromgeoms_agg
Gridgbx_rst_{h3,quadbin,bng,custom}_rasterize_agg, gbx_{bng,quadbin}_cellunion_agg, gbx_bng_cellintersection_agg, the *_cellfill functions
Vectorgbx_st_asmvt, gbx_st_coverageisvalid, gbx_st_coverageinvalidedges
Archivesgbx_pmtiles_agg
Memory scales with group size

A grouped aggregate realizes its whole group in the worker, so memory follows the rows per group. For most tile aggregators that is a few tiles per key. Point binning (rst_binpoints_agg) takes one row per point, so a full-resolution LiDAR tile can exhaust worker memory. The helper rasterx.helpers.bin_points_tiled avoids this with a two-stage aggregation. Peak memory is the raster grid, not the point count, and the output is identical for max, min, mean and count. See RasterX › rst_binpoints_agg and Serverless & Memory.

Arrow scalar UDFs​

A vectorized Arrow scalar pandas_udf receives an Arrow batch of rows, calls the function once per batch, and returns a pd.Series. The JVM and Python boundary is crossed once per batch, not once per row.

This shape fits one-row-in, one-row-out transforms: tile accessors, warps, edits, band math, terrain and the vector scalars. Functions that return MapType use a plain @f.udf for SQL registration, because Arrow does not support MapType in every pandas_udf build.

The row functions and table functions over tiles move their rows to Python in Arrow batches on every DBR 19 and Serverless compute. A row function gets its batch as pyarrow arrays, with no pandas step. So integer arguments, BIGINT cell ids and NULLs arrive exactly, even where classic DBR 19 keeps its legacy pandas conversion on. GeoBrix turns a batch into Python values a slice of rows at a time. So a large batch never holds a second copy of all its tiles. DBR 17.3 and 18 (Spark 4.0) send the rows as pickles, because Spark 4.0 can round a large BIGINT cell id in an Arrow batch. A tile table written in large Parquet row groups still costs memory per batch: see Tile tables with large row groups.

Chaining functions​

Compose tile functions in one expression, for example rx.rst_slope(rx.rst_setcrs(col("tile"), "EPSG:32633")). Do not split them across separate .select() or .withColumn() steps.

Spark fuses chained Column calls into a single Python worker. The intermediate tile passes between functions as a live object. The JVM and Python boundary is crossed once for the chain. Separate steps send each intermediate tile back to the JVM and re-serialize it. Chaining also composes with virtual-tile deferral: deferrable operations stay lazy and stay in one worker.

Vectorized cores​

The compute under each UDF shape comes from established Python libraries.

LibraryRole
rasterioTile open and decode, clip, COG conversion, band I/O
NumPyArray operations
SciPyFocal filters (rst_filter, rst_convolve). Delaunay triangulation for the TIN functions where the env wheel's Rust module is absent.
rio-tilerXYZ and web-tile output (rst_tilexyz, rst_xyzpyramid)
GDAL (raster algorithms)Terrain, color relief, band math, warp and resample, fill NoData, summary, contour, polygonize, viewshed, and gbx_rst_gdal
shapelyWKB geometry handling: clip, rasterize, grid aggregation, legacy-struct decode
pyogrioVector reader I/O in Arrow-native columnar batches
mapbox-vector-tileMVT protobuf encode and decode (st_asmvt, st_asmvt_pyramid)

Each library is called directly by the UDF. There is no subprocess and no native bridge.


Streaming versus consolidated returns​

Not every fan-out function is a streaming UDTF. The choice follows the cost.

Stream (UDTF) when one input row fans out to many output rows and the consumer needs individual rows. A consolidated ARRAY return carries three costs. It buffers the whole fan-out in worker memory. It serializes the nested array across the boundary. It explodes the array again downstream. These costs grow with the fan-out.

The clearest case is rst_separatebands on a hyperspectral raster. Each band tile carries its own bytes. A consolidated return holds all band tiles of one input row at once: 200 times the tile size for a 200-band scene. The streaming UDTF yields one band tile at a time, so worker memory stays flat whatever the band count. The same logic applies to fine tessellation, deep XYZ pyramids and retiling, where the output tile count grows with the input raster.

Consolidate when the collection is the answer. An aggregation (*_agg) produces one result per group, and the consolidation is the reduction. The *_agg reductions are the only consolidated returns. Every fan-out generator streams.