netcdf-c/libdap4
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 Significantly Improve Amazon S3 Cloud Storage Support 2021-09-27 18:36:33 -06:00
d4bytes.c Updated copyright stanza in libdap4 2018-12-06 14:24:28 -07:00
d4bytes.h Updated copyright stanza in libdap4 2018-12-06 14:24:28 -07:00
d4chunk.c Cleanup DAP4 testing 2022-11-13 13:15:11 -07:00
d4chunk.h Updated copyright stanza in libdap4 2018-12-06 14:24:28 -07:00
d4curlflags.c Updated copyright stanza in libdap4 2018-12-06 14:24:28 -07:00
d4curlfunctions.c Enable ACCEPT_ENCODING on DAP requests 2023-02-16 20:21:22 -07:00
d4curlfunctions.h Updated copyright stanza in libdap4 2018-12-06 14:24:28 -07:00
d4cvt.c Updated copyright stanza in libdap4 2018-12-06 14:24:28 -07:00
d4data.c Additional DAP4 fixes 2023-01-18 19:47:29 -07:00
d4debug.c Improve performance of the nc_reclaim_data and nc_copy_data functions. 2023-05-20 17:11:25 -06:00
d4debug.h Cleanup DAP4 testing 2022-11-13 13:15:11 -07:00
d4dump.c Additional DAP4 fixes 2023-01-18 19:47:29 -07:00
d4file.c Improve performance of the nc_reclaim_data and nc_copy_data functions. 2023-05-20 17:11:25 -06:00
d4fix.c Additional DAP4 fixes 2023-01-18 19:47:29 -07:00
d4http.c Cleanup DAP4 testing 2022-11-13 13:15:11 -07:00
d4http.h Updated copyright stanza in libdap4 2018-12-06 14:24:28 -07:00
d4includes.h Improve UTF8 Support On Windows 2022-02-08 20:53:30 -07:00
d4mem.c Updated copyright stanza in libdap4 2018-12-06 14:24:28 -07:00
d4meta.c Cleanup DAP4 testing 2022-11-13 13:15:11 -07:00
d4odom.c Spelling fixes 2019-09-18 08:03:01 -06:00
d4odom.h Updated copyright stanza in libdap4 2018-12-06 14:24:28 -07:00
d4parser.c Merge branch 'master' into dap4tests2.dmh 2023-03-02 20:00:05 -07:00
d4printer.c Updated copyright stanza in libdap4 2018-12-06 14:24:28 -07:00
d4read.c Improve operation of the DAP4 code and fix bugs 2021-05-21 20:46:56 -06:00
d4read.h Improve operation of the DAP4 code and fix bugs 2021-01-14 21:39:08 -07:00
d4swap.c Additional DAP4 fixes 2023-01-18 19:47:29 -07:00
d4util.c Fix DAP4 remotetest server 2022-11-15 20:29:21 -07:00
d4util.h Fix DAP4 remotetest server 2022-11-15 20:29:21 -07:00
d4varx.c Additional DAP4 fixes 2023-01-18 19:47:29 -07:00
Makefile.am Allow optional use of libxml2 2021-11-01 22:37:05 -06:00
ncd4.h Improve performance of the nc_reclaim_data and nc_copy_data functions. 2023-05-20 17:11:25 -06:00
ncd4dispatch.c Additional DAP4 fixes 2023-01-18 19:47:29 -07:00
ncd4dispatch.h removed NC from open in dispatch table 2019-08-01 14:30:20 -06:00
ncd4types.h Additional DAP4 fixes 2023-01-18 19:47:29 -07:00