DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [Bug 435] Proposed improvement to non-interactive loop timing
@ 2020-04-04  1:47 bugzilla
  2021-01-25  5:55 ` bugzilla
  0 siblings, 1 reply; 2+ messages in thread
From: bugzilla @ 2020-04-04  1:47 UTC (permalink / raw)
  To: dev

https://bugs.dpdk.org/show_bug.cgi?id=435

            Bug ID: 435
           Summary: Proposed improvement to non-interactive loop timing
           Product: DPDK
           Version: 20.02
          Hardware: All
                OS: Linux
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: Normal
         Component: testpmd
          Assignee: dev@dpdk.org
          Reporter: cfb@hpe.com
  Target Milestone: ---

When running testpmd in non-interactive mode, and using a stats period value,
the current loop delay is less than ideal.

The current code:

                if (stats_period != 0) {
                        uint64_t prev_time = 0, cur_time, diff_time = 0;
                        uint64_t timer_period;

                        /* Convert to number of cycles */
                        timer_period = stats_period * rte_get_timer_hz();

                        while (f_quit == 0) {
                                cur_time = rte_get_timer_cycles();
                                diff_time += cur_time - prev_time;

                                if (diff_time >= timer_period) {
                                        print_stats();
                                        /* Reset the timer */
                                        diff_time = 0;
                                }
                                /* Sleep to avoid unnecessary checks */
                                prev_time = cur_time;
                                sleep(1);
                        }
                }

Compares the difference in time, and if the time has not expired, will sleep
for one second before checking again. The problem with this is when the
difference is close, but not at the timer period. This will result in an
additional second being added to the update period. (e.g. a one second period
becomes almost 2 seconds.)

Ideally, the sleep value would be based on the amount of time left (cur_time -
prev_time).

Using usleep(), it is possible to create delays that are closer to the desired
delay.

The following code appears to work for me, and takes into account the time
required for the print_stats() call, but there may be a better solution:

                if (stats_period != 0) {
                        uint64_t cur_time, ticks_per_usec;
                        uint64_t timer_period;

                        /* Convert to number of usecs */
                        timer_period = stats_period * 1000000;
                        /* How many CPU ticks per usec */
                        ticks_per_usec = rte_get_timer_hz() / 1000000;

                        while (f_quit == 0) {
                                /* Get the current CPU ticks */
                                cur_time = rte_get_timer_cycles();
                                print_stats();
                                /* Get the tick count again and sleep for the
difference */
                                usleep(timer_period - (rte_get_timer_cycles() -
cur_time) / ticks_per_usec);
                        }
                }

-- 
You are receiving this mail because:
You are the assignee for the bug.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [dpdk-dev] [Bug 435] Proposed improvement to non-interactive loop timing
  2020-04-04  1:47 [dpdk-dev] [Bug 435] Proposed improvement to non-interactive loop timing bugzilla
@ 2021-01-25  5:55 ` bugzilla
  0 siblings, 0 replies; 2+ messages in thread
From: bugzilla @ 2021-01-25  5:55 UTC (permalink / raw)
  To: dev

https://bugs.dpdk.org/show_bug.cgi?id=435

Zhang, RobinX (robinx.zhang@intel.com) changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |WONTFIX
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |robinx.zhang@intel.com

--- Comment #1 from Zhang, RobinX (robinx.zhang@intel.com) ---
Hi Charlie, you can send your proposal to community for further discussion.
Here's the contributor's guideline:
https://doc.dpdk.org/guides/contributing/index.html

For this bugzilla, due to it's not a bug, I will close it, thanks.

-- 
You are receiving this mail because:
You are the assignee for the bug.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-25  5:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-04  1:47 [dpdk-dev] [Bug 435] Proposed improvement to non-interactive loop timing bugzilla
2021-01-25  5:55 ` bugzilla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).