Coder Social home page Coder Social logo

curent / dime Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 4.0 33.12 MB

Distributed Messaging Environment

Home Page: https://ltb.curent.org

License: GNU General Public License v3.0

Python 11.26% C 57.36% Makefile 0.77% MATLAB 13.51% Shell 3.18% Dockerfile 0.46% M 0.85% JavaScript 12.55% Batchfile 0.06%
data-exchange messaging simulation

dime's People

Contributors

jinningwang avatar nparsly avatar thehashtableslasher avatar zmalkmus avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dime's Issues

Add TLS support

I think it's safe to say this program will only be run on trusted networks, but better safe than sorry, right?

Add groups

Make it so, instead of a Matlab client joining with a unique name, it joins a named group. Messages sent to a group are sent to all members of said group. Clients should be able to join more than one group. Optionally, sub-groups (groups of groups) may be an option, but this might be too much to maintain.

Facing issues while running Makefile

Hi Good Morning,

Can anyone please help me in running Makefile. I'm facing following issue.

image

As mentioned in the comment, I uncommented the following lines:
image

I'm using mingw compiler on my system.

Your help will be appreciable.

Thanks.

Add Python client

Something like:

import dime
import numpy as np

d = dime.DimeClient("python", "ipc", "/tmp/dime.sock")

d["a"] = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
d.send_var("python", "a")
del d["a"]
d.sync()

print(d["a"])
# [[1 2 3]
#  [4 5 6]
#  [7 8 9]]

Note that #3 needs to be completed as a dependency. Also, the server should be aware of its clients' platforms, and instruct them to change their serialization method depending on what other types of clients are connected.

Split actual recv() and data parsing in socket

Right now, dime_socket_recvpartial handles both the recv() syscall and interpreting the data from it. However, this could theoretically end up with us getting two messages in one recv() call, and the second message will never be read. These two functionalities need to be split to ensure this doesn't happen

Use thread pool for handling connections

From README.md:

That having been said, multi-threading may not be avoided in the future. A technique used by several HTTP servers to tackle the C10k problem (e.g. Nginx, lighttpd) is to have a fixed-size pool of worker threads that each poll a set of client connections dispatched to them by the main thread. (An excellent article on the I/O performance of threads vs poll/select can be found here.) This approach may be used by this code in the future, if such scalability is desired.

Note that multi-threading would greatly increase the complexity of the server, and might actually make it slower due to locks on tables starving certain threads. Still, for maximum performance and scalability it may be worth considering in the future.

Verbose mode

The run-time flag -v should make the server print additional info about who connected, what messages are sent/received, etc.

Add wait command

Command that tells the clients to block until a variable is queued. When one is queued, send the client a message to unblock.

Add documentation for server

Includes adding Doxygen annotations to source code, and updating README.md with relevant info on compilation/running the server.

DiME starting message

Both ANDES and AGVis have messages when they begin to run. Dime has no such message so it may be confusing for new users to know it has been started.

For example, AGVis has a message appear on run like this:

    _   _____   ___     | Version 3.1.3.post40+g51174f2
   /_\ / __\ \ / (_)___ | Python 3.8.17 on Linux, 07/31/2023 03:57:50 PM
  / _ \ (_ |\ V /| (_-< | 
 /_/ \_\___| \_/ |_/__/ | Web-based geographical visualizer.

Working directory: "/home/zmalk/work/agvis"
AGVis will serve static files from directory "/home/zmalk/work/agvis/agvis/static"
at the URL http://127.0.0.1:8810. Open your web browser and navigate to the URL to access the application.

Starting AGVis... Press Ctrl+C to stop.

dime_socket_t send/recv optimizations

A few things:

  • Buffers for send/recv are allocated dynamically. A static byte array might make more sense if we can ensure a single-threaded, non-reentrant server
  • We can skip a potentially expensive memcpy and read directly from the buffer if the contents therein are contiguous
  • The ring buffers can be shrunk when they are empty

Sending more than one variable with send_var() causes subsequent sync() call to block forever

e.g. running

d = dime('matlab', 'ipc', '/tmp/dime.sock');
d.send_var('matlab', 'a');
d.send_var('matlab', 'b');
 ...
d.send_var('matlab', 'z');
d.sync();

works fine, but

d = dime('matlab', 'ipc', '/tmp/dime.sock');
d.send_var('matlab', 'a', 'b', ..., 'z');
d.sync();

Blocks forever on the last line. The server is receiving extra 'send' commands after 'sync' is called, so I suspect this is a client-side issue.

Resend data when the serialization changes

If the serialization changes during a send_var call, then the clients should resend their data with the new method. Otherwise, clients on the other end may not be able to decode the variables.

Packing DiME

Without packing DiME as a package, it is challenging to install necessary DiME dependencies for users.

DiME has the following dependencies build-essential, autotools-dev, autoconf, and libev-dev, to support the installation of OpenSSL, zlib, and Jansson.

To follow the installation style of ANDES and AMS, it can be better to pack a C project with the necessary dependencies and publish it on Conda and PyPI.

The installation of DiME is expected to be simple, like conda install dime or pip install dime.

Then starting a DiME server in the command line can be like this:

dime --path /tmp/dime --port 8818

Similarly, using DiME in Python can be like this:

import dime

# NOTE: start a DiME server
server = dime.server(path='/tmp/dime', port=8818)

# NOTE: start a DiME client and join a server
client = dime.client(protocol, varargin)
client.join(server)
...

With this feature, we can improve the usability of DiME and integrate AGVis as a built-in visualizer for ANDES and AMS.

Here are some possible references for packing DiME:
Conda documentation on creating and publishing packages
PyPI documentation on creating and publishing packages
Blog post on publishing C libraries on Conda and PyPI
Github repository with example setup.py files for packaging C projects
Conda-forge documentation on building and uploading packages
PyPI documentation on using twine to upload packages

See Interactive use through Python code for more discussion.

Add timeout

It appears sometimes dime likes to run forever when initialized. It would be good to add a timeout of some arbitrary length of time to avoid multiple hidden dime servers running in the background for no reason.

Add IPv6 support

Also, use a dual-stack IPv4/IPv6 socket when supported by the host OS.

Preserve hash table insertion order

Make the hash table implementation preserve the order in which elements are inserted, and iterate through them via that order, similar to Python's collections.OrderedDict. Currently two possible ways of doing this:

  • Create an implicit doubly-linked list within the hash table. Has the issue of maintaining said list when elements are relocated
  • Do what Python does, and split the table into two arrays (one for key-value pairs, and one for lookup based on the hash value). Has issues with locality for pure lookup purposes

Add test Dockerfile

Right now, all the tests are managed by a bunch of shell scripts, and that's becoming a little cumbersome

Fix matlab tests

Changing the workspace from 'base' to 'caller' breaks the current Matlab tests.

Thread-local error string

Ties in with #9 to some extent - a thread-local string unifying errors from Jansson and the C standard library

Add Javascript Websocket support

This was the original plan for #35, but since ltbvis assumes a Chrome browser for proper functionality, and Chrome has non-standard raw TCP socket support, that will be implemented first.

Consider alternate serialization method

Currently, data is marshalled via Matlab's undocumented getByteStreamFromArray and getArrayFromByteStream. Although this is the fastest method for pure Matlab clients, other types of clients (i.e. a Python binding) may exist in the future, (and relying on undocumented functions is as stable and future-proof as a box of moldy dynamite) so an open standard would be preferable. Ideally, the server would send a signal to continue using getByteStreamFromArray/getArrayFromByteStream until a non-Matlab client connects, at which point the alternate marshaller is used.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.