netcdf-c/include
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
..
.gitignore
ceconstraints.h
CMakeLists.txt Fix bad cmake install location 2022-07-06 15:01:23 -06:00
err_macros.h
fbits.h
hdf4dispatch.h
hdf5dispatch.h
hdf5internal.h Improve S3 Documentation and Support 2023-04-25 17:15:06 -06:00
isnan.h Removed unneeded code on OSX. 2020-08-26 16:29:51 -06:00
Makefile.am Ensure that netcdf_json.h does not interfere with ncjson. 2022-07-05 22:03:52 -06:00
nc3dispatch.h Fixed Clang -Wstrict-prototypes warnings 2022-03-01 23:21:24 -05:00
nc3internal.h Make sure mode flags are properly defined in netcdf.h 2022-01-11 19:05:46 -07:00
nc4dispatch.h further preparation for try 2 at quantizing 2021-08-24 01:04:55 -06:00
nc4internal.h Improve performance of the nc_reclaim_data and nc_copy_data functions. 2023-05-20 17:11:25 -06:00
nc_hashmap.h
nc_logging.h Additional Fixes to NCZarr 2020-12-16 20:48:02 -07:00
nc_provenance.h Provide a Number of fixes/improvements to NCZarr 2020-11-19 17:01:04 -07:00
nc_tests.h adding pre-processor constant NC_MAX_FILENAME to nc_tests.h 2022-07-08 07:27:54 -06:00
nc.h Improve performance of the nc_reclaim_data and nc_copy_data functions. 2023-05-20 17:11:25 -06:00
ncauth.h Enable ACCEPT_ENCODING on DAP requests 2023-02-16 20:21:22 -07:00
ncbytes.h Improve S3 Documentation and Support 2023-04-25 17:15:06 -06:00
ncconfigure.h Improve S3 Documentation and Support 2023-04-25 17:15:06 -06:00
nccrc.h Provide a Number of fixes/improvements to NCZarr 2020-11-19 17:01:04 -07:00
ncdap.h Additional DAP4 fixes 2023-01-18 19:47:29 -07:00
ncdimscale.h
ncdispatch.h fixed parallel functions for netcdf-fortran build 2022-04-24 05:41:14 -06:00
ncexhash.h ncexhash: replace invalid UTF-8 sequence 2021-07-28 12:51:30 -04:00
ncexternl.h
nchashmap.h Provide a Number of fixes/improvements to NCZarr 2020-11-19 17:01:04 -07:00
nchttp.h Improve S3 Documentation and Support 2023-04-25 17:15:06 -06:00
ncindex.h
ncjson.h Add support for Zarr string type to NCZarr 2022-08-27 20:21:13 -06:00
nclist.h Improve S3 Documentation and Support 2023-04-25 17:15:06 -06:00
nclog.h Improve S3 Documentation and Support 2023-04-25 17:15:06 -06:00
ncmodel.h
ncoffsets.h Improve performance of the nc_reclaim_data and nc_copy_data functions. 2023-05-20 17:11:25 -06:00
ncpathmgr.h Support MSYS2/Mingw platform 2021-12-23 22:18:56 -07:00
ncrc.h Improve S3 Documentation and Support 2023-04-25 17:15:06 -06:00
ncs3sdk.h Improve S3 Documentation and Support 2023-04-25 17:15:06 -06:00
nctestserver.h Additional DAP4 fixes 2023-01-18 19:47:29 -07:00
nctime.h
ncuri.h Improve S3 Documentation and Support 2023-04-25 17:15:06 -06:00
ncurlmodel.h
ncutf8.h
ncxcache.h Provide a Number of fixes/improvements to NCZarr 2020-11-19 17:01:04 -07:00
ncxml.h Fix dll exports for ncxml 2022-04-12 19:16:58 +10:00
netcdf_aux.h Improve performance of the nc_reclaim_data and nc_copy_data functions. 2023-05-20 17:11:25 -06:00
netcdf_dispatch.h.in Enhance/Fix filter support 2022-03-14 12:39:37 -06:00
netcdf_f.h
netcdf_filter_build.h Support installation of filters into user-specified location 2022-04-29 14:31:55 -06:00
netcdf_filter_hdf5_build.h Enhance/Fix filter support 2022-03-14 12:39:37 -06:00
netcdf_filter.h added netcdf_filter.h to doxygen build 2022-05-04 13:12:48 -06:00
netcdf_json.h Improve S3 Documentation and Support 2023-04-25 17:15:06 -06:00
netcdf_mem.h
netcdf_meta.h.in Improve S3 Documentation and Support 2023-04-25 17:15:06 -06:00
netcdf_par.h
netcdf.h Improve performance of the nc_reclaim_data and nc_copy_data functions. 2023-05-20 17:11:25 -06:00
onstack.h
rnd.h
XGetopt.h