-
Notifications
You must be signed in to change notification settings - Fork 531
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
Encapsulate code converting std::chrono::duration to timeval #1915
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,9 +191,7 @@ main(int, char **) | |
#endif | ||
|
||
for (;;) { | ||
struct timeval tv; | ||
tv.tv_sec = std::chrono::seconds(PingerTimeout).count(); | ||
tv.tv_usec = 0; | ||
auto tv = ToTimeval(PingerTimeout); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new converter handles There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
AFAICT, the above statement is based on two false assumptions: False assumption A: Proposed compiled code will be different from official compiled code. In reality, modern optimizing compilers see enough in this context to generate identical assembly in both cases (even at -O1 optimization level)! False assumption B: This loop is performance sensitive (at the precision level of a few integer operations added or removed). In reality, this is an I/O-waiting loop in a pinger helper. Adding a few quick ops to that loop would not change pinger performance, even under heavy load. In summary, this PR does not "add a performance regression". N.B. Proposed loop code is also clearly better -- it is a bit easier to read, and it supports reasonable PingerTimeout values that the official code silently mishandles. We may never need to support fractional seconds in this context, but better code is still an improvement.
Please do not block PRs just because you do not see value in them (when other core developers do see value). |
||
FD_ZERO(&R); | ||
if (icmp4_worker >= 0) { | ||
FD_SET(icmp4_worker, &R); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FTR; I do not believe this one is a true need. The
doMsec
cases should all be replaced by an output printingchrono::duration
instead.Better to add that new display logic and make this %code the first usage of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes in this PR do not preclude those future assembly() improvements. In fact, they can be viewed as making those future improvements slightly easier!
Correctly improving assemble() to get rid of doMsec and similar code would be good, but it is a complex, large task that is orthogonal to the small improvement offered by this PR. We should not view this as "either or" or "better X than Y" situation. Both "X" and "Y" are moving Squid code forward. "X" got here first; let's merge it.