netcdf-c/unit_test
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
..
CMakeLists.txt Improve performance of the nc_reclaim_data and nc_copy_data functions. 2023-05-20 17:11:25 -06:00
Makefile.am Improve performance of the nc_reclaim_data and nc_copy_data functions. 2023-05-20 17:11:25 -06:00
nctest_netcdf4_classic.nc Support MSYS2/Mingw platform 2021-12-23 22:18:56 -07:00
reclaim_tests.cdl Improve performance of the nc_reclaim_data and nc_copy_data functions. 2023-05-20 17:11:25 -06:00
run_reclaim_tests.sh Improve performance of the nc_reclaim_data and nc_copy_data functions. 2023-05-20 17:11:25 -06:00
run_s3sdk.sh s3-off 2023-04-30 18:41:31 -06:00
test_ncuri.c This PR adds EXPERIMENTAL support for accessing data in the 2020-06-28 18:02:47 -06:00
test_pathcvt.c Support installation of filters into user-specified location 2022-04-29 14:31:55 -06:00
test_s3sdk.c ## Addendum [5/9/23] 2023-05-09 21:13:49 -06:00
timer_utils.c Additional Fixes to NCZarr 2020-12-16 20:48:02 -07:00
timer_utils.h Make use of clock_gettime be conditional. 2020-12-06 18:19:53 -07:00
tst_exhash.c Additional Fixes to NCZarr 2020-12-16 20:48:02 -07:00
tst_nc4internal.c Change (again), and hopefully simplify, the file model inference algorithm. 2019-09-29 12:59:28 -06:00
tst_nclist.c fixed warning 2020-03-02 16:29:52 -07:00
tst_reclaim.c Improve performance of the nc_reclaim_data and nc_copy_data functions. 2023-05-20 17:11:25 -06:00
tst_xcache.c Fix a number of OS specific bugs 2021-11-03 12:49:54 -06:00