Finding Signals when the baseline varies greatly by signal set
This sounds like a job for a simple high-pass filter, followed by a simple threshold, to me.

1/3 billion records isn't much data if you're used to radio signal sampling rates, so computationally, this should be most definitely doable.

So, with scipy.signal there's a reasonable signal processing library for Python, but I'm from the GNU Radio world, where you can use Python to plug together a signal processing flow graph. 

In your case, it'd look like this:

Vector Source -+&gt; high pass filter --&gt; threshold --&gt; [custom block]


which  you can click together graphically in GNU Radio companion and let it generate Python, or you can directly write in Python.

The [custom block] is from the top of my head something you'd have to write yourself. You can do that in Python or C++, but Python will be slower to run. I'd still do it in Python for a first prototype:

When the first input is 0, it simply consumes the the input (effectively dropping that data). When it's 1, save the number of the first 1-sample in a row. Then wait until the 1s stop and safe locally something

self._list_of_signals.append( (first_item_number, last_item_number ) )


I think you get the idea. 

You feed in the data into the vector source in your python framework, e.g. with the data from your database, and then let the flow graph run, i.e. process all the data it has.

When it's done running, you ask your custom block to give you the list of timestamps. With their first sample number times the sampling rate, you get a time stamp, and then you just put (start, stop) into your database of "trimmed" data.