Re: [netcdfgroup] strlen calls in NC_finddim and NC_findvar

  • To: "Greg Sjaardema" <gdsjaar@xxxxxxxxxx>
  • Subject: Re: [netcdfgroup] strlen calls in NC_finddim and NC_findvar
  • From: Ed Hartnett <ed@xxxxxxxxxxxxxxxx>
  • Date: Thu, 03 Dec 2009 16:46:12 -0700
"Greg Sjaardema" <gdsjaar@xxxxxxxxxx> writes:

> I have a monstrous file with several thousand dimensions and variables
> which is running slower than it should.  I investigated the runtime
> and found that strlen was the major time user in the NC_finddim and
> NC_findvar calls.  The obvious optimization was to cache the length of
> the name instead of calling strlen each time.  However, when I went to
> do this, I discovered that the length is already cached as the nchars
> field in the NC_string struct.
>
> I did some checks in the code and also added some assertions to the
> code and verified that, as far as I can tell, nchars is the correct
> length of the string.  Is there a reason that it isn't used and
> strlen() is called instead?  Switching the code to use nchars dropped
> my execution time from 20 units to 6 units.  I would like to make the
> switch, but wondered if there was some strange corner case where the
> nchars value is incorrect and will cause problems.
>
> Thanks,
> --Greg
>

Howdy Greg!

Sounds interesting!

Can you send your patch to support-netcdf@xxxxxxxxxxxxxxxx and we can
take a look?

Thanks,

Ed

-- 
Ed Hartnett  -- ed@xxxxxxxxxxxxxxxx



  • 2009 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: