-
Notifications
You must be signed in to change notification settings - Fork 1
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
Memory saves and deletes. Cache dependant commits. #4
Conversation
@@ -342,13 +400,25 @@ func (ndb *nodeDB) uncacheNode(hash []byte) { | |||
} | |||
} | |||
|
|||
func (ndb *nodeDB) MaxChacheSizeExceeded() bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cacheSize
Thank you for the contribution. It's been a while since I looked at this code and the orphan system. I wish there were more of a design document that explained the previous orphan system, the changes, and the new code with ideally diagrams and prose to make this easy to understand for future maintainers about versioning and orphaning. |
// Saves orphaned nodes to disk under a special prefix. | ||
// version: the new version being saved. | ||
// orphans: the orphan nodes created since version-1 | ||
func (ndb *nodeDB) SaveOrphans(version int64, orphans map[string]int64) { | ||
ndb.mtx.Lock() | ||
defer ndb.mtx.Unlock() | ||
|
||
toVersion := ndb.getPreviousVersion(version) | ||
// When saving a new version, the previous version will always be one less than the new version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens when you save a version (H), delete it (H, so now the latest saved state is H-1), but then you save again? Is it H+1 or H?
ndb.deleteOrphansWithPredecessor(version, predecessor, nil) | ||
} | ||
|
||
func (ndb *nodeDB) deleteOrphansWithPredecessor(version, predecessor int64, unsavedOrphans *map[string]int64) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the purpose of this function w/ the unsavedOrphans arg? It never gets called?
Still updating this idea. This suggests a new paradigm where you don't use orphan except possibly in the most recent blocks. Instead, after deleting old blocks, you can scan the database removing nodes that are not part of a tree anymore. |
Add modified saveVersion and deleteVersions that only change the in-memory tree and don't commit changes to the database.
Add a maxCahce to nodedb, so that data is only written to the disk if the max Cache size is exceeded.