-
Notifications
You must be signed in to change notification settings - Fork 53
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
Expose functionality for client side applications #28
base: master
Are you sure you want to change the base?
Conversation
I think it would probably be better to introduce a separate read call for that like the c-api does it. That way we can still have the basic Read conform to reader at some point. |
Thanks @joa, I find this feature very interesting. Regarding the proposed changes I agree with @iSchluff. We are going to change Read/Write methods so they conform to io.Reader and io.Writer interfaces then, @joa, please use a separated read call for this functionality. Other than that proposed change looks good to me. |
By the way, I was expecting comments about Read/Write related change (io.Reader/io.Writer) but, as nothing arrived, I am going to publish the pending change. |
Cool. Given the changes to make SrtSocket conform to io.Reader I will adapt the MR. Do you have a preference for the method name? |
What about ReadMsg? It would be nice also that:
What do you think? |
Hey folks, let me know what you think. I did add SRT_MSGCTRL as its own struct as well as providing |
I think having a ReadMsg call is great, but this requires an extra allocation on every read, so I don't like Read calling ReadMsg so much. Maybe just deduplicate the epoll portion into a function and keep the actual read calls separate? |
@iSchluff Do you think that However I did produce a benchmark with the changes as you proposed. There is one additional allocation. In general, there's no mensurable difference in performance.
|
I think read is useful even for live because not everybody needs the srt-timestamps. Your benchmark is a bit misleading because srt limits the rate you can read at. But I tested a version without calling srt and apparently the ctrl struct is allocated on the stack so thats fine.
|
I think we can agree to disagree here. Real world performance is more important IMHO. Further does an artificial benchmark not include all the side-effects that will have an influence on def-use chains, inlining decisions and so on. The compiler will perform different optimizations here. I don't know if the struct is in this particular case only stack allocated because your methods are small enough so they are inlined and dead code elimination will remove everything. In fact, I think you benchmark effectively only the method call overhead plus
I did change the SrtMsgCtrl parsing also during the benchmarks. The signature is also more in line with that you've shown so that escape analysis can potentially prove the struct doesn't need to be heap allocated.
I will resolve conflicts and add the remaining change. |
Why not let the calling application hand the struct over as a pointer, that way it could statically alloc it once, and reuse it forever, stack allocs are still a form of allocations, and I prefer as close as possible to 0 when I'm pushing hundreds of mbits/s through my applications as that is in the tens of thousands of packets per second. Also for clarity: could you reorder the functions in the PR? It would make the diff more readable. |
Clients receiving data from an SRT socket need at minimum functionality that exposes the srctime of a packet as well as the SRT clock. With this change in place one can write code that will replay the packets as they were coming in.
I've tested this using srtgo with v1.4.3 from Haivision/srt and expect it to work with v1.4.1 as well.