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
Stop using (large) PropSubjectMap
items in Index (if possible), speed up update_index
for Commits
#282
Comments
Two possible approaches: Create a
|
Vec
items in Index (if possible)PropSubjectMap
items in Index (if possible)
PropSubjectMap
items in Index (if possible)PropSubjectMap
items in Index (if possible), speed up update_index
for Commits
I went for using |
Since I use
sled
, a KV store, I have to manually create my own index solutions. One of these is theValueIndex
, which storesValues
asKeys
, so I get a reference index. This is like an inverted store. With this, I can quickly find incoming references in resources. Very useful for constructing Collections! So lets say resource A has a reference to resource B, I might want to be able to find incoming references for resource B, without having to iterate over all resources.So the Key (K) here is actually the Value from a normal atom. The V is a
PropSubjectMap
, a HashMap which is a map of Properties and Subjects:This works OK, but does not scale well. Let's consider what happens when we update a Document, and append some new Element to it (a user presses Enter in a document editor). The Commit is parsed by the server, and the server will update the modified resource. After that, an Actor receives a message about this commit, and will update the indexes. We've only updated one Atom (the list of Elements), but since that is a ResourceArray, we'll iterate over every Subject inside that array. For each one, we'll
get_prop_subject_map
, remove the item accordingly, and thenset_prop_subject_map
. Setting and getting are expensive operations, since the entire object has to be fetched, (de)serialized and stored.In total, we're talking about 20ms on my laptop. I think this will get far worse as we have more resources, as getting and setting will become slower the bigger the
PropSubjectMap
items are. Note that some subjects will have a lot of incoming links, such as commonly used Classes, and probably also users.The text was updated successfully, but these errors were encountered: