-
Notifications
You must be signed in to change notification settings - Fork 133
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
GraphD: an in-memory Graph Service #312
Open
ericvolp12
wants to merge
11
commits into
main
Choose a base branch
from
graphd
base: main
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
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
ericvolp12
changed the title
GraphD: an in-memory Graph Service
Charybdis: an in-memory Graph Service
Sep 14, 2023
ericvolp12
changed the title
Charybdis: an in-memory Graph Service
GraphD: an in-memory Graph Service
Sep 15, 2023
Made startup go a good deal faster with this: follows := make(map[uint64]map[uint64]struct{})
following := make(map[uint64]map[uint64]struct{})
for fileScanner.Scan() {
if totalFollows%1_000_000 == 0 {
slog.Info("loaded follows", "total", totalFollows, "duration", time.Since(start))
}
// actorDid,rkey,targetDid,createdAt,insertedAt
followTxt := fileScanner.Text()
parts := strings.Split(followTxt, ",")
actorDID := parts[0]
targetDID := parts[2]
actorUID, ok := graph.GetUid(actorDID)
if !ok {
actorUID = nextUID
nextUID++
graph.SetUid(actorDID, actorUID)
graph.SetDid(actorUID, actorDID)
}
targetUID, ok := graph.GetUid(targetDID)
if !ok {
targetUID = nextUID
nextUID++
graph.SetUid(targetDID, targetUID)
graph.SetDid(targetUID, targetDID)
}
totalFollows++
f, ok := follows[actorUID]
if !ok {
f = make(map[uint64]struct{})
follows[actorUID] = f
}
f[targetUID] = struct{}{}
f, ok = following[targetUID]
if !ok {
f = make(map[uint64]struct{})
following[targetUID] = f
}
f[actorUID] = struct{}{}
}
graph.BulkLoad(follows, following) and func (g *Graph) BulkLoad(follows, following map[uint64]map[uint64]struct{}) {
for uid, m := range follows {
g.follows.Store(uid, &FollowMap{data: m})
}
for uid, m := range following {
g.following.Store(uid, &FollowMap{data: m})
}
} |
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.
WIP but GraphD (working title) is an in-memory graph daemon to handle lookups for followers, following, blockers, blocking, muters, muting, etc.
Internally represents relationships between UID-mapped DIDs.
Should be very fast and fairly light on memory, at 42M relationships it's using around 2GB of RAM and can grab 142k followers and resolve them to DIDs in ~20ms.