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

Private/caolan/async perf #9069

Merged
merged 8 commits into from
May 17, 2024
Merged

Private/caolan/async perf #9069

merged 8 commits into from
May 17, 2024

Conversation

caolanm
Copy link
Contributor

@caolanm caolanm commented May 16, 2024

  • Resolves: #
  • Target version: master

Summary

TODO

  • ...

Checklist

  • Code is properly formatted
  • All commits have Change-Id
  • I have run tests with make check
  • I have issued make run and manually verified that everything looks okay
  • Documentation (manuals or wiki) has been updated or is not required

@caolanm caolanm force-pushed the private/caolan/async_perf branch 4 times, most recently from 2e407cb to 3130e7c Compare May 16, 2024 13:49
Signed-off-by: Caolán McNamara <[email protected]>
Change-Id: Ie211fe596629af50eec01dd8512d2a12929545ea
Signed-off-by: Caolán McNamara <[email protected]>
Change-Id: I577af4280ac5a0a4389bb11ac6c531d846a196d1
Signed-off-by: Caolán McNamara <[email protected]>
Change-Id: I2d8ab8f3c7e42d6b2f80d68861e54dca9fc4adf2
as a separate stage

getCapabilitiesJson turns out to not be called in the MOBILEAPP case
so put inside !MOBILEAPP ifdef and remove unused branch

Signed-off-by: Caolán McNamara <[email protected]>
Change-Id: Ie144e4612aa36be88169e44d7eda7825b49a03c8
queue addresses that need resolution, use async dns to resolve them
and when final result known dispatch the capabilities to be sent

Signed-off-by: Caolán McNamara <[email protected]>
Change-Id: I13b6d0c4d47e6e8ecd06f7a449c8f808a41e5e7a
@caolanm caolanm force-pushed the private/caolan/async_perf branch from 3130e7c to 1794e4c Compare May 16, 2024 16:07
Signed-off-by: Caolán McNamara <[email protected]>
Change-Id: I1e2d818c0f5b678f3de179b6fb7ce747f9e76ac3
@caolanm caolanm requested a review from mmeeks May 16, 2024 19:09
Copy link
Contributor

@mmeeks mmeeks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very quick skim - and a few comments =) Prolly I mis-understood some things and we should have a call =)


Lookup lookup = _lookups.front();
_lookups.pop();
std::string hostToCheck, exception;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems we hold the lock while we do the slow synchronous lookup (?) =)


void AsyncDNS::addLookup(const std::string& lookup, const DNSThreadFn& cb)
{
std::unique_lock<std::mutex> guard(_lock);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the above - superficially it looks like this will still block the main thread while trying to push a lookup if the other thread is doing a slow sync. lookup (?) - which might defeat the parallelism surely ?

{
net::AsyncDNS::DNSThreadFn pushHostnameResolvedToPoll = [this](const std::string& hostname,
const std::string& exception) {
COOLWSD::getWebServerPoll()->addCallback([this, hostname, exception]() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great - glad we push into the right thread at the end =) I wonder if API-wise we might want to take a SocketPoll & - as well as a function - so it's clear in the API that we will always want a callback to happen in the right thread and it's not possible to re-use the async-DNS stuff outside that safety-net ;-) but - fine for now I guess.


void startThread();
void joinThread();
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would like to have a dumpState() mechanism that chains to the classes waiting on things too - so we can see all the pending work in the queue, and where it goes to etc. on the console as/when we're head-scratching over some odd behavior here :-)

@@ -1284,7 +1377,7 @@ void ClientRequestDispatcher::handlePostRequest(const RequestDetails& requestDet
requestDetails.equals(1, "get-thumbnail"))
{
// Validate sender - FIXME: should do this even earlier.
if (!allowConvertTo(socket->clientAddress(), request))
if (!allowConvertTo(socket->clientAddress(), request, nullptr))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surely this is still rather synchronous with a nullptr callback ?

Signed-off-by: Caolán McNamara <[email protected]>
Change-Id: If8ee89ef0e7436675c596461243d82a2e0412358
Signed-off-by: Caolán McNamara <[email protected]>
Change-Id: Ib40a6d1e3d6e983da674c5a7051ac5e7a565d0d1
@caolanm caolanm force-pushed the private/caolan/async_perf branch from 35b14ee to badb33a Compare May 17, 2024 14:09
Copy link
Contributor

@mmeeks mmeeks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me =)

@caolanm caolanm merged commit 41dc5a6 into master May 17, 2024
14 checks passed
@caolanm caolanm deleted the private/caolan/async_perf branch May 17, 2024 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants