Inspirel banner

Programming Distributed Systems with YAMI4

3.12 Multithreading And Performance Notes

As a general note on multithreading users should take into account that a single parameters object is not intended for concurrent use from multiple threads. In a typical scenario, a parameters object will be created on the stack and will be used by a single thread to send or handle a single message.

It is allowed to pass a single parameters object from one thread to another, but concurrent modifications should be avoided. The object itself is not protected against it and programs should ensure proper protection with additional mechanisms.

There is a trade-off between performance and other goals, in particular the intent to minimize the library footprint.

Technically, in Ada and C++ the parameters object offers linear cost of entry search, which means that it is not appropriate for constructing huge and shallow data sets. Instead, it is recommended to structure the data into deeper but narrow constructs with the help of arrays or nesting. This recommendation can be compared to the general policy of minimizing the number of parameters of a function or procedure, where too many parameters are considered to be a bad design practice. This comparison is very appropriate, because the parameters object is intended to model a signature of the remote operation. In other words, if an imaginary local function with a given list of parameters would be considered ``good'' (with respect to whatever design policy is in use in the project, like ``functions should have less than 10 parameters''), then a YAMI4 parameters object with the equivalent structure will be also appropriate and will perfectly reflect the same policies.

In general, users should not get overly sensitive with the performance aspect of this recommendation, because entry searches are local operations that are performed on the parameters object and are therefore very fast when compared to the cost of the whole typical remote message.

In Java and .NET minimizing the footprint was not the goal and the parameters object uses internal hash map for indexing entries by their names. This means that the cost of entry search in Java and .NET is that of the standard hash map keyed by strings.