Project

General

Profile

Actions

Bug #6339

closed

High CPU usage right before a timer expires

Added by jolly 3 months ago. Updated 3 months ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
libosmocore
Target version:
-
Start date:
01/23/2024
Due date:
% Done:

100%

Spec Reference:

Description

osmo_select_main() waits until a file descriptor event occurs or the nearest timer expires. In case this timer has already expired, it will return immediately. (If no timer is scheduled, it will wait infinitely until a file descriptor event occurs.)

The function uses osmo_timers_nearest_ms() to get the time in milliseconds until the nearest timer times out. The actual time is rounded down to the integer value of milliseconds. Because the value is rounded down, osmo_select_main() will wait up to one millisecond before the nearest timer actually times out. In most cases there is time left. (0..1 ms) Then osmo_select_main() will return and the timer may still have not expired. The main loop that calls osmo_select_main() many times until the timer actually expired, because osmo_timers_nearest_ms() returns 0 in this case. During that time, the main loop will consume 100% CPU time.

In a regular case the bug will not be noticed, but in case the timer is used to trigger RTP frames (50 frames per second), it will slow down the CPU noticeably.

A solution would be to round up the integer value of one millisecond instead of rounding it down.

Actions #1

Updated by jolly 3 months ago

  • % Done changed from 20 to 100

Patch has been submitted to Gerrit and has been merged.

Actions #2

Updated by jolly 3 months ago

  • Status changed from New to Resolved
Actions

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 48.8 MB)