Coder Social home page Coder Social logo

Another LRU crate about lru-rs HOT 4 OPEN

jeromefroe avatar jeromefroe commented on September 26, 2024 2
Another LRU crate

from lru-rs.

Comments (4)

jeromefroe avatar jeromefroe commented on September 26, 2024 1

Hi @marmeladema! It's no bother at all!

I just took a look at your crate, and I think it's a great approach! I'd be happy to add a comment to the README linking to it and explaining the differences between the two. The way I see it, the two crates occupy slightly different positions on the spectrum of performance and usability. clru-rs offers an API closer to HashMap and less unsafe code at the cost of slightly more memory usage because the keys are stored in a vector instead of a linked list, and this crate makes the opposite trade-off. Does that sound about right?

from lru-rs.

marmeladema avatar marmeladema commented on September 26, 2024 1

By the way, I haven't tagged a new release yet, but clru does not pre-allocate unconditionally all the memory anymore.
There is still a constructor available to do so though, for cases (like the ones I have) where it can be known in advance that the cache is going to be full.

from lru-rs.

marmeladema avatar marmeladema commented on September 26, 2024

Thank you for taking the time to look at the code! Really appreciate it!

I'd be happy to add a comment to the README linking to it and explaining the differences between the two.

Wow that would be super nice 👍 Maybe it's a bit too soon though, I'd like some more people to look at it / use it.

at the cost of slightly more memory usage because the keys are stored in a vector instead of a linked list

The keys are moved in a Rc and thus are shallow copy in the linked list. The overhead with this would be similar as if the keys were boxed once. I am not sure there is such a difference in memory usage between the two crates? It would be nice to measure it though! The only thing that I can think of where clru might be more memory hungry would be for non-full cache, because it pre-allocates all nodes ahead of time but then there is not much point in using an LRU cache that is never full.

from lru-rs.

jeromefroe avatar jeromefroe commented on September 26, 2024

Maybe it's a bit too soon though, I'd like some more people to look at it / use it.

Sounds good. We can circle back whenever you feel it's ready!

The only thing that I can think of where clru might be more memory hungry would be for non-full cache, because it pre-allocates all nodes ahead of time but then there is not much point in using an LRU cache that is never full.

That was all I could think of too. And I agree, it certainly seems like the difference would be negligible.

from lru-rs.

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.