Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Threading in CCF #774

Closed
ashamis opened this issue Feb 2, 2020 · 7 comments · Fixed by #831, #838 or #940
Closed

Threading in CCF #774

ashamis opened this issue Feb 2, 2020 · 7 comments · Fixed by #831, #838 or #940

Comments

@ashamis
Copy link
Contributor

ashamis commented Feb 2, 2020

No description provided.

@ashamis
Copy link
Contributor Author

ashamis commented Feb 13, 2020

This was not meant to be closed, re-opening

@ashamis ashamis reopened this Feb 13, 2020
@ashamis ashamis linked a pull request Feb 13, 2020 that will close this issue
@douglasism
Copy link

douglasism commented Feb 17, 2020

@ashamis Hi Alex, does this ticket and the linked issues represent all known multi-thread concurrency problems in CCF? That is, if I find a potential concurrency bug in a module not listed should I submit bugs?

@ashamis
Copy link
Contributor Author

ashamis commented Feb 18, 2020

Hi @douglasism, this is still work in progress so I am fixing bugs as a I find them. If you find any concurrency bugs I would really appreciate any bug reports or PRs.

@douglasism
Copy link

douglasism commented Feb 18, 2020

@ashamis I've been reviewing KV. Cogent concurrency in KV is going to be challenging. Even once the current approach is completed (#855, and another one I'm working on), I'm not sure what statements one will be able to make about its soundness. More broadly, what are the multi-threading design goals in the enclave?

Also, have you looked into how the spinlocks get compiled? Do they actually test before waiting? IOW, are they no-ops if there is only one thread (or no contention) in the enclave?

@douglasism
Copy link

douglasism commented Feb 22, 2020

@ashamis (Alex, please take no offense from my suggestions. You probably know all this, but I feel amiss if I don't speak up when I see a problem.)

For KV, as I noted in CCF chat, there may be deadlock risk, given that there are multiple locks with unclear ordering.

Also, consider ways to get rid of this pattern:

    void rollback(Version v) override
    {
      // This is called to roll the store back to the state it was in
      // at the specified version.
      // No transactions can be prepared or committed during rollback.
      std::lock_guard<SpinLock> mguard(maps_lock);
...
      for (auto& map : maps)
        map.second->lock();

      for (auto& map : maps)
        map.second->rollback(v);

      for (auto& map : maps)
        map.second->unlock();
...

Would it be possible to push the map lock into the map::rollback() func, making it RAII? That way, if an exception is thrown, the locks will get released automatically, and it will clean up this code.

@ashamis
Copy link
Contributor Author

ashamis commented Feb 22, 2020

@ashamis I've been reviewing KV. Cogent concurrency in KV is going to be challenging. Even once the current approach is completed (#855, and another one I'm working on), I'm not sure what statements one will be able to make about its soundness. More broadly, what are the multi-threading design goals in the enclave?

Also, have you looked into how the spinlocks get compiled? Do they actually test before waiting? IOW, are they no-ops if there is only one thread (or no contention) in the enclave?

@douglasism - The goal is to improve the throughput and reduce the latency of commands sent to CCF. Additionally, we want to isolate critical operations (such as Raft keep-alive messages) from command execution.

To generalize a bit the spinlocks we use wait on a variable that is updated with a CAS operation. At this time there is no special code in the single threaded case to reduce/avoid this cost. We may do something about this in the future but it will be prioritized against other performance issues.

This was referenced Feb 26, 2020
@ashamis ashamis linked a pull request Mar 11, 2020 that will close this issue
@ashamis
Copy link
Contributor Author

ashamis commented Apr 1, 2020

The bulk of this work is complete! If there are any other that pop-up they can be tracked individually.

@ashamis ashamis closed this as completed Apr 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants