Up to 110x speedup for protocol decoder, v0.96 vs v0.95

General Topics about DSView software
Introduction:
Before v0.96, DSView use the original libsigrokdecode library for protocol decoding. Really thanks to the great effort of sigrok community for libsigrokdecode project.

The original libsigrokdecode process logic data based on each sample, and perform decode one bit by one bit. It lead to a very slow decode speed. For example, a 128M samples of logic 1 signal, there's none of uart operation, but it take about 250 seconds to decode for libsigrokdecode in v0.95 version of DSView.

In v0.96, we make an import improvement to libsigrokdecode, each decoder has ability to analyze the signal, and skip the nonsense section. This produce a significant speedup compare to the original libsigrokdecode library.

Performance evaluation:
We captured a 128s serial port signal at 128M depth and 1MHz sample rate. This signal periodically produce several bytes transfer with 20ms interval. it's a typical real word case with significant meanings.
The UART decoder setting is 115200 baud rate, and other defaults
For libsigrokdecode in v0.95, it takes 4 minutes and 9.16 seconds to decode done
For libsigrokdecode4DSL in v0.96, it only takes 2.23 seconds to decode done.

It's up to 110x speedup. If we consider some limit case, for example, the logic 1 case, new decoder can complete the decoding immediately. it has a limitless speedup.

How to upgrade the original decoder of libsigrokdecode:
In v0.96 version of DSView, we have completed the improvement of three most frequently used protocol. It is UART, I2C and SPI. The decoder name with prefix 0-, indicates it's a speed preference with less details, and don't support stack decoder. Those with prefix 1-, indicates it's a full-featured improvement.
We will continue to improve other decoders, and we also hope more people can participate in the improvement.
Following is some details about how to upgrade the original decoder of libsigrokdecode to libsigrokdecode4DSL
libsigrokdecode4DSL introduce several parameters to help decoder to skip nonsense sample, and tell caller what is the next expacted sample.
itercnt //sample count between next expacted sample and current decoding sample; valid when logic_mask is equal to 0
exp_logic //next expacted signal level(0 or 1), each decoder channel map to one bit, bit is valid when corresponding bit of logic_mask is not equal to 0
logic_mask //indicate the exp_logic of which bit is valid
edge_index //indicate this index of exp_logic must be a edge type, if equal to -1, one of the not masked channel should be a edge
cur_pos //current decoding sample position

Based on these parameters, most of nonsense sample would be skipped by decoder.
for example:
itercnt = 100
logic_mask = 0
this means go to the next 100th sample positon
exp_logic = 0b01
exp_mask = 0b01
edge_index = 0
this means go to the rising edge, first channel of the decoder
exp_mask = 0b1111
edge_index = -1
this means go to the first edge, any one of 4 channels of the decoder

case 1: the simplest compatible change
Just add one row in the main "for loop" of the "decode" method.
data.itercnt += 1
This indicate next decode sample is just the next sample, so decode will perform one bit by one bit, until encouter the last sample.
For example:
compatible.JPG
compatible.JPG (104.45 KiB) Viewed 694 times


case 2: synchronous protocol
synchronous protocol act on every clock edge, so just find out the valid edge
For example:
i2c1.png
i2c1.png (40.33 KiB) Viewed 694 times


case 3: asynchronous protocol
most of asynchronous protocol work based on absolute time, like uart, can, etc.
we can combine the itercnt and exp_logic
For example:
uart.png
uart.png (38.97 KiB) Viewed 694 times


Upstream to libsigrokdecode project:
We really appreciate the great work of libsigrokdecode library, so we also expect the libsigrokdecode project can integrate this important feature. and more people can benefit from our improvement.
We have open all of the modification to the github. please refer to the libsigrokdecode4DSL directory of DSView repo.
Except the speedup improvement, libsigrokdecdoe4DSL also fix some memory leakage issues.
If we need to do more work to make an upstream integration, please feel free to let us know.

Thanks!
Andy
Site Admin
 
Posts: 149
Joined: Fri Jul 11, 2014 9:20 am

Return to General Discussion

Who is online
Users browsing this forum: No registered users and 1 guest
cron