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

Support for dumped memory representations #24

Open
cher-nov opened this issue Oct 17, 2024 · 0 comments
Open

Support for dumped memory representations #24

cher-nov opened this issue Oct 17, 2024 · 0 comments
Assignees

Comments

@cher-nov
Copy link
Owner

cher-nov commented Oct 17, 2024

Data structures, or special versions of them, should be able to be written to a memory buffer in such a way that they can be loaded from there using a regular pointer cast (that is, without an explicit deserialization stage). This will allow them to be built at compile-time, embedding the preprocessed contents directly into the program executable file to reduce loading time.

It is important to note that this does not apply to loading from files or retrieving over the network due to endianness considerations and other architectural peculiarities on different machines. This requires full-fledged serialization, which goes beyond the scope of the library itself and thus must be implemented separately (that's why internals are exposed here).

Some quick and important observations that should be explored in more detail later:

  1. Implicit data structures and open addressing. One of the clear problems raised here is how nodes should reference each other in a way that is efficient and does not require post-processing when loading and/or saving. Using absolute addresses implies either a fixed memory address at load time, or the use of relocations - both of which are insane and lead to an excessive dependence on the linker. Therefore, so far it looks like some kind of mechanism with pool allocation and relative addressing from the node or the pool itself.

  2. Immutable vs mutable. For example, a mutable binary tree stored in an array requires a layout of $2^n - 1$ elements (where $n$ is the height) to be always allocated, even if it is sparse and many nodes simply do not exist. But this is not necessary for an immutable tree.

https://30fps.net/pages/clean-pointer-serialization/

@cher-nov cher-nov self-assigned this Oct 17, 2024
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

1 participant