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 Added a new .gitignore specific to include/. 2014-09-18 15:05:08 -06:00
ceconstraints.h More standardizing of the copyright stanza. 2018-12-06 14:13:56 -07:00
CMakeLists.txt Fix bad cmake install location 2022-07-06 15:01:23 -06:00
err_macros.h cleanup of whitespace in include directory 2019-02-19 06:09:10 -07:00
fbits.h More standardizing of the copyright stanza. 2018-12-06 14:13:56 -07:00
hdf4dispatch.h raised NC_MAX_HDF4_NAME length to NC_MAX_NAME 2020-02-08 09:21:01 -07:00
hdf5dispatch.h Revert "Revert "Fix nczarr-experimental: improve build support, disengage hdf5 vs netcdf4 flags, and find AWS libraries"" 2020-08-17 19:15:47 -06:00
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 More standardizing of the copyright stanza. 2018-12-06 14:13:56 -07:00
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 Updated to use H5O_info2_t for HDF5 1.12 and the use of H5Oget_info3 instead of H5Gget_objinfo 2020-03-12 15:50:24 +00:00
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 More standardizing of the copyright stanza. 2018-12-06 14:13:56 -07:00
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 missinginclude 2020-07-09 13:30:33 -06:00
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 Change (again), and hopefully simplify, the file model inference algorithm. 2019-09-29 12:59:28 -06:00
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 More standardizing of the copyright stanza. 2018-12-06 14:13:56 -07:00
ncuri.h Improve S3 Documentation and Support 2023-04-25 17:15:06 -06:00
ncurlmodel.h This PR adds EXPERIMENTAL support for accessing data in the 2020-06-28 18:02:47 -06:00
ncutf8.h More standardizing of the copyright stanza. 2018-12-06 14:13:56 -07:00
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 More standardizing of the copyright stanza. 2018-12-06 14:13:56 -07:00
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 cleanup netcdf_mem.h and netcdf_dispatch.h 2019-10-28 10:56:24 -06:00
netcdf_meta.h.in Improve S3 Documentation and Support 2023-04-25 17:15:06 -06:00
netcdf_par.h fixed include issue 2019-12-20 07:43:39 -07:00
netcdf.h Improve performance of the nc_reclaim_data and nc_copy_data functions. 2023-05-20 17:11:25 -06:00
onstack.h More standardizing of the copyright stanza. 2018-12-06 14:13:56 -07:00
rnd.h More standardizing of the copyright stanza. 2018-12-06 14:13:56 -07:00
XGetopt.h Fix undefined references when using Visual Studio 2020-05-18 19:36:28 -06:00