Showing entries tagged [ar-5]

Proof New Default Chunk Cache in 4.1 Improves Performance

A last minute change before the 4.1 release ensures that this common case will get good performance.

There is a terrible performance hit if your chunk cache is too small to hold even one chunk, and your data are deflated.

Since the default HDF5 chunk cache size is 1 MB, this is not hard to do.

So I have added code such that, when a file is opened, if the data are compressed, and if the chunksize is greater than the default chunk cache size for that var, then the chunk cache is increased to a multiple of the chunk size.

The code looks like this:

/* Is this a deflated variable with a chunksize greater than the                                                                                               
* current cache size? */
if (!var->contiguous && var->deflate)
{
   chunk_size_bytes = 1;
   for (d = 0; d < var->ndims; d++)
     chunk_size_bytes *= var->chunksizes[d];
   if (var->type_info->size)
     chunk_size_bytes *= var->type_info->size;
   else
     chunk_size_bytes *= sizeof(char *);
#define NC_DEFAULT_NUM_CHUNKS_IN_CACHE 10
#define NC_DEFAULT_MAX_CHUNK_CACHE 67108864
   if (chunk_size_bytes > var->chunk_cache_size)
   {
     var->chunk_cache_size = chunk_size_bytes * NC_DEFAULT_NUM_CHUNKS_IN_CACHE;
     if (var->chunk_cache_size > NC_DEFAULT_MAX_CHUNK_CACHE)
        var->chunk_cache_size = NC_DEFAULT_MAX_CHUNK_CACHE;
     if ((retval = nc4_reopen_dataset(grp, var)))
        return retval;
   }
}

I am setting the chunk cache to 10 times the chunk size, up to 64 MB max. Reasonable? Comments are welcome.

The timing results show a clear difference. First, two runs without any per-variable caching, but the second run sets a 64MB file level chunk
cache that speeds up timing considerably. (The last number in the row is the average read time for a horizontal layer, in miro-seconds.)

bash-3.2$ ./tst_ar4_3d  pr_A1_z1_256_128_256.nc 
256     128     256     1.0             1       0           836327       850607

bash-3.2$ ./tst_ar4_3d -c 68000000 pr_A1_z1_256_128_256.nc
256     128     256     64.8            1       0           833453       3562

Without the cache it is over 200 times slower.

Now I have turned on automatic variable caches when appropriate:

bash-3.2$ ./tst_ar4_3d  pr_A1_z1_256_128_256.nc 
256     128     256     1.0             1       0           831470       3568

In this run, although no file level cache was turned on, I got the same response time. That's because when opening the file the netCDF library noticed that this deflated var had a chunk size bigger than the default cache size, and opened a bigger cache.

All of this work is in support of the general netCDF user writing very large files, and specifically in support of the AR-5 effort.

The only downside is that, if you open up a file with many such variables, and you have very little memory on your machine, you will run out of memory.

NetCDF-4 AR-4 Performance Data With One Time Series

Another concern that Russ and Dennis and I had was that by taking 5 time series, we were involving the cache too much. Might the data not be already pre-loaded after the first time series is retrieved?

So in this run I do one one time series read. This is all on the 3D precip flux data that Gary gave us.

