Stefano,

I wanted to try your program, but I get an error message:

mnm@vincent:~/M/_Linux/python/_mnms_tests$ python pyownet_run_out_of_sockets.py
  File "pyownet_run_out_of_sockets.py", line 13
    None if i % freq else print('Iteration {}'.format(i))
                              ^
SyntaxError: invalid syntax

since I am not very familiar with python I do not find the error on the spot... maybe you can help me out


btw. the line

    p = protocol.proxy(‘myowserver', persistent=False)

there is a typo: the first ' after ( is not a ' but a ‘ - it's hard to see here, but with syntax highlighting it is easy to spot ;o)

Martin


On 11/06/2015 11:20 AM, Stefano Miccoli wrote:
A proxy object with 'persistent=False'will bind and destroy a socket for each call to the owserver. (If you call 'netstat -t’ after the timing test you will see hundreds of lines like tcp 0 0 localhost:45494 localhost:4304 TIME_WAIT
which is the debris that remains after you tear down a socket…)

On the contrary with ‘persistent=True'a single socket is bound at the beginning of the transaction and reused for every subsequent owserver call. So 'persistent=False’ has a very small overhead (about 1ms) for each call.

Somehow your figures are consistent with this interpretation: non-persistent overhead is a constant small delta with respect to persistent connection. Since your owserver is apparently much slower than the one which I run my tests, you have a smaller relative overhead.

Usually I would not care about the persistent/non persistent thing, unless you are running out of available sockets.

This program

import itertools
from pyownet import protocol

p = protocol.proxy(‘myowserver', persistent=False)
freq = 1 << 12

for i in itertools.count():
    try:
        c = p.dir()
    except protocol.Error as exc:
        print('Iteration {0} raised exception: {1}'.format(i, exc))
        break
    None if i % freq else print('Iteration {}'.format(i))


prints

Iteration 0
Iteration 4096
Iteration 8192
Iteration 12288
Iteration 16384
Iteration 16977 raised exception: [Errno 49] Can't assign requested address

so it is possible to run out of sockets, although this is a rather edgy situation, that I’ve never analysed in detail.

S.

On 06 Nov 2015, at 02:26, Loren Amelang <lo...@pacific.net <mailto:lo...@pacific.net>> wrote:

On Thu, 05 Nov 2015 13:02:13 +0100,
Stefano Miccoli mo...@icloud.com <mailto:mo...@icloud.com> wrote:
...
Just a few numbers, collected with
https://github.com/miccoli/pyownet/blob/master/test/timing.py
<https://github.com/miccoli/pyownet/blob/master/test/timing.py> querying a
non localhost production owserver

pyownet: ver. 0.8.2
proxy_obj: ownet server at ('10.48.74.112', 4304)
server info: pid 2662, ver. unknown

timeit:
statement: proxy_obj.dir("/")
number: 20
repetitions: 5

** non persistent :  1.29 ms,  1.30 ms,  1.30 ms,  1.33 ms,  1.36 ms,
** persistent     :  0.77 ms,  0.77 ms,  0.79 ms,  0.80 ms,  0.97 ms,

The figure reported here are time for a single call to the given method,
computed as the average of 20 consecutive calls. (Please note that I read the cached temperature value? uncached is of course much slower, but this
is due to 1-wire)


I was surprised by the timing numbers you posted. So I tried your test script with my BBB installation...

Running on the BBB with the owserver:
---
ubuntu@arm:~/Lpkg$ python3 StefanoTimingTest.py3
pyownet: ver. 0.8.2 (/usr/local/lib/python3.4/dist-packages/pyownet/__init__.py)
proxy_obj: ownet server at ('127.0.0.1', 4304)
server info: pid 1243, ver. unknown

timeit:
statement: proxy_obj.dir("/")
number: 20
repetitions: 5

** non persistent : 37.55 ms, 37.78 ms, 39.26 ms, 40.15 ms, 41.11 ms,
** persistent     : 36.22 ms, 36.41 ms, 36.62 ms, 37.10 ms, 38.26 ms,
---


Running Python on an external Windows machine, one Wi-Fi hop from the BBB:
---
C:\Users\Loren\Documents\Projects\Computing\BeagleBone Black\BBB Projects\1-Wire\OWFS Python logging>python StefanoTimingTest.py3 owserver://10.1.1.4:4304 pyownet: ver. 0.8.2 (C:\Apps\Python33\lib\site-packages\pyownet\__init__.py)
proxy_obj: ownet server at ('10.1.1.4', 4304)
server info: pid 22210, ver. unknown

timeit:
statement: proxy_obj.dir("/")
number: 20
repetitions: 5

** non persistent : 41.69 ms, 45.79 ms, 45.99 ms, 48.34 ms, 49.41 ms,
** persistent     : 42.26 ms, 44.03 ms, 45.68 ms, 45.69 ms, 46.03 ms,
---


Between those two tests was a long learning session. For those who don't know...

In netstat, "0.0.0.0" addresses are accessible from outside machines, 127.0.0.1 addresses are not!

The localhost setting is in (at least) two places in /etc/owfs.conf:
! server: server = 10.1.1.4:4304 # localhost:4304 LA151105 allow net access
And:
server: port = 4304  # localhost:4304  LA151105 allow net access

After making those changes, I found "restart" does not notice them! You have to use "force-reload":
ubuntu@arm:~/Lpkg$ sudo /etc/init.d/owserver force-reload
* Restarting 1-Wire TCP Server owserver

Suddenly it works from out on the network!


So I wonder why persistence makes less than 10% difference here, while on your much faster machine it makes 25 to 40%...

| Loren Amelang | lo...@pacific.net <mailto:lo...@pacific.net> |




------------------------------------------------------------------------------
_______________________________________________
Owfs-developers mailing list
Owfs-developers@lists.sourceforge.net <mailto:Owfs-developers@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/owfs-developers



------------------------------------------------------------------------------


_______________________________________________
Owfs-developers mailing list
Owfs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/owfs-developers

------------------------------------------------------------------------------
_______________________________________________
Owfs-developers mailing list
Owfs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/owfs-developers

Reply via email to