Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

plumbing: cache, modify cache to delete more than one item to free space #720

Merged

Conversation

jfontan
Copy link
Contributor

@jfontan jfontan commented Jan 16, 2018

The previous version could only delete the oldest used object. If the
object to cache was bigger than the space freed it could not be added.

Also the decoder adds bases to the cache when they are needed.

This change increases the speed creating indexes 2x.

The previous version could only delete the oldest used object. If the
object to cache was bigger than the space freed it could not be added.

Also the decoder adds bases to the cache when they are needed.

This change increases the speed creating indexes 2x.

Signed-off-by: Javi Fontan <jfontan@gmail.com>
@@ -55,18 +55,14 @@ func (c *ObjectLRU) Put(obj plumbing.EncodedObject) {
return
}

if c.actualSize+objSize > c.MaxSize {
for c.actualSize+objSize > c.MaxSize {
Copy link
Contributor

@ajnavarro ajnavarro Jan 16, 2018

Choose a reason for hiding this comment

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

Should we check if the object to add is bigger than the cache size to do not remove everything?

Copy link
Contributor

Choose a reason for hiding this comment

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

nevermind, is already checked before the for.

@mcuadros
Copy link
Contributor

Will be nice have a test here.

Signed-off-by: Javi Fontan <jfontan@gmail.com>
Signed-off-by: Javi Fontan <jfontan@gmail.com>
@mcuadros mcuadros changed the title Modify cache to delete more than one item to free space plumbing: cache, modify cache to delete more than one item to free space Jan 16, 2018
@mcuadros mcuadros merged commit e9247ce into src-d:master Jan 16, 2018
jfontan added a commit to jfontan/old-go-git that referenced this pull request Jan 24, 2018
Resolving cycles relied on ObjectToPack objects having Original. This
is no longer true with the changes from src-d#720. This commit changes:

* Save original type, hash and size in ObjectToPack
* Use SetObject to set both Original and resolved type, hash and size
* Restore original object before using BackToOriginal (cycle resolution)
* Update encoder test to check this case

Signed-off-by: Javi Fontan <jfontan@gmail.com>
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants