adaptive compression including time to (de)compress data
Posted: Tue Sep 27, 2011 9:04 pm
Hi,
I've been mulling over a problem I have with OpenVPN compression and wondered
if an idea I had might make sense or if (more likely) it is just the ramblings
of a beginner. If you bear with me I'll describe it briefly and someone might
say why it's a bad idea.
As I understand it, if the compression ratio is R (ie R=0.9 means a 10%
reduction in data size), then you'll get data compression if R<1, but not if
R>1. Is that right? The docs seem to say that's roughly it.
As far as I can see, there are two criteria which determine whether compressing
data is a good idea:
1. The data, when compressed, is smaller than the original.
2. The time taken to compress is less than the time saved by the compression.
#1 is really a subset of #2 -- if the data doesn't compress, it won't
save time to compress it. So, an ideal adaptive compression might determine
whether to compress or not based on criteria #2.
Suppose openvpn can monitor the average Bitrate of data sent across the link,
B (this should be independent of whether compression is in use). The time
taken to forward a frame of size M across the link should be roughly:
Time = M / B seconds
If the observed compression ratio is R as above, the transfer time saved by
compressing the data should be about:
dTime = (1-R) * M / B seconds
One could in principal monitor cTime, the average time taken to compress the
data and possibly even xTime, the average time taken to expand the data. Then
use a criteria like:
if(dTime > (cTime + xTime)) {
enable_compression;
}
xTime might be awkward to determine, as it's only available at the far end, but
you could ignore it if need be and just use cTime. I would imagine compressing
is probably more costly than decompressing.
The reason I suggest this is that I've noticed that a busy CPU on a slow laptop
appears to kill OpenVPN performance if compression is enabled. My guess is
that the compression or decompression time is slowing things down. I would
prefer that the adaptive compression would realise that the compression is not
a benefit in this case and disable it.
Maybe this is overly simplistic, pure nonsense or maybe OpenVPN already does
this (the man page doesn't seem to suggest it, but I might have misread).
Thanks in advance for any opinions, corrections or criticisms,
Gavin
I've been mulling over a problem I have with OpenVPN compression and wondered
if an idea I had might make sense or if (more likely) it is just the ramblings
of a beginner. If you bear with me I'll describe it briefly and someone might
say why it's a bad idea.
As I understand it, if the compression ratio is R (ie R=0.9 means a 10%
reduction in data size), then you'll get data compression if R<1, but not if
R>1. Is that right? The docs seem to say that's roughly it.
As far as I can see, there are two criteria which determine whether compressing
data is a good idea:
1. The data, when compressed, is smaller than the original.
2. The time taken to compress is less than the time saved by the compression.
#1 is really a subset of #2 -- if the data doesn't compress, it won't
save time to compress it. So, an ideal adaptive compression might determine
whether to compress or not based on criteria #2.
Suppose openvpn can monitor the average Bitrate of data sent across the link,
B (this should be independent of whether compression is in use). The time
taken to forward a frame of size M across the link should be roughly:
Time = M / B seconds
If the observed compression ratio is R as above, the transfer time saved by
compressing the data should be about:
dTime = (1-R) * M / B seconds
One could in principal monitor cTime, the average time taken to compress the
data and possibly even xTime, the average time taken to expand the data. Then
use a criteria like:
if(dTime > (cTime + xTime)) {
enable_compression;
}
xTime might be awkward to determine, as it's only available at the far end, but
you could ignore it if need be and just use cTime. I would imagine compressing
is probably more costly than decompressing.
The reason I suggest this is that I've noticed that a busy CPU on a slow laptop
appears to kill OpenVPN performance if compression is enabled. My guess is
that the compression or decompression time is slowing things down. I would
prefer that the adaptive compression would realise that the compression is not
a benefit in this case and disable it.
Maybe this is overly simplistic, pure nonsense or maybe OpenVPN already does
this (the man page doesn't seem to suggest it, but I might have misread).
Thanks in advance for any opinions, corrections or criticisms,
Gavin