any comments about a cache design?

This is a discussion on any comments about a cache design? within the C Programming forums, part of the General Programming Boards category; -------------------------------------------------------------------------------- Hello everyone, I am going to design a Cache in C/C++ (memory cache). I have two different approaches to ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    any comments about a cache design?

    --------------------------------------------------------------------------------

    Hello everyone,


    I am going to design a Cache in C/C++ (memory cache). I have two different approaches to design/implement it, any comments will be appreciated.

    Design 1, using a map (hashtable) to store key --> object pointer relationship (simple and straight forward);

    Design 2, store real object or object pointer in a stack/linked list/queue/array as an internal storage data structure, then using a map (hashtable) as an external interface to mapping key --> index in the stack/linked list/queue/array; (in this design, when accessing an object, we need two times mapping, first mapping key to index in the stack/linked list/queue/array, then using the index to access the real object)

    I am wondering any advantages or disadvantages of the two designs. Any better design approach suggestion will be appreciated.


    thanks in advance,
    George

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,175
    What are you going to be storing in this cache? Is it a malloc() wrapper for something specific?
    If you understand what you're doing, you're not learning anything.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,821
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Thank you itsme86,


    Quote Originally Posted by itsme86
    What are you going to be storing in this cache? Is it a malloc() wrapper for something specific?
    It is customer structure from malloc or something. Any comments about the two designs?


    regards,
    George

  5. #5
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Any advertisements ... Any useful stuff to recommend?


    regards,
    George

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,821
    > Any useful stuff to recommend?
    None at all.

    Try stuff out and work out which is best for you.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Dump Truck Internet valis's Avatar
    Join Date
    Jul 2005
    Posts
    357
    How modern x86 processors cache your app's memory is too unpredictable to make a judgement about which is going to be better.
    The big advantage to having your objects in a stack/queue is that you'll have your objects stored sequentially which can be a big benefit if you're using an architecture such as the cell.

    Repeating what salem said, just run some tests and see which performs better; you should never go strictly by theoretical values.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. need help with cache simulator!
    By dtogers123 in forum C Programming
    Replies: 3
    Last Post: 04-30-2008, 07:18 PM
  2. Resource manager tree
    By VirtualAce in forum Game Programming
    Replies: 23
    Last Post: 09-07-2007, 11:27 PM
  3. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 02:30 PM
  4. cache miss/hit
    By xddxogm3 in forum C++ Programming
    Replies: 3
    Last Post: 05-07-2007, 07:51 PM
  5. The Art of Writing Comments :: Software Engineering
    By kuphryn in forum C++ Programming
    Replies: 15
    Last Post: 11-23-2002, 05:18 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21