Skip to content

NetCDF slow writes when using the stride parameter. #1877

@agnishd

Description

@agnishd

NetCDF versions in which we have observed this issue:

  • Observed in 4.7.1, 4.6.3, and 4.3.3.1. There is a considerable improvement in 4.7.1 but, strided writes are still slower than just using loops and iteratively writing the same values at the same locations.

Platform information:

  • Tested on Linux lsdbgl28141glnxa64 4.19.0-9-amd64 Netcdf cmake #1 SMP Debian 4.19.118-2+deb10u1 (2020-06-07) x86_64 GNU/Linux

Description of the issue:

  • We have observed slower write speeds when using the "nc_put_vars_double()" function to write to a NetCDF4-classic file using the "stride" feature. I created a standalone file to reproduce the issue and tested it on versions 4.7.3, 4.6.1, and 4.3.3.1 of the NetCDF library. The following are some sample runtimes that I got both by using the stride feature and without it:

ver 4.3.3.1:
Strided: 184514115 microseconds
Looped: 336884 microseconds

ver 4.6.1:
Strided: 175383093 microseconds
Looped: 340540 microseconds

ver 4.7.3:
Strided: 5841009 microseconds
Looped: 370361 microseconds

The code attached writes a 5184 x 228 x 40 matrix to a NetCDF file with dimensions: 5184 x 228 X (unlimited), using the nc_put_vars_double() function of NetCDF by:
a. Using the stride parameter i.e. specifying the stride vector as (1, 1, 5).
b. By looping along the z-axis and iterating the starting points of the writes as (0, 0, i * 5) while keeping the stride vector as (1, 1, 1).
NetCDF_slow_stided_writes-main.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions