Copilot commented on code in PR #12602:
URL: https://github.com/apache/trafficserver/pull/12602#discussion_r2453623340
##########
doc/admin-guide/files/records.yaml.en.rst:
##########
@@ -383,6 +383,18 @@ Thread Variables
will create its own domain socket with a ``-<thread id>`` suffix added to
the
end of the path.
+.. ts:cv:: CONFIG proxy.config.exec_thread.event_time_update_rate INT 10
+
+ This dynamically loadable setting controls the rate that exec thread loop
timestamps are
+ updated after processing an event given as a percentage from 0 to 100. 0
+ would mean the timestamp is only updated once per event loop, 100 percent
+ means the timestamp is updated after any potential operation that could take
+ time (i.e. processing and event or waiting on IO). The timestamp is used
for
Review Comment:
Corrected spelling of 'and event' to 'an event'.
```suggestion
time (i.e. processing an event or waiting on IO). The timestamp is used
for
```
##########
doc/admin-guide/files/records.yaml.en.rst:
##########
@@ -383,6 +383,18 @@ Thread Variables
will create its own domain socket with a ``-<thread id>`` suffix added to
the
end of the path.
+.. ts:cv:: CONFIG proxy.config.exec_thread.event_time_update_rate INT 10
+
+ This dynamically loadable setting controls the rate that exec thread loop
timestamps are
+ updated after processing an event given as a percentage from 0 to 100. 0
+ would mean the timestamp is only updated once per event loop, 100 percent
+ means the timestamp is updated after any potential operation that could take
+ time (i.e. processing and event or waiting on IO). The timestamp is used
for
+ queing events and comparing timestamps for processing. Updating more often
Review Comment:
Corrected spelling of 'queing' to 'queueing' and 'and event' to 'an event'.
```suggestion
time (i.e. processing an event or waiting on IO). The timestamp is used
for
queueing events and comparing timestamps for processing. Updating more
often
```
##########
src/iocore/eventsystem/UnixEThread.cc:
##########
@@ -144,26 +146,29 @@ EThread::set_event_type(EventType et)
event_types |= (1 << static_cast<int>(et));
}
-void
-EThread::process_event(Event *e, int calling_code)
+ink_hrtime
+EThread::process_event(Event *e, int calling_code, ink_hrtime event_time)
{
ink_assert((!e->in_the_prot_queue && !e->in_the_priority_queue));
WEAK_MUTEX_TRY_LOCK(lock, e->mutex, this);
if (!lock.is_locked()) {
- e->timeout_at = ink_get_hrtime() + DELAY_FOR_RETRY;
+ e->timeout_at = event_time + DELAY_FOR_RETRY;
EventQueueExternal.enqueue_local(e);
} else {
if (e->cancelled) {
MUTEX_RELEASE(lock);
free_event(e);
- return;
+ return event_time;
}
Continuation *c_temp = e->continuation;
// Restore the client IP debugging flags
set_cont_flags(e->continuation->control_flags);
e->continuation->handleEvent(calling_code, e);
+ if (static_cast<int>(generator.random() % 100) < event_time_update_rate) {
+ event_time = ink_get_hrtime();
Review Comment:
The modulo operation on random() happens on every event processing. Consider
checking if `event_time_update_rate` is 0 or 100 first to skip the random
number generation in those cases, as they represent deterministic behavior
(never update or always update).
```suggestion
if (event_time_update_rate == 100) {
event_time = ink_get_hrtime();
} else if (event_time_update_rate != 0) {
if (static_cast<int>(generator.random() % 100) <
event_time_update_rate) {
event_time = ink_get_hrtime();
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]