cs[0] cs[1] cs[2] cache(MB) deflate shuffle read_hor(us) read_time_ser(us)
0     0     0     0       0       0       247          5073
256   64    128   4        0       0       238          2162
256   64    128   32        0       0       172          47050
256   64    128   128       0       0       165          42516
256   64    256  4         0       0       89           2061
256   64    256   32        0       0       136          83352
256   64    256   128       0       0       112          80282
256   128   128   4         0       0       217          2119
256   128   128   32        0       0       153          83400
256   128   128   128       0       0       128          80055
256   128  256   4         0       0       78           2250
256   128  256   32        0       0       188          188474
256   128   256   128       0       0       133          177679
1024  64    128   4         0       0       230          1952
1024  64    128   32        0       0       108690       52045
1024  64    128   128       0       0       216          49018
1024  64    256   4         0       0       88           2100
1024  64    256   32        0       0       87           1964
1024  64    256   128       0       0       175          95524
1024  128   128   4         0       0       218          2064
1024  128   128   32        0       0       218          1991
1024 128   128   128       0       0       194          95595
1024  128   256   4         0       0       76           2128
1024  128   256   32        0       0       76           2041
1024  128   256   128       0       0       198          197824
1560  64    128   4         0       0       229          1973
1560  64    128   32        0       0       229          1915
1560  64    128   128       0       0       161078       37119
1560  64    256   4         0       0       87           2178
1560  64    256   32        0       0       87           2105
1560  64    256   128       0       0       160058       72695
1560  128   128   4         0       0       214          2048
1560  128   128   32        0       0       213          1980
1560  128   128   128       0       0       159984       73765
1560  128   256   4         0       0       78           2284
1560  128   256   32        0       0       76           1954
1560  128   256   128       0       0       76           1947

Sorry about the alignment of the columns, but they show up fine for me in emacs. Obviously this fancy web technology is only a few years away from doing what emacs could do in 1981...

NetCDF-4 AR-4 Performance Data With Horizonatal and Time Series Reversed

Russ, Dennis and I discussed some of the chunking results yesterday. We were concerned that the horizontal reads were causing all the data to be preloaded into cache for the subsequent time series read. So I swapped the order - now the time series read is done first.

Here's some results. The first line are the results for reading a classic netCDF file.

cs[0] cs[1] cs[2] cache(MB) deflate shuffle read_hor(us)  read_time_ser(us)
0     0     0     0         0      0        247           5908
256   64    128   4         0      0        241           2039
256   64    128   32        0      0        168           31384
256   64    128   128       0      0        140           17096
256   64    256   4         0      0        93            2548
256   64    256   32        0      0        136           55722
256   64    256   128       0      0        106           26892
256   128   128   4         0      0        216           2035
256   128   128   32        0      0        152           55488
256   128   128   128       0      0        121           26698
256   128   256   4         0      0        79            2392
256   128   256   32        0      0        188           191120
256   128   256   128       0      0        136           186396
1024  64    128   4         0      0        236           1945
1024  64    128   32        0      0        108356        53812
1024  64    128   128       0      0        220           19551
1024  64    256   4         0      0        89            1930
1024  64    256   32        0      0        89            1864
1024  64    256   128       0      0        209           40942
1024  128   128   4         0      0        222           2065
1024  128   128   32        0      0        220           1833
1024  128   128   128       0      0        227           41183
1024  128   256   4         0      0        77            1894
1024  128   256   32        0      0        76            1839
1024  128   256   128       0      0        199           207533
1560  64    128   4         0      0        234           1885
1560  64    128   32        0      0        233           1850
1560  64    128   128       0      0        161596        14921
1560  64    256   4         0      0        88            1969
1560  64    256   32        0      0        87            1929
1560  64    256   128       0      0        160939        30848
1560  128   128   4         0      0        218           1924
1560  128   128   32        0      0        218           1875
1560  128   128   128       0      0        161316        30876
1560  128   256   4         0      0        77            1857
1560  128   256   32        0      0        76            1797
1560  128   256   128       0      0        76            1796

Again, there are many chunk size selections which beat the classic netCDF file performance.

Even More Performance Data for NetCDF-4 On AR-4 File

Here's a set of benchmarking results to ponder:

