Skip to content

Addressing issue #41 - maxSyncConcurrency environment variable#63

Open
smeyerhot wants to merge 5 commits into
coinbase:masterfrom
smeyerhot:teo/maxsync
Open

Addressing issue #41 - maxSyncConcurrency environment variable#63
smeyerhot wants to merge 5 commits into
coinbase:masterfrom
smeyerhot:teo/maxsync

Conversation

@smeyerhot

Copy link
Copy Markdown

Fixes #41

Motivation

This commit allows users to specify an env variable MAXSYNC which overrides DefaultConcurrency in rosetta-sdk-go.

Solution

The solution was to add a field to the Configuration struct in the same way as Mode and Network. Then used this value when constructing the syncer to override defaults.

Open questions

@smeyerhot smeyerhot changed the title Addressing issue #41 - maxSyncConcurrency enviroment variable Addressing issue #41 - maxSyncConcurrency environment variable Dec 25, 2020
@smeyerhot

Copy link
Copy Markdown
Author

This is a revised PR, same fix but cleared up some issues with the Dockerfile.

Comment thread indexer/indexer_test.go Outdated
Network: bitcoin.MainnetNetwork,
Blockchain: bitcoin.Blockchain,
},
MaxSyncConcurrency: 1,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This will default to 4 but will also cap out there. Might want set back to 256.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

Comment thread configuration/configuration.go Outdated
case "0":
return nil, errors.New("syncer concurrency must be greater than zero")
default:
config.MaxSyncConcurrency, _ = strconv.ParseInt(maxSyncValue, 10, 64)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you should explicitly handle this parsing error

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Handled in new commit.

Note: Allowed for MAXSYNC to not be set and default to 256

Comment thread go.mod Outdated




Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove these extra lines

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

removed

Comment thread indexer/indexer.go Outdated
coinCacheMutex: new(sdkUtils.PriorityMutex),
seenSemaphore: semaphore.NewWeighted(int64(runtime.NumCPU())),
maxSync: config.MaxSyncConcurrency,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: extra line

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

removed

Comment thread configuration/configuration.go Outdated
}
config.GenesisBlockIdentifier = bitcoin.TestnetGenesisBlockIdentifier
config.Params = bitcoin.TestnetParams

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: extra line

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

removed

Comment thread README.md Outdated
#### Mainnet:Online
```text
docker run -d --rm --ulimit "nofile=100000:100000" -v "$(pwd)/bitcoin-data:/data" -e "MODE=ONLINE" -e "NETWORK=MAINNET" -e "PORT=8080" -p 8080:8080 -p 8333:8333 rosetta-bitcoin:latest
docker run -d --rm --ulimit "nofile=100000:100000" -v "$(pwd)/bitcoin-data:/data" -e "MAXSYNC"="256" -e "MODE=ONLINE" -e "NETWORK=MAINNET" -e "PORT=8080" -p 8080:8080 -p 8333:8333 rosetta-bitcoin:latest

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: "MAXSYNC=256"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

Comment thread Dockerfile Outdated
ENV GOLANG_DOWNLOAD_SHA256 9a58494e8da722c3aef248c9227b0e9c528c7318309827780f16220998180a0d
ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: extra line

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

Comment thread Dockerfile

# Copy binary from rosetta-builder
COPY --from=rosetta-builder /app/* /app/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: removed line unnecessarily

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

added back in.

return nil, errors.New("syncer concurrency must be greater than zero")
default:
config.MaxSyncConcurrency = parsedValue
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The expression on line 148 is equivalent to:

!(err == nil || defaultMaxSync)

if we want to change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Allow max concurrency limits configuration on the indexer

2 participants