netcdf-c/libnczarr
Dennis Heimbigner fb40a72b45 Improve performance of the nc_reclaim_data and nc_copy_data functions.
re: Issue https://github.com/Unidata/netcdf-c/issues/2685
re: PR https://github.com/Unidata/netcdf-c/pull/2179

As noted in PR https://github.com/Unidata/netcdf-c/pull/2179,
the old code did not allow for reclaiming instances of types,
nor for properly copying them. That PR provided new functions
capable of reclaiming/copying instances of arbitrary types.

However, as noted by Issue https://github.com/Unidata/netcdf-c/issues/2685, using these
most general functions resulted in a significant performance
degradation, even for common cases.

This PR attempts to mitigate the cost of using the general
reclaim/copy functions in two ways.

First, the previous functions operating at the top level by
using ncid and typeid arguments. These functions were augmented
with equivalent versions that used the netcdf-c library internal
data structures to allow direct access to needed information.
These new functions are used internally to the library.

The second mitigation involves optimizing the internal functions
by providing early tests for common cases. This avoids
unnecessary recursive function calls.

The overall result is a significant improvement in speed by a
factor of roughly twenty -- your mileage may vary. These
optimized functions are still not as fast as the original (more
limited) functions, but they are getting close. Additional optimizations are
possible. But the cost is a significant "uglification" of the
code that I deemed a step too far, at least for now.

## Misc. Changes
1. Added a test case to check the proper reclamation/copy of complex types.
2. Found and fixed some places where nc_reclaim/copy should have been used.
3. Replaced, in the netcdf-c library, (almost all) occurrences of nc_reclaim_copy with calls to NC_reclaim/copy. This plus the optimizations is the primary speed-up mechanism.
4. In DAP4, the metadata is held in a substrate in-memory file; this required some changes so that the reclaim/copy code accessed that substrate dispatcher rather than the DAP4 dispatcher.
5. Re-factored and isolated the code that computes if a type is (transitively) variable-sized or not.
6. Clean up the reclamation code in ncgen; adding the use of nc_reclaim exposed some memory problems.
2023-05-20 17:11:25 -06:00
..
obsolete Add filter support to NCZarr 2021-09-02 17:04:26 -06:00
CMakeLists.txt Improve S3 Documentation and Support 2023-04-25 17:15:06 -06:00
Makefile.am Improve S3 Documentation and Support 2023-04-25 17:15:06 -06:00
SimpleBinStream.h This PR adds EXPERIMENTAL support for accessing data in the 2020-06-28 18:02:47 -06:00
zarr.c Check at nc_open if file appears to be in NCZarr/Zarr format. 2023-03-13 13:24:14 -06:00
zarr.h Add support for Zarr string type to NCZarr 2022-08-27 20:21:13 -06:00
zattr.c Improve performance of the nc_reclaim_data and nc_copy_data functions. 2023-05-20 17:11:25 -06:00
zcache.h Add support for Zarr string type to NCZarr 2022-08-27 20:21:13 -06:00
zchunking.c More NCZarr optimizations 2021-01-06 13:35:59 -07:00
zchunking.h Add filter support to NCZarr 2021-09-02 17:04:26 -06:00
zclose.c Add support for Zarr string type to NCZarr 2022-08-27 20:21:13 -06:00
zcreate.c Support MSYS2/Mingw platform 2021-12-23 22:18:56 -07:00
zcvt.c Fix some problems with PR https://github.com/Unidata/netcdf-c/pull/2492 2022-09-03 14:21:48 -06:00
zdebug.c Fix byterange handling of some URLS 2023-03-02 19:51:02 -07:00
zdebug.h notrace 2023-04-26 14:16:22 -06:00
zdim.c Provide a Number of fixes/improvements to NCZarr 2020-11-19 17:01:04 -07:00
zdispatch.c Enhance/Fix filter support 2022-03-14 12:39:37 -06:00
zdispatch.h Enhance/Fix filter support 2022-03-14 12:39:37 -06:00
zfile.c Merge branch 'main' into bloscfix.dmh 2022-09-06 13:49:18 -06:00
zfilter.c Improve S3 Documentation and Support 2023-04-25 17:15:06 -06:00
zfilter.h I made a major update to this PR with the following changes: 2022-05-19 22:00:40 -06:00
zgrp.c Provide a Number of fixes/improvements to NCZarr 2020-11-19 17:01:04 -07:00
zincludes.h Improve S3 Documentation and Support 2023-04-25 17:15:06 -06:00
zinternal.c Improve performance of the nc_reclaim_data and nc_copy_data functions. 2023-05-20 17:11:25 -06:00
zinternal.h Fix some problems with PR https://github.com/Unidata/netcdf-c/pull/2492 2022-09-03 14:21:48 -06:00
zmap_file.c Support MSYS2/Mingw platform 2021-12-23 22:18:56 -07:00
zmap_s3sdk.c Fix additional S3 support issues 2021-10-29 20:06:37 -06:00
zmap_zip.c Support MSYS2/Mingw platform 2021-12-23 22:18:56 -07:00
zmap.c Improve S3 Documentation and Support 2023-04-25 17:15:06 -06:00
zmap.h Improve S3 Documentation and Support 2023-04-25 17:15:06 -06:00
zodom.c More NCZarr optimizations 2021-01-06 13:35:59 -07:00
zodom.h More NCZarr optimizations 2021-01-06 13:35:59 -07:00
zopen.c Support MSYS2/Mingw platform 2021-12-23 22:18:56 -07:00
zprov.c Additional Fixes to NCZarr 2020-12-16 20:48:02 -07:00
zprovenance.h This PR adds EXPERIMENTAL support for accessing data in the 2020-06-28 18:02:47 -06:00
zs3sdk.cpp Significantly Improve Amazon S3 Cloud Storage Support 2021-09-27 18:36:33 -06:00
zsync.c Improve performance of the nc_reclaim_data and nc_copy_data functions. 2023-05-20 17:11:25 -06:00
ztype.c Improve performance of the nc_reclaim_data and nc_copy_data functions. 2023-05-20 17:11:25 -06:00
zutil.c Improve performance of the nc_reclaim_data and nc_copy_data functions. 2023-05-20 17:11:25 -06:00
zvar.c Improve performance of the nc_reclaim_data and nc_copy_data functions. 2023-05-20 17:11:25 -06:00
zwalk.c Improve performance of the nc_reclaim_data and nc_copy_data functions. 2023-05-20 17:11:25 -06:00
zxcache.c Improve performance of the nc_reclaim_data and nc_copy_data functions. 2023-05-20 17:11:25 -06:00