cs[0]  cs[1]  cs[2]  cache(MB)  deflate  shuffle  read_hor(us) read_time_ser(us)
0    0    0    0        0    0        246         3908
1     16     32    4        0     0        678        158842
1     16    32    32       0     0        703         60649
1     16     32    128        0    0        704         60073
1    16     128    4       0     0        233        50186
1     16     128    32         0    0        253         121418
1     16    128    128        0    0        251        23324
1    16    256    4        0    0        151         40377
1     16     256    32         0    0        167         106875
1     16     256    128        0    0        184        22115
1     64     32    4        0    0        269         49471
1     64    32    32         0    0        286         86265
1     64    32    128        0    0        285         22933
1    64     128    4         0    0        144        39626
1     64     128    32        0     0        158         93995
1    64     128    128        0    0        176        19252
1     64    256    4         0    0        125         59562
1     64    256    32         0    0        127         89096
1     64     256    128        0    0        141        38744
1     128    32    4         0    0        217         45392
1     128    32     32        0     0        224        110270
1     128    32     128        0    0        239         24357
1    128    128    4        0     0        130         55016
1     128    128    32        0    0        137        84879
1    128    128    128        0     0        150         37176
1     128    256    4        0    0        102        82356
1     128    256    32        0     0        108         101119
1    128    256    128        0    0        120         143347
10     16    32     4        0     0        560        3862
10     16    32    32        0    0        574         3023
10    16    32    128        0     0        596        2165
10     16    128    4        0    0        211         6783
10    16    128    32        0     0        222       7965
10     16    128    128        0    0        235         3805
10    16    256    4        0     0        135        9760
10     16    256    32        0    0        148         11471
10     16    256    128        0     0        157         6161
10    64    32     4        0     0        241        6165
10     64    32     32         0    0        250         7304
10     64    32     128        0     0        263        3517
10    64    128    4        0     0        135         18767
10     64    128    32        0     0        145         21202
10    64    128    128        0     0        155        5397
10     64    256    4        0     0        102         31856
10    64    256    32         0     0        110        34256
10     64    256    128        0     0        120         11744
10     128   32     4        0     0        186         9587
10     128   32     32        0     0        198        11277
10     128   32     128        0     0        208         5963
10    128   128    4         0     0        118        31822
10     128   128    32         0    0        127         34339
10     128   128    128        0     0        137         11778
10     128   256    4         0     0        95          66583
10     128   256    32        0     0        101         65303
10    128   256    128        0     0        116        61578
256     16    32     4        0     0        10728        1370
256     16    32     32        0     0        555         1350
256     16    32     128        0     0        566        765
256    16    128    4        0     0        10924        4929
256    16    128    32        0    0        228        5459
256     16    128    128        0     0        247         3526
256     16    256    4        0     0        11189        9961
256     16    256    32        0     0        154        9276
256    16    256    128        0     0        159        5912
256    64    32     4        0     0        10965        4973
256     64    32     32        0     0        263         4827
256     64    32    128        0     0        267        2684
256     64    128    4         0     0        225         1637
256    64    128    32        0     0        163        19207
256    64    128    128        0     0        160         4680
256     64    256    4         0     0        83        1602
256     64    256    32         0     0        139       35278
256     64    256    128        0     0        134         12680
256    128   32     4        0     0        11319        9963
256    128   32     32        0     0        208        9266
256     128   32    128        0     0        212         5892
256     128   128    4         0     0        216        1693
256     128   128    32        0     0        155         35481
256    128   128    128        0     0        148        12731
256    128   256    4         0     0        69         1598
256     128   256    32         0     0        164        160629
256     128   256    128        0     0        155         154782
1024    16   32     4        0     0        42966        1616
1024    16    32     32         0     0        40867        1431
1024    16    32     128        0     0        565        973
1024    16    128    4         0     0        302         1622
1024    16    128    32         0     0        49018        6434
1024    16    128    128        0     0        256        4686
1024    16    256    4         0     0        120         1452
1024    16    256    32         0     0        38800        10148
1024    16    256    128        0     0        169        9740
1024    64    32     4        0     0        681         1463
1024    64    32     32         0     0        40196        5385
1024    64    32    128        0     0        274        4271
1024    64    128    4        0    0        231        1599
1024    64    128    32        0     0        92258        46865
1024    64    128    128        0    0        204         13802
1024    64    256    4         0     0        81        1541
1024    64    256    32         0    0        79         1531
1024    64    256    128        0     0        178        35534
1024    128   32     4        0    0        641        1580
1024    128   32     32         0     0        39225        10224
1024    128   32     128        0    0        223         9788
1024    128   128    4        0     0        221        1622
1024    128   128    32        0    0        221         1613
1024    128   128    128        0     0        194        35413
1024    128   256    4         0    0        68         1574
1024    128   256    32         0     0        68         1562
1024    128   256    128        0     0        169        178748
1560    16   32     4        0     0        64666        1225
1560    16    32     32         0     0        62167        995
1560    16    32     128        0     0        59672        610
1560    16    128    4        0     0        300        1491
1560    16    128    32        0     0        59760        4155
1560    16    128    128        0     0        58138        2532
1560    16    256    4         0     0        128         1631
1560    16    256    32         0    0        74452        9566
1560    16    256    128        0     0        77289        8045
1560    64    32     4        0     0        695         1570
1560    64    32     32         0     0        74121        4917
1560    64    32     128        0     0        78406        3328
1560    64    128    4        0     0        228         1657
1560    64    128    32        0     0        227         1655
1560    64    128    128        0    0        158447       8447
1560    64    256    4         0     0        96         1721
1560    64    256    32        0    0        96         1726
1560    64    256    128        0     0        157660       31986
1560    128   32     4         0    0        637         1621
1560    128   32     32         0     0        75336        9685
1560    128   32     128        0    0        77909        8133
1560    128   128    4         0     0        221        1827
1560    128   128    32        0     0        219        1814
1560    128   128    128        0     0        157832       32289
1560    128   256    4         0     0        76        1754
1560    128   256    32         0    0        75        1751
1560    128   256    128        0    0        76        1750

