GstShark - Example: CPU usage analysis

From RidgeRun Developer Connection
Jump to: navigation, search




Previous: Examples Index Next: Example: Frame rate




The CPU usage tracer was developed with the purpose of measuring the load on the CPU at the time of running a determined pipeline; this tracer has the capability of measuring every core of the system, which means that in a multiprocessor system the tracer is capable of measuring the load on every core, giving an idea of the effort that running the pipeline means for the CPU and the effect on the total CPU consumption. Refer to the GstShark User's Guide GstShark for more detailed information.

Error something wrong.jpg Problems running the pipelines shown on this page?
Please see our GStreamer Debugging guide for help.

Description

The following pipeline is an example used for showing the load on the CPU introduced by running an encoding pipeline. The caps of the pipeline set a frame rate value of 30 FPS and the fakesink element is configured to not synchronize with the clock of the pipeline (normally it is the system clock), therefore the pipeline tries to produce the maximum frame rate using the 100% of the resources of the cores available in the processor as it can be seen on the plot of the results obtained right after the test pipeline.

Original pipeline

Pipeline:

GST_DEBUG="GST_TRACER:7" GST_TRACERS="cpuusage" gst-launch-1.0 videotestsrc num-buffers=10000 ! 'video/x-raw, format=(string)YUY2, width=(int)640, height=(int)480, framerate=(fraction)30/1' ! videorate max-rate=30 ! videoconvert ! queue ! avenc_h263p ! queue ! avimux ! fakesink 

Result:

CPU usage of the pipeline with a fakesink not synchronized with the clock

Improving the pipeline

With the purpose of making a comparison and checking the behavior of the CPU usage tracer to different circumstances, the element fakesink was configured to be synchronized with the clock of pipeline, which means that each element is executed 30 times per second, according to the caps of the pipeline; and therefore the CPU usage will decrease as it is shown on the plot at following.

Pipeline:

GST_DEBUG="GST_TRACER:7" GST_TRACERS="cpuusage" gst-launch-1.0 videotestsrc num-buffers=900 ! 'video/x-raw, format=(string)YUY2, width=(int)640, height=(int)480, framerate=(fraction)30/1' ! videorate max-rate=30 ! videoconvert ! queue ! avenc_h263p ! queue ! avimux ! fakesink sync=true

Result:

CPU usage of the pipeline with a fakesink synchronized with the clock

Result comparison

In addition to the results obtained through the CPU usage tracer and the plots through the scripts from the GstShark application, is possible to get a comparison graph between CPU Usage and frame rate depending only on the tracers selected at the time of running the pipeline. This is a feature, limited only to the CPU usage and frame rate tracers, and the only extra step needed is to add the frame rate tracer to the previous pipeline as it is shown on the following box, the resulting plot is presented after the pipeline run:

GST_DEBUG="GST_TRACER:7" GST_TRACERS="cpuusage;framerate" gst-launch-1.0 videotestsrc num-buffers=900 ! 'video/x-raw, format=(string)YUY2, width=(int)640, height=(int)480, framerate=(fraction)30/1' ! videorate max-rate=30 ! videoconvert ! queue ! avenc_h263p ! queue ! avimux ! fakesink sync=true
CPU usage and frame rate of the pipeline with a fakesink synchronized with the clock


Previous: Examples Index Next: Example: Frame rate