GithubHelp home page GithubHelp logo

yangyang233333 / smallkv Goto Github PK

View Code? Open in Web Editor NEW
98.0 2.0 10.0 17.36 MB

A small Key-Value storage engine written in C++.

License: MIT License

CMake 1.79% C++ 96.95% Shell 0.44% Dockerfile 0.82%
cpp database kv-store

smallkv's Issues

memory/allocate.cpp中Deallocate方法

在memory/allocate.cpp文件中,Deallocate方法最后删除内存块的代码是不是有问题?感觉好像是在添加新的内存块,没有删除释放的操作。
具体代码如下:
void FreeListAllocate::Deallocate(void *p, int32_t n) {
if (p == nullptr || n == 0) {
logger->error("p cannot be nullptr, n cannot be zero. p={}, n={}", p, n);
return;
}

    // 大于MAX_OBJ_SIZE是malloc分配的,也由free回收
    if (n > MAX_OBJ_SIZE) {
        free(p);
        p = nullptr;
        return;
    }


   // 这四行代码感觉好像有问题
    auto slot_index = get_index(n);
    auto node = static_cast<BlockNode *>(p);
    node->next = memory_slot[slot_index];
    memory_slot[slot_index] = node;
}

内存池设计是否多余

LevelDB中的Arena主要是用于MemTable的,看README内的内存池设计看起来是用于Block的,貌似和Block/Table Cache本身的功能产生了一些冲突?Minor Compaction时生成SSTable时的Block除了最后一个以外都是4k(默认一般考虑4k对齐)的吧,看图总感觉有不少浪费在了小Block上

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.