Netcdf-4 Chunking Performance Results on AR-4 3D Data File

Some results from AR-5 performance evaluation

As part of analyzing netcdf-4 performance for the upcoming AR-5 climate data archive, I have been running benchmarks on some AR-4 (3D precip flux) data that I got from Gary Strand (thanks Gary!) pr_A1.20C3M_8.CCSM.atmm.1870-01_cat_1999-12.nc.

Here's what's in the file:

 netcdf pr_A1.20C3M_8.CCSM.atmm.1870-01_cat_1999-12
 {                                                                                                          
  dimensions:                                                                                                                                                      
          lon = 256 ;                                                                                                                                              
          lat = 128 ;                                                                                                                                              
          bnds = 2 ;                                                                                                                                               
          time = UNLIMITED ; // (1560 currently)                                                                                                                   
  variables:                                                                                                                                                       
          double lon_bnds(lon, bnds) ;                                                                                                                             
          double lat_bnds(lat, bnds) ;                                                                                                                             
          double time_bnds(time, bnds) ;                                                                                                                           
          double time(time) ;                                                                                                                                      
                  time:calendar = "noleap" ;                                                                                                                       
                  time:standard_name = "time" ;                                                                                                                    
                  time:axis = "T" ;                                                                                                                                
                  time:units = "days since 0000-1-1" ;                                                                                                             
                  time:bounds = "time_bnds" ;                                                                                                                      
                  time:long_name = "time" ;                                                                                                                        
          double lat(lat) ;                                                                                                                                        
                  lat:axis = "Y" ;                                                                                                                                 
                  lat:standard_name = "latitude" ;                                                                                                                 
                  lat:bounds = "lat_bnds" ;                                                                                                                        
                  lat:long_name = "latitude" ;                                                                                                                     
                  lat:units = "degrees_north" ;                                                                                                                    
          double lon(lon) ;                                                                                                                                        
                  lon:axis = "X" ;                                                                                                                                 
                  lon:standard_name = "longitude" ;                                                                                                                
                  lon:bounds = "lon_bnds" ;                                                                                                                        
                  lon:long_name = "longitude" ;                                                                                                                    
                  lon:units = "degrees_east" ;                                                                                                                     
          float pr(time, lat, lon) ;                                                                                                                               
                  pr:comment = "Created using NCL code CCSM_atmm_2cf.ncl on\n",                                                                                    
                          " machine mineral" ;                                                                                                                     
                  pr:missing_value = 1.e+20f ;                                                                                                                     
                  pr:_FillValue = 1.e+20f ;                                                                                                                        
                  pr:cell_methods = "time: mean (interval: 1 month)" ;                                                                                             
                  pr:history = "(PRECC+PRECL)*r[h2o]" ;                                                                                                            
                  pr:original_units = "m-1 s-1" ;                                                                                                                  
                  pr:original_name = "PRECC, PRECL" ;                                                                                                              
                  pr:standard_name = "precipitation_flux" ;                                                                                                        
                  pr:units = "kg m-2 s-1" ;                                                                                                                        
                  pr:long_name = "precipitation_flux" ;                                                                                                            
                  pr:cell_method = "time: mean" ;          

And here are the first results of putting this data in different sets of chunksizes, with no compression. The first I read all horizontal slabs in the file, then 5 time series. The times show the time to read each slab, and the time to read each time series, in microseconds.

cs[0]   cs[1]   cs[2]   cache(MB) deflate shuffle read_hor(us) read_time_ser(us)
0       0       0       0         0       0       240          3822
1       16      32      1         0       0       667          57087
1       16      128     1         0       0       245          23929
1       16      256     1         0       0       160          26913
1       64      32      1         0       0       277          22840
1       64      128     1         0       0       147          41359
1       64      256     1         0       0       110          47856
1       128     32      1         0       0       205          25052
1       128     128     1         0       0       123          47417
1       128     256     1         0       0       97           68877
10      16      32      1         0       0       552          3284
10      16      128     1         0       0       204          5834
10      16      256     1         0       0       138          8465
10      64      32      1         0       0       233          5268
10      64      128     1         0       0       132          16690
10      64      256     1         0       0       99           28037
10      128     32      1         0       0       180          8414
10      128     128     1         0       0       113          28064
10      128     256     1         0       0       90           54715
256     16      32      1         0       0       8853         1167
256     16      128     1         0       0       8012         3677
256     16      256     1         0       0       118          1581
256     64      32      1         0       0       8170         3737
256     64      128     1         0       0       227          1640
256     64      256     1         0       0       80           1627
256     128     32      1         0       0       645          1624
256     128     128     1         0       0       211          1650
256     128     256     1         0       0       68           1667
1024    16      32      1         0       0       32337        1192
1024    16      128     1         0       0       296          1489
1024    16      256     1         0       0       114          1564
1024    64      32      1         0       0       679          1415
1024    64      128     1         0       0       221          1503
1024    64      256     1         0       0       79           1669
1024    128     32      1         0       0       646          1558
1024    128     128     1         0       0       208          1568
1024    128     256     1         0       0       68           1646
1560    16      32      1         0       0       55064        1055
1560    16      128     1         0       0       298          1438
1560    16      256     1         0       0       115          1477
1560    64      32      1         0       0       685          1425
1560    64      128     1         0       0       225          1545
1560    64      256     1         0       0       79           1589
1560    128     32      1         0       0       658          1535
1560    128     128     1         0       0       208          1567
1560    128     256     1         0       0       68           1544

The first line shows the read times for the classic netcdf file.

I am happy to see there are a number of cases that clearly outperform classic netcdf. The trick is to come up with some algorithm that comes up with the correct answers without the user being involved.

Unidata Developer's Blog
A weblog about software development by Unidata developers*
Unidata Developer's Blog
A weblog about software development by Unidata developers*

Welcome

FAQs

News@Unidata blog

Take a poll!

What if we had an ongoing user poll in here?

Browse By Topic
Browse by Topic
« March 2024
SunMonTueWedThuFriSat
     
1
2
3
5
6
7
8
9
10
11
12
13
14
15
16
17
19
20
21
22
23
24
25
26
27
28
29
30
31
      
Today