Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shared memory for multiple processes on same machine. #8

Open
missinglink opened this issue Nov 16, 2016 · 1 comment
Open

shared memory for multiple processes on same machine. #8

missinglink opened this issue Nov 16, 2016 · 1 comment

Comments

@missinglink
Copy link
Contributor

is it possible to share the libpostal memory between two different nodejs processes calling require('node-postal') on the same machine?

calling require('node-postal') uses a fair chunk of RAM so having two different services on the same machine using node-postal consumes more RAM than maybe it needs to?

I'm assuming that the memory is read-only so would it be possible to share that memory between processes?

@albarrentine
Copy link
Contributor

Not without re-architecting a few parts of libpostal. require('node-postal') reads the model files from disk and creates the necessary in-memory data structures for libpostal using malloc. To share memory between processes in UNIX you're almost always talking about mmap. Parts of the said model files like the arrays/matrices should be mmap-able, but because of the way we store numeric types on disk (endian-agnostic, floats/doubles stored as their uint32/uint64 representations and converted on read), and the fact that mmap would only provide access to the raw bytes, it would require quite a bit of refactoring apart from just the I/O functions.

In any case, reducing memory should be relatively easy to accomplish at the application level by designating one process per machine to load libpostal and communicate with other processes through a named pipe, a TCP socket, something like ZeroMQ, Redis, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants