diff options
| author | Mark Stapp <mjs@voltanet.io> | 2021-02-22 13:04:43 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-22 13:04:43 -0500 |
| commit | 76787f231ddf62ea448176f2ca18d290190e0c3d (patch) | |
| tree | abceeb517b203708257aae6a420b3ba244454a88 /lib/thread.c | |
| parent | fa17cdc70fabd79769d4fa86bfcfb3ca78b89ebd (diff) | |
| parent | 5e8229578a96abb7cdfb24b5d7c8756b60793880 (diff) | |
Merge pull request #8105 from donaldsharp/reduce_monotime
lib: Reduce getrusage/monotime for event handling
Diffstat (limited to 'lib/thread.c')
| -rw-r--r-- | lib/thread.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/thread.c b/lib/thread.c index f7f1ed8b7e..5c06c6ddb5 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -1515,9 +1515,13 @@ struct thread *thread_fetch(struct thread_master *m, struct thread *fetch) if (fetch->ref) *fetch->ref = NULL; pthread_mutex_unlock(&m->mtx); + if (!m->ready_run_loop) + GETRUSAGE(&m->last_getrusage); + m->ready_run_loop = true; break; } + m->ready_run_loop = false; /* otherwise, tick through scheduling sequence */ /* @@ -1676,7 +1680,11 @@ void thread_call(struct thread *thread) #endif RUSAGE_T before, after; - GETRUSAGE(&before); + if (thread->master->ready_run_loop) + before = thread->master->last_getrusage; + else + GETRUSAGE(&before); + thread->real = before.real; frrtrace(9, frr_libfrr, thread_call, thread->master, @@ -1689,6 +1697,7 @@ void thread_call(struct thread *thread) pthread_setspecific(thread_current, NULL); GETRUSAGE(&after); + thread->master->last_getrusage = after; #ifndef EXCLUDE_CPU_TIME realtime = thread_consumed_time(&after, &before, &helper); |
