Rate This Document
Findability
Accuracy
Completeness
Readability

DAS Interfaces

Interface Description

DAS smart prefetch interfaces.

Interface Format

  • int32_t Rcache_CeateDasModule(DasModuleParam *createInstanceParam);

    void Rcache_ExitDasModule(void);

  • int32_t Rcache_PutDasInfo(DasKvParam *params);

Parameters

Parameter

Type

Description

Input/Output

createInstanceParam

Pointer to the structure of the callbacks registered by the user

Callbacks to be registered by the user.

Input

params

Pointer to the structure of the I/O information submitted by the user

The user submits I/O information to the smart prefetch interfaces.

Input

ret

Integer

If the interface is successfully invoked, 0 is returned. Otherwise, an error code is returned.

Output

Data Structures

struct DasOPS

Member

Type

Description

SubmitDasPrefetch

Function pointer

Submits prefetch I/Os.

logFunc

Function pointer

Prints DAS internal logs.

struct DasModuleParam

Member

Type

Description

ops

struct DasOPS structure pointer

Callbacks registered by the user.

logger

Pointer

Log module object of the user.

cacheLineSize

Integer

Cache line size.

struct DasKvParam

Member

Type

Description

offset

Integer

Start position of the I/O to be prefetched, in bytes.

len

Integer

Length of the I/O to be prefetched, in bytes.

timeStamp

Integer

I/O timestamp, in nanoseconds.

lunID

Integer

Logical unit ID of the I/O.

Dependency

ksal/das.h

Example

  1. Write DAS test code.
    1. Create a test.cpp file.
      vi test.cpp
    2. Press i to enter the insert mode and add the following test code to the file:
      #include <cstdio>
      #include <vector>
      #include <ksal/das.h>
      
      std::vector<DasKvParam> prefetchInfoLists;
      
      void das_req_prefetch(DasKvParam *params){
          DasKvParam prefetchInfo = {params->offset, params->len, params->timeStamp, params->lunID};
          prefetchInfoLists.push_back(prefetchInfo);
      }
      
      void ProducerTask(const uint32_t ioNum)
      {
          bool readyToExit = false;
          int32_t ret = 0;
          uint32_t counter = 0;
      
          for (uint32_t i = 0; i < ioNum; i++){
              DasKvParam params;
              params.offset = 4096 * i;
              params.len = 4096;
              params.timeStamp = 0 + i * 10000000;
              params.lunID = 1;
      
              ret = Rcache_PutDasInfo(&params);
          }
      }
      
      int main(int argc, char **argv)
      {
          DasModuleParam *dasInstanceParam = new DasModuleParam();
          dasInstanceParam->cacheLineSize = 8192;
          dasInstanceParam->logger = nullptr;
          DasOPS *regOps = new DasOPS();
          regOps->SubmitDasPrefetch = das_req_prefetch;
          regOps->logFunc = nullptr;
          dasInstanceParam->ops = regOps;
          int32_t ret = Rcache_CeateDasModule(dasInstanceParam);
      
          uint32_t ioNum = 10000;
          ProducerTask(ioNum);
      
          for (int i = 0; i < prefetchInfoLists.size(); ++i) {
              printf("prefetchInfo: lunId[%u], offset[%lu], len[%lu]\n", prefetchInfoLists[i].lunID,prefetchInfoLists[i].offset, prefetchInfoLists[i].len);
          }
      
          Rcache_ExitDasModule();
      
          return 0;
      }
    3. Press Esc to exit the insert mode. Type :wq! and press Enter to save and exit the file.
  2. Compile the test.cpp file into an executable file test.
    g++ test.cpp -lpthread -ldas -o test
  3. Run the test executable file.
    ./test
    The command output is as follows:
    config_dasOff: 0
    config_dasMemLimit: 300 MB
    config_prefetchMaxLen: 16 MB
    create DAS module clloector success.
    prefetchInfo: lunId[1], offset[20480], len[65536]
    prefetchInfo: lunId[1], offset[86016], len[65536]
    prefetchInfo: lunId[1], offset[151552], len[65536]
    prefetchInfo: lunId[1], offset[217088], len[65536]
    prefetchInfo: lunId[1], offset[282624], len[65536]
    prefetchInfo: lunId[1], offset[348160], len[65536]
    prefetchInfo: lunId[1], offset[413696], len[65536]
    prefetchInfo: lunId[1], offset[479232], len[65536]
    prefetchInfo: lunId[1], offset[544768], len[65536]
    prefetchInfo: lunId[1], offset[610304], len[65536]
    prefetchInfo: lunId[1], offset[675840], len[65536]
    prefetchInfo: lunId[1], offset[741376], len[65536]
    prefetchInfo: lunId[1], offset[806912], len[73728]
    prefetchInfo: lunId[1], offset[880640], len[73728]
    prefetchInfo: lunId[1], offset[954368], len[81920]
    prefetchInfo: lunId[1], offset[1036288], len[81920]
    prefetchInfo: lunId[1], offset[1118208], len[90112]
    prefetchInfo: lunId[1], offset[1208320], len[90112]
    prefetchInfo: lunId[1], offset[1298432], len[98304]
    prefetchInfo: lunId[1], offset[1396736], len[98304]
    prefetchInfo: lunId[1], offset[1495040], len[106496]
    prefetchInfo: lunId[1], offset[1601536], len[106496]
    prefetchInfo: lunId[1], offset[1708032], len[114688]
    prefetchInfo: lunId[1], offset[1822720], len[114688]
    prefetchInfo: lunId[1], offset[1937408], len[122880]
    prefetchInfo: lunId[1], offset[2060288], len[122880]
    prefetchInfo: lunId[1], offset[2183168], len[131072]
    prefetchInfo: lunId[1], offset[2314240], len[131072]
    prefetchInfo: lunId[1], offset[2445312], len[139264]
    prefetchInfo: lunId[1], offset[2584576], len[139264]
    prefetchInfo: lunId[1], offset[2723840], len[147456]
    prefetchInfo: lunId[1], offset[2871296], len[147456]
    prefetchInfo: lunId[1], offset[3018752], len[155648]
    prefetchInfo: lunId[1], offset[3174400], len[155648]
    prefetchInfo: lunId[1], offset[3330048], len[163840]
    prefetchInfo: lunId[1], offset[3493888], len[163840]
    prefetchInfo: lunId[1], offset[3657728], len[172032]
    prefetchInfo: lunId[1], offset[3829760], len[172032]
    prefetchInfo: lunId[1], offset[4001792], len[180224]
    prefetchInfo: lunId[1], offset[4182016], len[180224]
    prefetchInfo: lunId[1], offset[4362240], len[188416]
    prefetchInfo: lunId[1], offset[4550656], len[360448]
    prefetchInfo: lunId[1], offset[4911104], len[720896]
    prefetchInfo: lunId[1], offset[5632000], len[1441792]
    prefetchInfo: lunId[1], offset[1781760], len[1048576]
    prefetchInfo: lunId[1], offset[2830336], len[1048576]
    prefetchInfo: lunId[1], offset[3878912], len[1048576]
    prefetchInfo: lunId[1], offset[4927488], len[1048576]
    prefetchInfo: lunId[1], offset[5976064], len[1048576]
    das mem used : 316688 Byte
    exit DAS module prefetcher
    exit DAS module collector