dmroeder / pylogix

Read/Write data from Allen Bradley Compact/Control Logix PLC's
Apache License 2.0
598 stars 182 forks source link

Speed benchmarks #184

Closed alex4acre closed 2 years ago

alex4acre commented 3 years ago

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

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)?

TheFern2 commented 3 years ago

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

dmroeder commented 3 years ago

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.

alex4acre commented 3 years ago

@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?

TheFern2 commented 3 years ago

@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.

dmroeder commented 3 years ago

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.

TheFern2 commented 3 years ago

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.

alex4acre commented 3 years ago

@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?

dmroeder commented 3 years ago

@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.

alex4acre commented 3 years ago

That makes sense!