pylogix icon indicating copy to clipboard operation
pylogix copied to clipboard

Speed benchmarks

Open alex4acre opened this issue 2 years ago • 9 comments

Preflight checks

Before you post an issue, ensure you have tried the minimal examples within the repo, or tried the pylogix-tester.

Type of issue

  • [ ] Bug
  • [ ] Feature Request
  • [x] Question
  • [ ] Other

Delete items that do not apply below.

Description of issue

After looking through the questions here I did not see this question explicitly. Has this been benchmarked in terms of reads/writes per second? What is a reasonable expectation? Can this be used to query data at a regular high interval (a few hundred tags at 100ms)?

alex4acre avatar Sep 22 '21 12:09 alex4acre

Hey there, I did some performance testing before comparing this to OPC servers. A few hundred tags should be no problem at 100ms. Have a look at these reports. pylogix was used for the EIP portions. Hope this helps.

Avg response for 1000 individual tags (zero use of threading or async funcs), also this could be faster by a tenfold if you read an array of data:

1000 tags pylogix
No. of tags 1000, execution: 183.488 milliseconds
No. of tags 1000, execution: 70.272 milliseconds
No. of tags 1000, execution: 73.244 milliseconds
No. of tags 1000, execution: 67.356 milliseconds
No. of tags 1000, execution: 70.258 milliseconds
No. of tags 1000, execution: 68.312 milliseconds
No. of tags 1000, execution: 78.13000000000001 milliseconds
No. of tags 1000, execution: 82.938 milliseconds
No. of tags 1000, execution: 71.257 milliseconds
No. of tags 1000, execution: 75.163 milliseconds

round-trip.pdf

large-read.pdf

TheFern2 avatar Sep 22 '21 13:09 TheFern2

Dang @TheFern2, nice work. It's kind of funny that Ignition beats RA at their own protocol. I'd guess they utilize reads by instance ID, which allows you to pack more data into a packet, plus multiple connections.

dmroeder avatar Sep 22 '21 14:09 dmroeder

@TheFern2, are you saying that you are doing individual reads for each tag at this rate? That these are not put into a tag array like the example 05_read_multiple_tags.py?

alex4acre avatar Sep 22 '21 15:09 alex4acre

@TheFern2, are you saying that you are doing individual reads for each tag at this rate? That these are not put into a tag array like the example 05_read_multiple_tags.py?

Correct single reads, it could be very well even faster if you group tags in a single call or do an array read. Not sure how many tags you can do per multiread with pylogix? @dmroeder is there a limit?

Dang @TheFern2, nice work. It's kind of funny that Ignition beats RA at their own protocol. I'd guess they utilize reads by instance ID, which allows you to pack more data into a packet, plus multiple connections.

Yeah not sure what they're doing behind the scenes but I only ever saw one eip connection open in ignition. they're fast for sure. I am thinking RA is doing some internal throttling behind the scenes, ain't no telling.

TheFern2 avatar Sep 22 '21 15:09 TheFern2

There is no limit. pylogix will break the reads up based on the max packet size.

@TheFern2 what controller were you using for your test?

Edit: based on a quick test, I believe @TheFern2 test would have been reading a list of tags, doing 1000 individual reads would take a lot longer than 100ms. I just did a test reading 300 tags, one at a time, it took about 3.4 seconds. Reading them as a list took about 70ms. Now if the controller is a 1756-L8x or a 5069-L3xER, the speeds will likely be much faster.

dmroeder avatar Sep 22 '21 16:09 dmroeder

There is no limit. pylogix will break the reads up based on the max packet size.

@TheFern2 what controller were you using for your test?

Edit: based on a quick test, I believe @TheFern2 test would have been reading a list of tags, doing 1000 individual reads would take a lot longer than 100ms. I just did a test reading 300 tags, one at a time, it took about 3.4 seconds. Reading them as a list took about 70ms. Now if the controller is a 1756-L8x or a 5069-L3xER, the speeds will likely be much faster.

Yeah, that's right I had forgotten just checked my scripts. It was a list of tags indeed. It was a compactlogix L33 iirc.

TheFern2 avatar Sep 22 '21 16:09 TheFern2

@dmroeder

There is no limit. pylogix will break the reads up based on the max packet size.

from the documentation it seemed there was a byte limit. Are you saying that is no longer the case? Can I pack as many different tags into a single python array and read it that way?

alex4acre avatar Sep 22 '21 17:09 alex4acre

@dmroeder

There is no limit. pylogix will break the reads up based on the max packet size.

from the documentation it seemed there was a byte limit. Are you saying that is no longer the case? Can I pack as many different tags into a single python array and read it that way?

You should be able to read a list of tags as large as you want.

I might need to make the documentation a little more clear. There is a limit to the amount of data that can fit into a single packet. For modern Rockwell PLC's that limit is 4002 bytes.

Pylogix will take your list of tags and generate as many reads as necessary to read all of your tags, returning the values to you after all are read.

So let's say 100 tags will fit into a single 4002 byte packet. You provide a list of 200 tags. pylogix will generate 2 packets, the first 100 being in the first packet, the next 100 being in the 2nd packet. Once all of the values are retrieved, the enter list of 200 responses are returned to you.

Hopefully that makes sense.

dmroeder avatar Sep 22 '21 17:09 dmroeder

That makes sense!

alex4acre avatar Sep 22 '21 19:09 alex4acre