[
https://issues.apache.org/jira/browse/PROTON-1910?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16572136#comment-16572136
]
Alan Conway commented on PROTON-1910:
-------------------------------------
New thought: From a bit of reading it seems the main issue with CGO is that C
calls can't be made with Go's tiny stacks, so they have to be executed on a
native thread, which messes up Go's normal scheduling. The electron/proton
libraries are already designed to serialize C calls to a dedicated
goroutine-per-connection, since the C library isn't thread safe.
It's interesting that the pn_message and marshal/unmarshal-related calls you've
identified are the only ones that *don't* happen in that dedicated goroutine -
each message is an independent data object. So perhaps if we make all the
Message methods operate on native Go data, and defer the required C calls to
the proton goroutine, that might help Go schedule them efficiently.
Don't know when I'll get time to try it but it seems the most promising
approach.
> Profiling indicates that cgo becomes a bottleneck during scale testing of
> electron
> ----------------------------------------------------------------------------------
>
> Key: PROTON-1910
> URL: https://issues.apache.org/jira/browse/PROTON-1910
> Project: Qpid Proton
> Issue Type: Bug
> Components: go-binding
> Affects Versions: proton-c-0.24.0
> Reporter: Aaron Smith
> Assignee: Alan Conway
> Priority: Major
>
> While performing scale testing, detailed profiling of Go test clients showed
> that >95% of the execution time can be devoted to the cgo call. The issues
> seems to be related on sends to the NewMessage() call. For receives, the
> bottleneck is both NewMessage() and the call to actually receive the message.
>
>
> This behavior is not unexpected as CGO is a well-known bottleneck. Would it
> be possible to have a NewMessage() call that return multiple messages and a
> recv call that took an "At most" argument. i.e. recv(10) would receive 10 or
> fewer messages that might be waiting in the queue. Also, it would be nice to
> be able to trade latency for throughput in that the callback wasn't triggered
> until N messages were recieved (with timeout)....
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]