C++ concurrent data structure for fast retrieval

Discussion in 'App Development' started by kmiklas, Sep 2, 2020.

  1. Girija

    Girija

    a structure with say name, price, hash and lock (other items to suit your need). You will need a hash to search the structure otherwise it will become a linear search. A lock maintained with a compare and swap so only one updater writes to it. If you maintain it in memory you will also need a mechanism to rebuild in the event of a crash.
     
    #21     Sep 2, 2020
  2. thecoder

    thecoder

    Depends on the data. If each data record is long, then it can indeed be necessary to update parts of it in parallel by multiple threads. But normally one should avoid that.
    And on a standard SMT2-core 2 HW-threads can run in parallel, but one can run much more (even hundreds) of SW-threads on the same core.
    One would better work with job queues, ie. producer/consumer stuff, with many worker threads...
     
    Last edited: Sep 2, 2020
    #22     Sep 2, 2020
  3. ph1l

    ph1l

    #23     Sep 2, 2020
  4. kmiklas

    kmiklas

    What data structure to hold the orders?
     
    #24     Sep 3, 2020
  5. Girija

    Girija

    Really, h/w thread and s/w thread?.
     
    #25     Sep 3, 2020
  6. KDB

    GAT
     
    #26     Sep 3, 2020
  7. thecoder

    thecoder

    Traversable container(s), ie. vector and/or set of own classes, plus a hash-like key-mechanism for fast direct access, or an index for similar purpose (though with set and correctly defined key part this is not necessary as it's implicitly given in set as it uses internally a btree-like mechanism, called red-black-tree or something that, it's implementation dependent, but usually with B*tree functionality for fast finding...)...
    And: one can always improve with an own cache mechanism, should it be necessary.
    But you need to create an internal API first, for all the running threads (and for processes, in case that is really a requirement)...
     
    Last edited: Sep 3, 2020
    #27     Sep 3, 2020
    kmiklas likes this.
  8. thecoder

    thecoder

    What exactly don't you understand?
    User should just use SW-threads, the language internally will manage how to do this with and on the available HW-threads on the CPU-cores.
    Remember: this (ie. OPs requirement) is normal application programming, not system programming.
     
    Last edited: Sep 3, 2020
    #28     Sep 3, 2020
  9. SteveH

    SteveH

    GAT, have you been following Whitney's latest project, Shakti?

    https://shakti.com/

    There's also a Shakti Google Group:

    https://groups.google.com/g/shaktidb?pli=1

    Really interesting stuff. Allows use of CUDA too.

    For a higher level language though, Clojure seems like an easier fit than C++ for the OP's task. All that concurrent worry nonsense goes away. But I get it. He's married to C++ so has to come up with a C++ solution. Good luck!
     
    Last edited: Sep 3, 2020
    #29     Sep 3, 2020
    globalarbtrader likes this.
  10. MGB

    MGB

    NxCore
     
    #30     Sep 4, 2020