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

Multithreaded cryptography #850

Merged
merged 34 commits into from Oct 9, 2019

Conversation

@majestrate
Copy link
Collaborator

commented Oct 1, 2019

this makes most of the cryptography done in worker threads.
includes iwp multiack and public key pinning because separating them would effectively mean rewriting that part so eh why not include it. this DOES break the protocol handshake but we're going to do that anyways.

majestrate and others added 28 commits Sep 3, 2019
this yields more efficient througput. probably.
…ode only)
@majestrate majestrate requested a review from tewinget Oct 1, 2019
@@ -39,7 +39,7 @@ struct DemoCall : public abyss::http::IRPCClientHandler
bool HandleResponse(abyss::http::RPC_Response) override
{
llarp::LogInfo("response get");
m_Logic->queue_func(m_Callback);
m_Logic->queue_func([=]() { m_Callback(); });

This comment has been minimized.

Copy link
@michael-loki

michael-loki Oct 1, 2019

Collaborator

I don't understand what this change achieves?

This comment has been minimized.

Copy link
@neuroscr

neuroscr Oct 2, 2019

Collaborator

storing a snapshot of the scope? I see this type of hack in JS a lot

This comment has been minimized.

Copy link
@majestrate

majestrate Oct 2, 2019

Author Collaborator

js is pass by reference, C++ is pass by value (unless explicitly noted otherwise)

llarp/ev/ev_libuv.hpp Outdated Show resolved Hide resolved
std::bit_xor< size_t >()),
std::bit_xor< size_t >());
}
};

This comment has been minimized.

Copy link
@michael-loki

michael-loki Oct 1, 2019

Collaborator

you could use abseil hashing instead:

template <typename H>
H AbslHashValue(H h, const Path& p) {
    return H::combine(std::move(h), p.hops[0].upstream, p.hops[0].rxID, p.hops[0].txID);
}

(providing the sub-types were also hashable)

@@ -97,7 +109,7 @@ namespace llarp
bool
Logic::can_flush() const
{
return ourID == std::this_thread::get_id();
return id.has_value() && id.value() == std::this_thread::get_id();

This comment has been minimized.

Copy link
@michael-loki

michael-loki Oct 2, 2019

Collaborator

this can just be id == std::this_thread::get_id()

@@ -433,7 +433,8 @@ extern "C"
void
llarp_main_signal(struct llarp_main *ptr, int sig)
{
ptr->ctx->HandleSignal(sig);
ptr->ctx->logic->queue_func(
std::bind(&llarp::Context::HandleSignal, ptr->ctx.get(), sig));

This comment has been minimized.

Copy link
@michael-loki

michael-loki Oct 2, 2019

Collaborator

this is probably clearer as:

ptr->ctx->logic->queue_func([ctx=ptr->ctx.get(),sig]() { ctx->HandleSignal(sig); });

This comment has been minimized.

Copy link
@tewinget

tewinget Oct 2, 2019

Collaborator

for that matter, as long as queue_func takes an r-value reference it could be even cleaner to do:
auto func = <make the lambda>; logic->queue_func(func);
as 2 separate lines, but either way it's a style consideration.

@majestrate majestrate merged commit fb7360c into loki-project:dev Oct 9, 2019
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.