-
Notifications
You must be signed in to change notification settings - Fork 98
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
Motoko Data Inspection #4705
Open
luc-blaeser
wants to merge
20
commits into
master
Choose a base branch
from
luc/data-inspection
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Motoko Data Inspection #4705
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Very cool! |
I wonder if leb encodings would compress stuff quite a bit... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motoko Data Inspection
Note: This is still a prototype, not yet ready for merging.
Generic data inspection of Motoko canisters by authorized users.
Your Motoko Program is a Database!
This is only a small first step towards the bigger vision of providing data tooling to Motoko, similar to a database management system. This would support data inspection, data queries, maybe even data modification, data backup/restore, complex data migration, and/or administrative functionality.
Frontend Prototype
A simple frontend is available to test the data inspection, see https://github.com/luc-blaeser/data-inspector (limited access).
Backend Design
The Motoko runtime system is extended to stream the heap state to the frontend canister for displaying the data to authorized users.
Currently, the following design aspects apply to the data inspection in the Motoko runtime system:
Binary format (EBNF)
The object payload is organized as follows:
Object
, the object size is prepended because the hash blob cannot directly belocated in the stream.
object_id
are potentially synthetic identifiers of an objects. The ids are skewed,to distinguish them from scalars. Currently, the
object_id
are heap pointers butthis would change with incremental inspection.
usize
is 64-bit little endian.Implementation
bitmap is independent of the potentially other bitmaps used during incremental GC.
temporarily store slicing information stored during the incremental GC.
inspection.
stores the array slicing information of the heap inspection, independent of the
incremental GC.
The buffer is represented as a linked list of blobs that is finally copied to a combined
single blob. This is because the size of the live set is not known in advance.
Future: Incremental Inspection
Incremental inspection can be realized in the future for scalability to larger heaps:
messages. This is particularly important because the message response size is limited.
without needing to refetch the full heap.
Possible implementation:
This is because objects are moved by the GC.
for marking during heap traversal, such that a mark bitmap would no longer be needed.
The pointers in the map are weak pointers that are updated by the GCs but will be removed
from the map if the object is collected.
pointers have been traversed. Otherwise, their state need to be transmitted on a
subsequent download message.
The pointers in the pending list are weak.
during a heap inspection session. The pointers of modified objects are recorded in a
hash set, similar to the remembered set of the generational GCs. Again the pointers are
treated as weak pointers.
the hash set in addition to a potentially next heap chunk of the pending list.
The hash set is eventually cleared and the sent objects are removed from the pending list.
are added.