GithubHelp home page GithubHelp logo

tjr_lru_cache's Introduction

Tjr_lru_cache

[TOC]

Description

Tjr_lru_cache is an LRU cache, a component of tjr_kv and ImpFS.

Tjr_kv is a key-value store in OCaml. ImpFS will hopefully be a filesystem for OCaml.

Tjr_kv architecture:

Note on src/

  • in-mem: the basic implementation; maintains a "cache state"; expressed as state-passing functions; requires help to execute a call to the lower layer; API returns result together with a typically-empty list of evictees

  • multithreaded: includes lists of threads blocked on particular keys (multiple reader, single writer);

    The idea is that the first thread that needs to make a "slow" call to disk to execute find(k), first creates a list of waiters, then calls out to disk; on return, the thread activates all waiters before returning; in the meantime, if another thread needs find(k), they discover that the call is in process, and so they suspend themselves after adding themselves to the wait list

Performance testing

In directory test/ there are various test programs. One does exhaustive testing. The other does performance testing. Type make run_performance_test to see the output, which resembles:

find _build -name "test_main.exe" -exec cp \{\} . \;
./test_main.exe -count 10000 -cap 100 -evict 10
count is 10_000 (src/test_performance.ml)
capacity is 100 (src/test_performance.ml)
evict count is 10 (src/test_performance.ml)
Following timings are in nanoseconds
              pqwy functional lru, op=add-and-trim 5_834_736
              pqwy imperative lru, op=add-and-trim 1_178_008
  pqwy imperative lru with batch evict if over cap 1_126_974
            hashtable, with drop when cap exceeded 750_954
            hashtable, with new when exceeding cap 1_515_602
          tjr_lru with automatic evict if over cap 4_611_904

Note that from these timings, the pqwy imperative LRU implementation with batch eviction appears to be extremely good, allowing for around 10M operations per second. [tjr_lru] is using the functional lru, and so is expected to be slower, at around 2M ops/s in this example. FIXME in production, the pqwy imperative version should be used.

Quick links

Dependencies

Dependency Comment
tjr_fs_shared Common library
minicli, containers For testing

tjr_lru_cache's People

Contributors

tomjridge avatar

Watchers

James Cloos avatar  avatar  avatar

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.