Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to improve PVA put concurrency performance #188

Closed
zhouyunbin opened this issue Apr 26, 2023 · 3 comments
Closed

How to improve PVA put concurrency performance #188

zhouyunbin opened this issue Apr 26, 2023 · 3 comments

Comments

@zhouyunbin
Copy link

I need to put lots of PV at the same time, which function I used is chan.put.set().exec(), but no matter how I use std::jthread or std::thread to achieve, it looks like always sequential execution at the bottom level. Is there a way to put the value without for waiting timeout?

@mdavidsaver
Copy link
Member

Based on chan.put.set().exec() I think this is a question about https://github.com/mdavidsaver/pvxs . I will try to transfer the issue.

@sveseli
Copy link
Contributor

sveseli commented Apr 26, 2023

The question is probably for pvxs client, but you could also try MultiChannel class from the pvaClientCPP module. Here is what one can expect when connecting to and retrieving data from 1000 CA channels running in an IOC on the same machine:

>>> from pvaccess import *
>>> cList = ['X%s' % i for i in range (1,1001)]
>>> import time
>>> from pvaccess import *
>>> cList = ['X%s' % i for i in range (1,1001)]
>>> mc = MultiChannel(cList, CA)
>>> t0 = time.time(); pv = mc.get(); t1 = time.time(); print(t1-t0)
0.27422356605529785
>>> t0 = time.time(); pv = mc.get(); t1 = time.time(); print(t1-t0)
0.05835700035095215
>>> t0 = time.time(); pv = mc.get(); t1 = time.time(); print(t1-t0)
0.055959224700927734

The initial request is a bit slower because it takes some time to connect to the PVs. Here is what happens with put:

>>> vList = [float(i) for i in range (1,1001)]
>>> t0 = time.time(); mc.putAsDoubleArray(vList); t1 = time.time(); print(t1-t0)
0.13571906089782715
>>> t0 = time.time(); mc.putAsDoubleArray(vList); t1 = time.time(); print(t1-t0)
0.13674354553222656

@mdavidsaver
Copy link
Member

mdavidsaver commented Apr 26, 2023

It looks like github.com doesn't allow transfer of issues between users. So I've opened mdavidsaver/pvxs#42 for further discussion.

To answer your question. Concurrent operations are easy. The exec() method immediately returns an Operation, which can then be stored. In one loop call exec() several times and store each Operations. Then in a second loop call wait() on each Operation. The source for the pvxget executable does this for GET operations. The code flow is the same for PUT.

https://github.com/mdavidsaver/pvxs/blob/dd2f076b4aa6dc63fb91980eda711eabee910696/tools/get.cpp#L104

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants