Skip to content

Maintenance: move async and events code to libasync #1635

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

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

kinkie
Copy link
Contributor

@kinkie kinkie commented Jan 13, 2024

Move Async and Events related code
to own library in src/async

@kinkie
Copy link
Contributor Author

kinkie commented Jan 13, 2024

Note: I have intentionally avoided creating Async namespace, this PR touches so much code already.
If there is consensus to do it, I'll do that as a followup PR

@kinkie
Copy link
Contributor Author

kinkie commented Jan 13, 2024

The idea for this PR stems from a comment in PR #1548

@kinkie kinkie changed the title Create libasync Maintenance: move async and events code to async/ Jan 13, 2024
@kinkie kinkie changed the title Maintenance: move async and events code to async/ Maintenance: move async and events code to libasync.la Jan 13, 2024
@kinkie kinkie changed the title Maintenance: move async and events code to libasync.la Maintenance: move async and events code to libasync Jan 13, 2024
@rousskov
Copy link
Contributor

rousskov commented Jan 13, 2024

I have intentionally avoided creating Async namespace, this PR touches so much code already.

FWIW, I do not think creating Async namespace is a good idea (in any PR).

@kinkie kinkie marked this pull request as draft January 13, 2024 22:03
@kinkie kinkie changed the title Maintenance: move async and events code to libasync [WIP] Maintenance: move async and events code to libasync Jan 13, 2024
@yadij
Copy link
Contributor

yadij commented Jan 13, 2024

I have intentionally avoided creating Async namespace, this PR touches so much code already.

FWIW, I do not think creating Async namespace is a good idea (in any PR).

And yet it was you who decided all these objects should consume the Async prefix (a.k.a. namespace).
You have a better alternative to rename them as?

IMO the AsyncJob and related pieces are sufficiently complex and self-contained to deserve their own library+namespace like this.

However, @kinkie please do not merge the EventLoop mechanism into it. That should have a separate library of its own.

@yadij
Copy link
Contributor

yadij commented Jan 13, 2024

@kinkie, also be aware the AsyncEngine is an interface for the Engine mechanism, not the part of AsyncJob mechanism.

@kinkie
Copy link
Contributor Author

kinkie commented Jan 14, 2024

I have intentionally avoided creating Async namespace, this PR touches so much code already.

FWIW, I do not think creating Async namespace is a good idea (in any PR).

Sure, but could you highlight why? It would be a deviation from standard practice, isn't it?

@rousskov rousskov self-requested a review January 14, 2024 14:15
@kinkie kinkie changed the title [WIP] Maintenance: move async and events code to libasync Maintenance: move async and events code to libasync Jan 14, 2024
@kinkie kinkie marked this pull request as ready for review January 14, 2024 16:37
@@ -8,4 +8,3 @@

#include "squid.h"
#include "AsyncEngine.h"

Copy link
Contributor

Choose a reason for hiding this comment

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

File should no longer be touched.

@@ -27,7 +28,6 @@
#include "comm/Loops.h"
#include "CommCalls.h"
#include "errorpage.h"
#include "event.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

This event.h and corresponding event.cc code is all part of the EventLoop mechanism. Not part of AsyncJob code, even though the two are similar and interact.


if ENABLE_AUTH
SUBDIRS += auth
AUTH_LIBS= auth/libauth.la
AUTH_ACL_LIBS= auth/libacls.la
endif

SUBDIRS += http ip icmp ident log ipc mgr
SUBDIRS += http ip icmp ident log ipc mgr
Copy link
Contributor

Choose a reason for hiding this comment

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

typo

Suggested change
SUBDIRS += http ip icmp ident log ipc mgr
SUBDIRS += http ip icmp ident log ipc mgr

class CallDialer;
class DelayedAsyncCalls;

template <class Answer> class AsyncCallback;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
template <class Answer> class AsyncCallback;
template<class Answer> class AsyncCallback;

template<class Job> class JobWait;

template<class Cbc> class CbcPointer;
typedef CbcPointer<AsyncJob> AsyncJobPointer;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
typedef CbcPointer<AsyncJob> AsyncJobPointer;
using AsyncJobPointer = CbcPointer<AsyncJob>;

Copy link
Contributor

@rousskov rousskov left a comment

Choose a reason for hiding this comment

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

Alex: FWIW, I do not think creating Async namespace is a good idea (in any PR).

Francesco: Sure, but could you highlight why?

I am not convinced that every Squid class must be in a namespace1. If some Squid classes should not be in a namespace, then it is reasonable to question whether, say, AsyncCall should be. To me, AsyncCall feels similar to SBuf -- both do not really need a dedicated namespace1 AFAICT.

I failed to find an applicable industry guideline regarding the use of namespaces in similar contexts.

The value of numerous users using "Async::Call" (instead of existing "AsyncCall") just so that AsyncCall implementation can simply say "Call" is rather questionable.

If all deferred calls (whatever we decide that or a similar term means) should migrate to (the variation of) AsyncCall API, then we may even decide to drop "Async" itself. One large change is better than two (with the same end result) in this case.

I will change my position if somebody proves that we should change 800+ lines of code to migrate AsyncCall and AsyncJob to Async namespace, but I believe that change proposal must come first, before I am forced to spend even more time on discussing a change that has not been really proposed yet.

Francesco: It would be a deviation from standard practice, isn't it?

You will need to define "standard practice" for me to be able to answer that question. I can interpret that term many different ways. Needless to say, Squid does not use namespaces for some code grouped inside src directories, and I am not aware of any requirement to use a namespace for all src directories code. Each directory or group of related names deserves a dedicated decision IMO.

Amos: And yet it was you who decided all these objects should consume the Async prefix (a.k.a. namespace).

I have been begging to stop posting reviews of people and yet here we go again.

  • Squid classes used "Async prefix" before "all these objects" were introduced
  • a class name prefix is not the same as a C++ namespace
  • not "all these objects" consume the "Async prefix"

Amos: You have a better alternative to rename them as?

I am not convinced they should be renamed at this time.

Amos: IMO the AsyncJob and related pieces are sufficiently complex and self-contained to deserve their own library+namespace like this.

FWIW, I am (still) OK with grouping AsyncCall-related code in a dedicated directory and convenience library. The devil is in the details (e.g., what code to move, what directory name to use, whether to introduce a new namespace, whether to rename anything, etc.). For example, we can move without introducing a new namespace. I believe those details are being hammered out elsewhere, and this PR should continue to wait for the conclusion of those discussions.

Amos: the EventLoop mechanism ... should have a separate library of its own.

FWIW, there is currently no consensus on whether EventLoop deserves a library of its own.

Footnotes

  1. Other than the existing default global namespace and "Squid" namespace that we might use more aggressively for reasons unrelated to this discussion. 2

@kinkie kinkie marked this pull request as draft February 1, 2024 12:01
@kinkie kinkie added the M-ignored-by-merge-bots https://github.com/measurement-factory/anubis/blob/master/README.md#pull-request-labels label Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
M-ignored-by-merge-bots https://github.com/measurement-factory/anubis/blob/master/README.md#pull-request-labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants