I just tried to test the controller. I found it experienced a latency of around 25 ms when calling a method in the rpc server from ARTIQ. Is this normal?
First I implemented a simple server. In the server, I created a method that performs no actions:
from sipyco.remote_exec import simple_rexec_server_loop
import logging
class MyServer:
def do_noting(self):
pass
def ping(self):
return True
def main():
logging.basicConfig(level=logging.INFO)
my_server = MyServer()
simple_rexec_server_loop("my_server", my_server, "::1", 17000)
if __name__ == "__main__":
main()
And added it to the device database:
...
device_db.update({
"my_server": {
"type": "controller",
"host": "::1",
"port": 17000,
"target_name": "my_server",
"command": "python3 -m backend.controllers.my_server"
},
})
Then I called that method from ARTIQ and measured the time before and after the call:
from artiq.experiment import *
from artiq.coredevice import core
class TestServerLatency(EnvExperiment):
def build(self):
pass
def prepare(self):
self.core: core.Core = self.get_device(self.core_name)
self.my_server: MyServer = self.get_device("my_server")
@kernel
def run(self):
self.core.reset()
self.core.break_realtime()
for i in range(10):
rtio_cursor_1 = self.core.get_rtio_counter_mu()
self.my_server.do_nothing()
rtio_cursor_2 = self.core.get_rtio_counter_mu()
print(rtio_cursor_2 - rtio_cursor_1)
I found the delays of about 25ms:
...
INFO:worker(2567,test_sipyco.py):print:25219936
INFO:worker(2567,test_sipyco.py):print:24917544
INFO:worker(2567,test_sipyco.py):print:24892720
INFO:worker(2567,test_sipyco.py):print:24886056
INFO:worker(2567,test_sipyco.py):print:27009160
INFO:worker(2567,test_sipyco.py):print:24918368
INFO:worker(2567,test_sipyco.py):print:24885424
INFO:worker(2567,test_sipyco.py):print:24885784
INFO:worker(2567,test_sipyco.py):print:24885352
INFO:worker(2567,test_sipyco.py):print:24916608
...
For comparison, when I ping the ARTIQ IP from RPC, the delay is less than 1ms. Is there something I did wrong, or is this just how it is?