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

ingest: Remove mutex from change compactor #4811

Merged
merged 1 commit into from
Mar 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions ingest/change_compactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package ingest

import (
"encoding/base64"
"sync"

"github.com/stellar/go/support/errors"
"github.com/stellar/go/xdr"
Expand Down Expand Up @@ -50,7 +49,6 @@ import (
type ChangeCompactor struct {
// ledger key => Change
cache map[string]Change
mutex sync.Mutex
encodingBuffer *xdr.EncodingBuffer
}

Expand All @@ -70,9 +68,6 @@ func NewChangeCompactor() *ChangeCompactor {
// cache takes too much memory, you apply changes returned by GetChanges and
// create a new ChangeCompactor object to continue ingestion.
func (c *ChangeCompactor) AddChange(change Change) error {
c.mutex.Lock()
defer c.mutex.Unlock()

switch {
case change.Pre == nil && change.Post != nil:
return c.addCreatedChange(change)
Expand Down Expand Up @@ -215,9 +210,6 @@ func (c *ChangeCompactor) addRemovedChange(change Change) error {
// GetChanges returns a slice of Changes in the cache. The order of changes is
// random but each change is connected to a separate entry.
func (c *ChangeCompactor) GetChanges() []Change {
c.mutex.Lock()
defer c.mutex.Unlock()

changes := make([]Change, 0, len(c.cache))

for _, entryChange := range c.cache {
Expand All @@ -229,7 +221,5 @@ func (c *ChangeCompactor) GetChanges() []Change {

// Size returns number of ledger entries in the cache.
func (c *ChangeCompactor) Size() int {
c.mutex.Lock()
defer c.mutex.Unlock()
return len(c.cache)
}