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

Optimize graph object buffering and flushing #395

Merged
merged 26 commits into from
Dec 18, 2020

Conversation

austinkelleher
Copy link
Contributor

@austinkelleher austinkelleher commented Dec 16, 2020

Overview

The motivation of this change is to allow our FileSystemGraphObjectStore to buffer more data in memory before performing a flush.

Previously Implementation Details

Whenever we called jobState.findEntity, jobState.iterateEntities, or jobState.iterateRelationships, a flush would be performed. Multiple steps are typically running at the same time in an integration. This means that flushing is happening all of the time.

New Implementation Details

We now have two in-memory graph object lookup tables:

A = Map<Graph Object _key, Graph Object>
B = Map<Graph Object _type, Map<Graph Object _key, boolean>>

When we perform a jobState.findEntity, we first check map A to see if we have this graph object buffered in memory. If we do not, then we perform our traditional lookup on disk. (There is actually more we can do to optimize this. See here: #385 (comment))

When we perform a jobState.iterateEntities or a jobState.iterateRelationships, we first iterate over the data we have buffered in map B, then we perform our traditional disk file iteration method.

Copy link
Contributor

@ndowmon ndowmon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @austinkelleher, thanks for this improvement!

Copy link
Contributor

@ctdio ctdio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small change requested regarding some commented out code. Otherwise this looks pretty good!

ndowmon
ndowmon previously approved these changes Dec 16, 2020
Copy link
Contributor

@ndowmon ndowmon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

ctdio
ctdio previously approved these changes Dec 16, 2020
Only write prettified files to the file system on local collection
Share graph object creation test utils across tests and cleanup
Support for continuous integration data uploads
@austinkelleher austinkelleher dismissed stale reviews from ctdio and ndowmon via b2b44c3 December 16, 2020 18:28
ctdio
ctdio previously approved these changes Dec 16, 2020
ndowmon
ndowmon previously approved these changes Dec 16, 2020
) {
await this.flushRelationshipsToDisk();
await this.flushRelationshipsToDisk(onRelationshipsFlushed);
}
}

async getEntity({ _key, _type }: GraphObjectLookupKey): Promise<Entity> {
Copy link
Contributor

@mknoedel mknoedel Dec 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought: what information is typically gotten from previous entities? My first thought would be that it would usually only be foreign keys, which is likely just an id. Is it worth considering when we flush InMemoryGraphObjectStore, we maintain a map similar to the implementation of DuplicateKeyTracker. That way we could likely store much more than 500 entities and relationships for most of the use-cases of getEntity.
Maybe we could get lucky and reduce roundtrips to the disk a good amount of the time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are definitely lots of additional caching improvements that we can make!

mknoedel
mknoedel previously approved these changes Dec 17, 2020
Copy link
Contributor

@mknoedel mknoedel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a great improvement!

@austinkelleher austinkelleher dismissed stale reviews from mknoedel, ndowmon, and ctdio via e3d379a December 18, 2020 16:43
ndowmon
ndowmon previously approved these changes Dec 18, 2020
mknoedel
mknoedel previously approved these changes Dec 18, 2020
 - @jupiterone/[email protected]
 - @jupiterone/[email protected]
 - @jupiterone/[email protected]
 - @jupiterone/[email protected]
 - @jupiterone/[email protected]
 - @jupiterone/[email protected]
 - @jupiterone/[email protected]
@austinkelleher austinkelleher dismissed stale reviews from mknoedel and ndowmon via 3cb5160 December 18, 2020 17:53
@austinkelleher austinkelleher merged commit 0a90361 into master Dec 18, 2020
@austinkelleher austinkelleher deleted the 1786-optimize-flushing branch December 18, 2020 17:58
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

Successfully merging this pull request may close these issues.

4 participants