Commit graph

373 commits

Author SHA1 Message Date
Martin Bremmer
5a8197fa2b Rudimentary process management.
Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
386d5d3029 remove Lease element from test config
The element has long been meaningless and got deprecated in commit
c3dca32a2f.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
8c6055f92c initial version of permance/network check tool
The current situation for performance measurements and checking network
behaviour is rather unsatisfactory, as the only tools available are
``pubsub`` and the ``roundtrip`` and ``throughput`` examples.  The first
can do many things thanks to its thousand-and-one options, but its
purpose really is to be able to read/write arbitrary data with arbitrary
QoS -- though the arbitrary data bit was lost in the hacked conversion
from the original code.  The latter two have a terrible user interface,
don't perform any verification that the measurement was successful and
do not provide the results in a convenient form.

Furthermore, the abuse of the two examples as the primary means for
measuring performance has resulted in a reduction of their value as an
example, e.g., they can do waitset- or listener-based reading (and the
throughput one also polling-based), but that kind of complication does
not help a new user understand what is going on.  Especially not given
that these features were simply hacked in.

Hence the need for a new tool, one that integrates the common
measurements and can be used to verify that the results make sense.  It
is not quite done yet, in particular it is lacking in a number of
aspects:

* no measurement of CPU- and network load, memory usage and context
  switches yet;
* very limited statistics (min/max/average, if you're lucky; no
  interesting things such as jitter on a throughput test yet);
* it can't yet gather the data from all participants in the network
  using DDS;
* it doesn't output the data in a convenient file format yet;
* it doesn't allow specifying boundaries within which the results
  must fall for the run to be successful.

What it does verify is that all the endpoint matches that should exist
given the discovered participant do in fact come into existence,
reporting an error (and exiting with an exit status code of 1) if they
don't, as well as checking the number of participants.  With the way the
DDSI protocol works, this is a pretty decent network connectivity check.

The raw measurements needed for the desired statistics (apart from
system-level measurements) are pretty much made, so the main thing that
still needs to be done is exploit them and output them.  It can already
replace the examples for most benchmarks (only the 50%/90%/99%
percentiles are still missing for a complete replacement).

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
053229e508 missing m_observer_lock on (re)setting statuses
Most of the places where the status flags were reset, this happened
without holding m_observer_lock protecting these status flags.  For most
of these statuses, they are only ever set/reset while also holding the
entity lock, but this is not true for all of them (DATA_AVAILABLE for
example), and thus there are some cases where retrieving the status
could lead to losing the raising of a (at least a DATA_AVAILABLE)
status.

The problem was introduced in ba46cb1140.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
d8cfececae Fix DATA_AVAILABLE race condition
The DATA_AVAILABLE status was reset by read and take while holding the
upper-layer reader lock, but after completing the read/take operation on
the RHC.  As data can be written into the RHC without holding the
upper-layer reader lock, new data could arrive in between the
reading/taking and the resetting of the DATA_AVAILABLE status, leading
to a missed detection.  Resetting DATA_AVAILABLE prior to accessing the
RHC solves this.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
410e0afb3b remove "Error occurred on locking entity" messages
Those should not be printed to stderr (or wherever), there are errors
returned in these cases ...

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
e350aa903c suppress EHOSTUNREACH and EHOSTDOWN errors in log
Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
986db690b8 always append 0 byte to user/group/topic data
Changes the semantics of dds_qget_{user,group,topic}data to always
append a 0 byte to any non-empty value without counting it in the size.
(An empty value is always represented by a null pointer and a size of
0).  The advantage is that any code treating the data as the octet
sequence it formally is will do exactly the same, but any code written
with the knowledge that it should be a string can safely interpret it as
one.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
712ca3149f move util library into ddsrt
As was the plan with the introduction of ddsrt; this includes renaming
the identifiers to match the capitalization style and removes old junk.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
42500e7fb8 add participant instance handle to builtin topics
Extend the endpoint built-in topic data with the participant instance
handle (the GUID was already present).  Having the instance handle
available makes it trivial to look up the participant, whereas a lookup
of the GUID is rather impractical.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
f12b36e112 add setter for partition QoS for a single name
This adds dds_qset_partition1 as a convenience function to set the
partition QoS to a single name.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
e6f35cdab8 publish built-in topics prior to matching
The built-in topics for readers and writers should be published before a
subscription or publication matched listener is invoked, otherwise the
instance handle provided to the listener is not yet available in a
reader for the corresponding topic.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
14148aceb5 add QoS to ignore local readers/writers (#78)
Adds a new "ignorelocal" QoS to the readers/writers to ignore local
matching readers/writers, with three settings:

* DDS_IGNORELOCAL_NONE: default
* DDS_IGNORELOCAL_PARTICIPANT: ignores readers/writers in the same
  participant
* DDS_IGNORELOCAL_PROCESS: ignores readers/writers in the same process

These can be set/got using dds_qset_ignorelocal and
dds_qget_ignorelocal.

If a matching reader or writer is ignored because of this setting, it is
as-if that reader or writer doesn't exist.  No traffic will be generated
or data retained on its behalf.

There are no consequences for interoperability as this is (by
definition) a local affair.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
6e2068173a crash invoking data available on built-in reader
The DDSI reader/writer pointers are now returned as out parameters
instead of as a return value, so that the upper-layer reference is set
before any listener can be invoked.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
c891fdc685 block signals in ddsrt_thread_create
Signal handling in multi-threaded processes is bad enough at the best of
times, and as we don't really use any signals in the Cyclone code, it
makes more sense to create all threads with most signals blocked.  That
way an application that wants to handle signals using sigwait() need not
block all signals prior to creating a participant.

Note that instead of blocking all signals, we block all except SIGXCPU.
The reason is that the liveliness monitoring and stack trace dumping
code currently relies on that signal.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
59270173dc remove dds_rhc_fini abomination
It was called strangely early in the deleting of the reader, even before
the DDSI reader was no longer being accessed by other threads.  The
immediate and obvious problem is that it resets the pointer to the
upper-layer entity even though this can still be dereferenced in
invoking a listener, resulting in a crash.

Secondly it blocks until there are no listener calls any more (and the
resetting of that pointer will prevent any further listener
invocations), but a similar piece of logic is already in generic entity
code that resets the mask and then waits for all listener invocations to
complete.  Having both is a problem.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
e085130a39 fix deadlock between listener, deleting reader, &c
If a (proxy) writer delivers data to a reader that has a data_available
listener calling read/take while that reader is being deleted, blocked
in set_listener waiting for the listeners to complete, then a deadlock
can occur:

* listener calling read/take then attempt to lock reader;
* deleting the reader locks the reader, then waits for the listeners to
  complete while holding the lock

This commits unlocks the reader before waiting for the listeners to
complete.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
1dad5d6493 add dds_entity_release counterpart to entity_claim
Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
7382c682de eliminate clang static analyzer false positive
Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
7f5c56e819 defer triggering dqueue thread until end-of-packet
There appears to be a minor performance benefit to not waking up the
delivery thread (if used) immediately upon enqueueing the first sample,
but rather to wait (typically) until the end of the packet.  In a
latency measurement it probably makes little difference: one shouldn't
use asynchronous delivery if one needs the lowest possible latency, and
the end of the packet is reached rather quickly normally.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
21a1c4aa33 enable printf format checking for dds_log
Also remove superfluous parameters in a TRACE statement and fix a format
specification in pong.c.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
bb7373b90d nestable calls to thread_[state_]awake
Remove all the "if asleep then awake ..." stuff from the code by making
awake/asleep calls nestable, whereas before it "awake ; awake" really
meant a transition through "asleep".  This self-evidently necessitates
fixing those places where the old behaviour was relied on upon, but
fortunately those are few.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
7d281df24a lift limits on handle allocation and reuse (#95)
The old entity handle mechanism suffered from a number of problems, the
most terrible one being that it would only ever allocate 1000 handles
(not even have at most 1000 in use at the same time).  Secondarily, it
was protected by a single mutex that actually does show up as a limiting
factor in, say, a polling-based throughput test with small messages.
Thirdly, it tried to provide for various use cases that don't exist in
practice but add complexity and overhead.

This commit totally rewrites the mechanism, by replacing the old array
with a hash table and allowing a near-arbitrary number of handles as
well as reuse of handles.  It also removes the entity "kind" bits in the
most significant bits of the handles, because they only resulted in
incorrect checking of argument validity.  All that is taken out, but
there is still more cleaning up to be done.  It furthermore removes an
indirection in the handle-to-entity lookup by embedding the
"dds_handle_link" structure in the entity.

Handle allocation is randomized to avoid the have a high probability of
quickly finding an available handle (the total number of handles is
limited to a number much smaller than the domain from which they are
allocated).  The likelihood of handle reuse is still dependent on the
number of allocated handles -- the fewer handles there are, the longer
the expected time to reuse.  Non-randomized handles would give a few
guarantees more, though.

It moreover moves the code from the "util" to the "core/ddsc" component,
because it really is only used for entities, and besides the new
implementation relies on the deferred freeing (a.k.a. garbage collection
mechanism) implemented in the core.

The actual handle management has two variants, selectable with a macro:
the preferred embodiment uses a concurrent hash table, the actually used
one performs all operations inside a single mutex and uses a
non-concurrent version of the hash table.  The reason the
less-predeferred embodiment is used is that the concurrent version
requires the freeing of entity objects to be deferred (much like the
GUID-to-entity hash tables in DDSI function, or indeed the key value to
instance handle mapping).  That is a fair bit of work, and the
non-concurrent version is a reasonable intermediate step.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
069688bb76 fix trace print of tkmap_instance address
Fix the trace to contain a print of the address of the tkamp_instance
(along with the instance id), rather than the address of the stack
variable pointing to the tkmap_instance.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
a94a2296fe install core/ddsi and util header files
Some of the former are required to implement alternative serialisation
methods; the latter is just generally useful. For the time being these
are not part of the formal API and not subject to backwards
compatibility. Still, they have value for quickly building tools on that
use Cyclone and happen to need any of these functions.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
9bfac607a4 move MT19937 random generator to ddsrt
Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
83f3a51a47 small performance improvement in RHC
The introduction of properly functioning query conditions adds some
overhead, this commit removes some of that cost by avoiding some calls
to update_conditions when there are no query conditions.

It also removes the has_changed field from the instance, instead using a
local boolean to track whether DATA_AVAILABLE should be raised or not.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
19a3f6bcad fix race: delete reader & delete writer (#159)
Adding and removing reader/writer matches can be done by multiple
threads, and this can result in two threads simultaneously trying to do
this on a single reader/writer pair.  The code therefore always checks
first whether the pair is (not) matched before proceeding.

However, removing a reader from a proxy writer had part of the code
outside this check.  Therefore, if both entities are being deleted
simultanously, there is a risk that local_reader_ary_remove is called
twice for the same argument, and in that case, it asserts in one of them
because the reader can no longer be found.  The counting of the number
of matched reliable readers suffers from the same race condition.

This commit eliminates these race conditions by moving these operations
into the block guarded by the aforementioned check.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Jeroen Koekkoek
47ba0ba8c6 Remove JAVA_HOME regarding registry from .travis.yml
Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
2019-05-23 18:51:23 +02:00
Jeroen Koekkoek
2700dce0eb Remove dependency on jdk8 Chocolatey package
Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
2019-05-23 18:51:23 +02:00
Erik Boasson
58f21af36e set DATA_AVAILABLE when deleting writer (#148)
Deleting a writer causes unregisters (and possibly disposes) in the rest
of the network, and these updates to the instances should trigger
DATA_AVAILABLE.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
d4f8456479 ignore data until a heartbeat is received (#146)
When data arrives before a heartbeat has been received, it is impossible
to know whether this is a new "live" sample or a retransmit, and for
this reason the requesting of historical data is delayed until a
heartbeat arrives that informs the readers of the range of sequence
numbers to request as historical data.

However, by this time, and without this new condition in place, the
reader may have already received some data directly, and may
consequently request some data twice.  That's not right.

Requiring a heartbeat to have been received before delivering the data
avoids this problem, but potentially delays receiving data after a new
writer/reader pair has been matched.  The delay caused by a full
handshake at that point seems less bad that the odd case of stuttering
where that isn't expected.  There are almost certainly some tricks
possible to avoid that delay in the common cases, but there are more
important things to do ...

Best-effort readers on a reliable proxy writer are a bit special: if
there are only best-effort readers, there is no guarantee that a
heartbeat will be received, and so the condition does not apply.  This
commit attempts to deal with that by only requiring a heartbeat if some
reliable readers exist, but that doesn't allow a smooth transition from
"only best-effort readers" to "some reliable readers".

One could moreover argue that this condition should not be imposed on
volatile readers (at worst you get a little bit of data from before the
match), but equally well that it should (there's no guarantee that no
sample would be skipped in the case of a keep-all writer, if the first
sample happened to be a retransmit).

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Jeroen Koekkoek
c38d9761f3 Move md5 from ddsi to ddsrt
Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
2019-05-23 18:51:23 +02:00
Jeroen Koekkoek
4200f9a846 Fix format strings and signatures for fixed size integers
Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
2019-05-23 18:51:23 +02:00
Erik Boasson
79d0e1a43c ignore all-zero durability service QoS in SEDP
For compatibility with TwinOaks CoreDX, ignore an all-zero durability
service QoS received over SEDP for volatile and transient-local
endpoints.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Martin Bremmer
2c878c3c62 Cleanup log tests.
Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
f0fdde1345 remove rmbias_and_adjust assert on threadid (#121)
The introduction of multiple receive threads could trigger the assertion
because a set of samples ready for delivery may have been received by
multiple threads (the problem manifests itself most easily with
fragmented samples). This is actually a non-issue:

* while synchronously processing a packet, there is a bias of 2**31
  added to the refcount, to prevent any thread under any circumstance
  from ever freeing the data;
* while data lives in the defragment buffers or reorder buffer of the
  proxy writer, a bias of 2**20 is added to it until this particular
  function is called, after delivery of the data to the readers, and
  (if needed) after inserting the samples in the reorder buffer of
  any readers that are out-of-sync with the proxy writer;
* the relevant refcount is updated atomically in such a manner that this
  particular operation atomically removes the bias and performs the
  delayed increment of the refcount to account for the data being stored
  in any of the defragmenting or reorder buffers;
* the only ordinary decrementing of the refcount happens either
  synchronously (if synchronous delivery is chosen), or asynchronously
  in a delivery queue thread, and so the entire mechanism exists to
  avoid premature freeing of the underlying data because the data is
  delivered very quickly (possibly synchronously);
* as the biases are removed after all the delayed refcount increments
  are taken into account and there are no increments following the call
  to rmbias_and_adjust, the "ordinary" decrements can do no harm.
* the case of data from multiple writers being combined in a single
  packet is dealt with by the 2**20 bias, and so there is potentially a
  problem if there are more than 2**20 out-of-sync readers attached to
  a single proxy writer, or data submessages from more than 2**11
  writers in a single packet. The minimum possible data message is 32
  bytes (headers, encoding, data, padding), so packets up to 64kB are
  safe.

None of this is in any way related to which threads originally accepted
the packets, and therefore I see no argument for the existence of the
assertion.

That said, it is a rather complicated mechanism of unknown benefit, and
a major simplification is definitely something to be considered. In UDP
mode I see no chance of abuse, but there may be network protocols (TCP,
for sure) where there might be packets larger than 64kB and those could,
under worst-case assumptions, cause trouble. That, too, is a reason to
rethink it.

The call to rmbias_and_adjust was sometimes called with the proxy writer
locked, and sometimes after unlocking it. This commit changes it to
consistently call it with the lock held.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
371a9cf107 clarify "spdp" token in AllowMulticast option
Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
73ec5beef4 gracefully handle a too small ReceiveBufferSize
Sizing/ReceiveBufferSize must be >= Sizing/ReceiveBufferChunkSize + N
for some small N, and if it is not, Cyclone will crash reading beyond
allocated memory in a nasty way. Ordinarily this should be handled by
the configuration validation, but that would put the burden of knowing
the details of computing N upon the user, an unreasonable requirement.

The old state of an assertion presupposes a check, and brings us back
that same requirement.

Thus, a change to ensure that ReceiveBufferSize will be taken as the
minimum of the configured value and the actual minimal value as
determined by ChunkSize and whatever N happens to be.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
bfe44a9785 avoid debmon thread shutdown logging write errors
During shutdown, the optional "debmon" thread for getting some
information about internal state of the DDSI stack had a tendency to run
into errors from calling write on a connection that had already been
closed immediately after connecting successfully to wake the thread.

Instead of blindly writing into the connection, it now checks whether it
is supposed to shutdown before doing anything, avoiding this particular
problem.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
dc0ebb55ff trace correct thread id during thread creation
The rewrite of the abstraction layer changed some details in thread ids
used in tracing and functions to get those ids, with a result of always
printing the parent thread's id in create_thread rather than the newly
create thread's id. As all supported platforms use thread names in the
trace, it is a rather insignificant matter, and so this provides the
trivial fix by letting the new thread log the message.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
Erik Boasson
cb0d1a9e50 timely initialization of builtin topics (#138)
The rtps_init function used to initialize all data structures and start
all threads used by the protocol stack, allowing discovery of remote
entities before the built-in topic data structures were initialized.
(Very) early discovery of a remote participant thus led to a crash.

This commit splits the initialisation, providing a separate function for
starting, in particular, the threads receiving data from the network.
In terms of threads created, it matches exactly with the rtps_stop /
rtps_fini split that already existed to address the exact same problem
on termination.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-23 18:51:23 +02:00
eboasson
b9406b2dee
Merge pull request #136 from martinbremmer/udpwrite2
Possible assert when ddsi socket write fails.
2019-03-26 10:10:22 +01:00
Martin Bremmer
71f0fa5252 Fixed ddsi connection writes return values.
Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>
2019-03-25 16:12:56 +01:00
eboasson
758bdb4b8f
Merge pull request #134 from eboasson/ddsrt-oi
Some minor things from issues and restoring OpenIndiana support
2019-03-25 12:58:47 +01:00
Erik Boasson
3faf5f45f6 enable expensive checks in CI builds
Signed-off-by: Erik Boasson <eb@ilities.com>
2019-03-23 15:40:29 +01:00
Erik Boasson
fcb6b935ea support for building/running on OpenIndiana
Signed-off-by: Erik Boasson <eb@ilities.com>
2019-03-23 15:40:29 +01:00
Erik Boasson
7540ac8229 make expensive checks in asserts optional (#125)
This adds an Internal/EnableExpensiveChecks setting for enabling some or all expensive run-time checks to avoid a massive slowdown when assertions are enabled at compile-time. Currently these cover only the writer and reader-history cache checking.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-03-23 15:40:29 +01:00
Erik Boasson
a39701fc2e allow configuration input (typically CYCLONEDDS_URI) to include XML fragments
The configuration handling already allowed specifying multiple files in CYCLONEDDS_URI to be read in-order, this extends the behaviour to also allow the contents of these files to be embedded. This makes it possible to set a configuration without requiring a file system, or to add some ad-hoc options.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-03-23 15:40:29 +01:00
Erik Boasson
15a3d7d3ad make it possible to retrieve buffer position after parsing XML
Signed-off-by: Erik Boasson <eb@ilities.com>
2019-03-23 15:40:29 +01:00