The dawn of a new port #818
Replies: 3 comments 5 replies
-
Oh, by the way. We could also use a chunk with a user-header to implement a dynamically growing vector or string. The user-header would contain all the methods, a relocatable pointer to the payload and a pointer to a |
Beta Was this translation helpful? Give feedback.
-
Nice write-up @elBoberido thanks! You've convinced me to use the One other idea: |
Beta Was this translation helpful? Give feedback.
-
@elBoberido IIRC we had a discussion about a month ago on whether to use the new
What's your take on the idea? cc @budrus |
Beta Was this translation helpful? Give feedback.
-
While thinking about the proposals for the service discovery in #784 I came to the conclusion that we are missing a building block.
Let's assume your application has a status/configuration which doesn't change often or even never changes and has a size of only a few kilobyte at maximum if it changes. Let's also assume you want all other applications be able to read this status and their only interest is the latest status. They do not care if there were status changes since they took the previous update. Currently you need a publisher for the application broadcasting this status and a subscriber for each application which is interested in this data. Furthermore, the publisher can serve quite a lot of subscriber, although it's rarely needed. Actually only for situation were an application wants to share a status/config with many applications. Since we use shared memory, we pay a price with a high memory consumption although it's rarely needed and when it's needed, it doesn't even fulfills the job since RouDi can manage more applications than a publisher can serve. It's like when your only tool is a hammer, every problem looks like a nail.
What we need is a
StatusPort
/ConfigPort
/BroadcastPort
. Subsequently I will refer to it asStatusPort
. This port has the following properties:StatusPort
(with a persistent property), set the data and then stopWhile this is not zero copy, when the data is small, it's even faster than the zero copy approach with publisher and subscriber, saves memory and is accessible by all applications.
Potential applications:
With the
StatusPort
we could reduce the number of subscribers a publisher can serve to e.g. 42 (currently 256). This would result in smaller ports and less cache trashing, which has the potential to even speed things up for publish-subscribe. If it's really necessary to have publish-subscribe with more than these number of ports, we could refactor the publisher ports a little bit. Instead of having theChunkDistributor
as part of theChunkSender
, aChunkSender
could have a vector of pointer toChunkDistributors
. TheChunkDistributors
would live in a pool and once theChunkDistributor
cannot hold anotherChunkQueue
, aChunkDistributor
will be obtained from the pool and added to the vector when a new subscriber is acquired. While this would also solve some problems aStatusPort
would solve, aStatusPort
still has advantages compared to publish-subscribe for some use cases.A
StatusPort
would basically look like thisIf an application has a static configuration to share (no matter how large it is) or needs to update a status to many applications (let's say < 1kB), the
StatusPort
is much faster than aPublisher
/Subscriber
combination.@budrus @mossmaurice @MatthiasKillat @elfenpiff what do you think?
Edit: fixed some findings from MatthiasKillat in the example code
Beta Was this translation helpful? Give feedback.
All reactions