Giter Site home page Giter Site logo

aetlib's Introduction

AET Lib

AET Lib is a C++ implementation for the Cache Model AET and its extension Extended-AET,EAET, which uses Average Eviction Time as a measurement of data item movement in LRU cache, both hardware cache and in-memory key-value cache.

How to install it

It is very easy to compile and install the AET Lib in different platforms (Linux, MacOS, SunOS).

git clone [email protected]:PanCheng111/AETLib.git
cd AETLib
make && make install

Then you can use AET model in your C++ code directly.

How to use it

The are several steps in using AET to generate Miss Ratio Curve (MRC) and Write Back Curve (WBC) after the #include "aet.h". We will illustrate some APIs in following parts.

specific models in AET Lib

We firstly define three models for different scenarios:

#define MODEL0 0    // direct access, ignoring READ / WRITE, uniform data size
#define MODEL1 1    // access concerning READ / WRITE, uniform data size
#define MODEL2 2    // access concerning READ / WRITE / UPDATE / DELETE, non-uniform data size

And also we use an option structure to specify the configuration:

typedef struct Options {
    size_t block_size;
    int model;
} Options;

Here, when we set option.model to MODEL0 and MODEL1, we need to set block_size to a fixed number (in bytes), e.g cache line size, 64, to represent the uniform access data size. In MODEL2, we can simply set block_size = 0 since it won't used in the following part.

init monitor

From the very beginning, we need to initialize the data structure for the monitor and prepare to record the trace from the AET user. Options *option induces configuration options for the AET monitor.

void aetInitMonitor(Options *option);

feed the trace into monitor

We have two different APIs to feed the trace into monitor:

  • Uniform Data Access
  • Non-uniform Data Access
/**
 * Access uniform data size. (like hardware cache, 64B).
 * size_t addr:     hashed key, if the key is not a number; otherwise you can directly use the addr.
 * bool isWrite:    true for write, false for read.
 */ 
void aetAccessUniform(size_t addr, bool isWrite);

/**
 * Access non-uniform data size. (like KV-cache, Redis, Memcached).
 * size_t addr:     hashed key, if the key is not a number; otherwise you can directly use the addr.
 * size_t oriSize:  the original data size of the key-value.
 * size_t curSize:  the current data size of the key-value. 
 * bool isWrite:    true for write, false for read.
 */ 
void aetAccessNonUniform(size_t addr, size_t oriSize, size_t curSize, bool isWrite);

generate Miss Ratio Curve (MRC) from monitor

/**
 * Calculate the Miss Ratio Curve (MRC) in the monitor.
 * size_t tot_mem:      the maximum memory (in bytes) in MRC.
 * size_t granularity:  the granularity of the MRC.
 * double *mrc:         results (MRC) stored in it.
 */ 
void aetCalculateMRC(size_t tot_mem, size_t granularity, double *mrc);

generate Write Back Curve (WBC) from monitor

/**
 * Calculate the Write Back Curve (WBC) in the monitor.
 * size_t tot_mem:      the maximum memory (in bytes) in WBC.
 * size_t granularity:  the granularity of the WBC.
 * double *wbc:         results (WBC) stored in it.
 */ 
void aetCalculateWBC(size_t tot_mem, size_t granularity, double *wbc);

clear up & free the monitor

We can clear up the data in the monitor using this API, which means we can start a fresh new monitoring:

/**
 * Clear the data in the monitor.
 */
void aetClearMonitor();

And also, in the last, remember to free the data structures in the AET monitor, in order to avoid memory leaking.

/**
 * Free the monitor entirely.
 */ 
void aetFreeMonitor();

aetlib's People

Contributors

pancheng111 avatar

Stargazers

Ziyue Qiu avatar

Watchers

James Cloos avatar  avatar

Forkers

blitheyu ziyueqiu

aetlib's Issues

an overflow problem

void rthCalcMRC(rthRec *rth, size_t tot_memory, size_t PGAP) {
    ...
    rth->mrc[(int)(c / PGAP)] = miss_ratio; <<< remove it
    rth->mrc[(size_t)(c / PGAP)] = miss_ratio; <<< 1) into this
    rth->mrc[(c / PGAP)] = miss_ratio; <<< or 2) into this
}

double free() problem

I suggest add a line here or face seg fault.

void aetCalculateMRC(size_t tot_mem, size_t granularity, double *mrc) {
    rthCalcMRC(rth_rec, tot_mem, granularity);
    memcpy(mrc, rth_rec->mrc, sizeof(double) * (tot_mem / granularity + 1));
    if (rth_rec->mrc != NULL) free(rth_rec->mrc);
    rth_rec->mrc = NULL; <<<<<<< add this line <<<<<<<
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.