Giter Club home page Giter Club logo

Comments (3)

karlseguin avatar karlseguin commented on July 23, 2024 1

There's no special configuration. You could increase the # of buckets to 32 or even 64 and, if you have long TTLs of oft-fetched items (and you're OK with occasionally evicting a recently fetched item), you could increase the GetsPerPromote beyond 3 (which I find already quite high).

ccache.New(ccache.Configure().MaxSize(X).Buckets(64).GetsPerPromote(5))

But you'd have to measure for your use case if those actually make a difference.

ccache has a lot of features (e.g. layered caching and external tracking)...if you just need a key=>value cache, and you're concerned about raw performance, there are probably faster alternatives. e.g. https://github.com/dgraph-io/ristretto

from ccache.

devrodriguez avatar devrodriguez commented on July 23, 2024

Thanks for your answer!!!
I'm increasing PromoteBuffer to 2048, this also contributes to improving the performance? On the other hand, what is the technical explanation for Promote?
Thks dude!!!

from ccache.

karlseguin avatar karlseguin commented on July 23, 2024

Every instance of ccache has 1 worker threads which is responsible for maintaining the cache. This simplifies and minimizes the amount and type of locking that needs to take place.

When you get an item, rather than locking the linked list which tracks recency directly in the goroutine which performed the get, you write the information to a "promotables" channel (i.e.. promote as most recently use) which is consumed by the worker thread. (This linked list isn't under lock, since only the worker thread ever touches it).

A high promote buffer is a good idea. It'll ensure that read operations (e.g., Get) don't block.The current default, 1024, is probably too low given that the tradeoff is just a bit of extra memory. (Also, now that I think of it, I wonder if having 4-8 promotables channels to minimize their contention is a good idea...)

from ccache.

Related Issues (20)

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.