Skip to content

Conversation

@ywkaras
Copy link
Contributor

@ywkaras ywkaras commented May 5, 2023

No description provided.

@ywkaras ywkaras self-assigned this May 5, 2023
@ywkaras ywkaras added the Debug Support for system debugging label May 5, 2023
@ywkaras ywkaras added this to the 10.0.0 milestone May 5, 2023
@bryancall bryancall requested a review from SolidWallOfCode May 8, 2023 22:07
~NetAcceptAction() override { Debug("net_accept", "NetAcceptAction dying"); }
~NetAcceptAction() override
{
static DbgCtl dbg_ctl{"net_accept"};
Copy link
Member

@SolidWallOfCode SolidWallOfCode May 12, 2023

Choose a reason for hiding this comment

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

Are there any concerns about late initialization for this? IIRC the compiler can arrange for dbg_ctl to be constructed on first invocation rather than process start. Is the constructor thread safe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used the reference count work-around for the C++ initialization/destruction order fiasco. Construction of a DbgCtl increments the reference count to the tag container. The tag container is created when the reference count goes from 0 to 1:

~DbgCtl() { _rm_reference(); }

DbgCtl::_new_reference(char const *tag)

_RegistryAccessor()

I probably would have gotten a promotion for figuring all of this out, if I were under 40 and it involved YAML.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also note that the static local DbgCtl is key to getting the old Debug() call to have the improved performance:

static DbgCtl Debug_ctl(TAG); \

That code has gone through both years of review and running in production.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you want to see something really scary, pull over, here's a static DbgCtl that's local to a lambda:

static DbgCtl idts_ctl(TAG); \

Copy link
Member

@SolidWallOfCode SolidWallOfCode May 16, 2023

Choose a reason for hiding this comment

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

I was much more concerned about thread safety. Can the registry be updated from multiple threads concurrently? Consider line "DbgCtl.cc:158". Is that thread safe?

auto res = d.set.insert(ctl);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes because the constructor of _RegistryAccessor takes the registry's mutex:

_RegistryAccessor ra;

DbgCtl dbg_ctl_v_net_queue{"v_net_queue"};
DbgCtl dbg_ctl_iocore_net_main{"iocore_net_main"};

#ifdef DEBUG
Copy link
Member

Choose a reason for hiding this comment

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

Is it worth #ifdef for these? It's not much of a footprint.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm indifferent, what's you preference? One could make the argument that DDbg() itself is not worth it.

Copy link
Member

@SolidWallOfCode SolidWallOfCode left a comment

Choose a reason for hiding this comment

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

My only real concern is with the controls that are function local and when, exactly, those are constructed.

@ezelkow1
Copy link
Member

[approve ci centos]

@ywkaras ywkaras force-pushed the NewDbg4 branch 3 times, most recently from a493f4a to 8fa41fb Compare July 26, 2023 18:15
@ywkaras ywkaras force-pushed the NewDbg4 branch 3 times, most recently from 697fa7f to 40bf579 Compare August 17, 2023 15:10
@ywkaras ywkaras changed the title Remove deprecated debug output functions from 19 source files. Remove deprecated debug output functions from 21 source files. Aug 17, 2023
@ywkaras
Copy link
Contributor Author

ywkaras commented Aug 17, 2023

@SolidWallOfCode if this doesn' t get reviewed soon, @zwoop will throw me in the wood chipper in the backyard of the Denver Apple site. And you'll have to live with the guilt.

@ywkaras ywkaras force-pushed the NewDbg4 branch 2 times, most recently from 845c5a6 to 3247c5e Compare August 28, 2023 19:08
Copy link
Contributor

@zwoop zwoop left a comment

Choose a reason for hiding this comment

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

Not 100% sure I like the pattern with static "ctl"'s in functions / scopes, but I'll survive.

@ywkaras
Copy link
Contributor Author

ywkaras commented Sep 13, 2023

As we discussed, I investigated the overhead of local static that are dynamically initialized. I looked at the assembler generated by some example code. In this example, if the local static in f() is already initialized, the overhead will be executing instructions on lines 3 through 5 of the assembler code. The mutex locking only comes in if it's not initialized, to avoid a race condition if multiple threads see it as uninitialized, and try to initialize it. https://godbolt.org/z/EjM9jsPz3

@ywkaras ywkaras merged commit 55f6901 into apache:master Sep 13, 2023
cmcfarlen pushed a commit to cmcfarlen/trafficserver that referenced this pull request Jun 3, 2024
cmcfarlen pushed a commit to cmcfarlen/trafficserver that referenced this pull request Jun 3, 2024
* commit '236b749b2b3cc746829ad534a7034ab7799d1b71':
  Allow origins to do TLS renegotiation (apache#10385)
  Remove deprecated debug output functions from 21 source files. (apache#9683)
  Fixes some make test build problems (apache#10402)
  Removes unused Errata functions from WCCP (apache#10380)
  Move InkAPI.cc into src/api (apache#10315)
  cmake: Generate files in rc, install the trafficserver script (apache#10367)
  Add support for OCSP requests by GET method (apache#10306)
  Preserve unmapped url regardless of need for remapping (apache#10304)
  Add TSVConnFdGet api (apache#10324)
  include/ts: comma on all last enum elements (apache#10400)
  cmake: Add remaining plugins without external deps (apache#10395)
  CID-1508974 (apache#10397)
  CID-1508987 (apache#10398)
  Coverity 1518564: fix off by one (apache#10401)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Debug Support for system debugging

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants