ava-labs / avalanchego

Go implementation of an Avalanche node.
https://avax.network
BSD 3-Clause "New" or "Revised" License
2.13k stars 670 forks source link

Improve the build system. #118

Closed Determinant closed 4 years ago

Determinant commented 4 years ago

The Gecko project uses libraries written in other languages (crypto and network part in C/C++, for example). Thus it is non-trivial work to have a streamlined build experience as there is no official, feature-rich build system provided by golang. There are, however, some utilities (e.g. gotools) that could be utilized to help put together a customized build logic.

This post serves as an initial overview of dependencies and how packages are currently (as of Apr 30, 2020) organized in Gecko. It will subject to update in the future and the containing discussion thread will continue serving as the summary for all changes planned to the build system.

Important Dependencies

In addition to the go packages imported by Gecko's go code and resolved automatically by gotools, gecko also depends on several Go wrappers for its main functionality.

Current Build Logic

We currently use a basic build script under scripts/build.sh, which:

Principles

While the build system subjects to changes in the future, as the creator, I would humbly suggest we follow the following guidelines or at least keep them in our mind when making changes:

adasari commented 4 years ago

+1

swdee commented 4 years ago

You should consider the comments here https://github.com/ava-labs/gecko/issues/21#issuecomment-607607392 which when written make the build scripts unnecessary as it just integrates with Go's environment and tools.

Since that comment coreth has been established, so at most a simple Makefile could be created to build the multiple binaries; ava, evm, and xputtest.

Determinant commented 4 years ago

I'm aware of the go module support. Yes it is related and hopefully we'll get rid of the manual parts as much as possible. But still there will be some internal build process for salticidae-go, either by Makefile or bash scripts. (Doesn't make a huge difference as salticidae already uses cmake)

danlaine commented 4 years ago

@swdee @adasari @Determinant

I've created a branch of Gecko and salticidae-go that, together, somewhat improve the build process.

The good news:

The bad news:

@swdee I saw your suggestions as to how to simplify the build script. Thanks for those. I agree that it would be better to have Salticidae be installed to the OS library and to have our libraries available on an APT repo, and I would like to make those improvements in the future, but those changes require more developer time. The changes I made are an improvement, but are by no means the end of improving the build process. (Also, if we move to a different networking library this will all be moot, so there's that ;) )

Let me know what you all think, and thanks for your time.

adasari commented 4 years ago

@danlaine This is awesome beginning towards reproducible builds.

  • There is still tight coupling between Gecko, salticidae-go and coreth.

Could you please elaborate ? and name few dependencies ?

  • Go modules aren't compatible with git submodules so I had to copy salticidae into salticidae-go rather than linking it

salticidae is using C/C++. decoupling cmake may solve the problem.i never used cgo. cgo have its own challenges and platform dependencies if i understand it correctly. i will read more on this weekend.

adasari commented 4 years ago

I just read @swdee suggestion , i was referring to similar lines for salticidae with OS build parameters.

swdee commented 4 years ago

@danlaine Interesting comment of moving to a different network library, maybe a Go port of salticidae, or something like https://github.com/perlin-network/noise ?

Determinant commented 4 years ago

@swdee Go is slow in dealing with large amount of short messages. Plus we don't have the leisure of time to rewrite the whole thing in Go. Please move the discussion elsewhere...

danlaine commented 4 years ago

I didn't like the approach I took before to improve the build process so I tried again Changes are here: https://github.com/ava-labs/gecko/compare/go-mod-support-alt

The summary of the changes are:

Downsides:

Thoughts? @swdee @Determinant @StephenButtolph @adasari

Determinant commented 4 years ago

@danlaine Thanks for the effort! I like most part of it except for this: why do we want to let Gecko pull the salticidae? The version of salticidae is highly coupled with salticidae-go, so it makes much much more sense to let salticidae-go pull the correct version of its C++ dep, while Gecko pulls in the correct version of salticidae-go. The other way around that you suggested does more harm than good IMHO.

yilunzhang commented 4 years ago

Go is slow in dealing with large amount of short messages.

@Determinant Just curious, what kind of speed you meant by slow here. A pure Go networking layer can easily handle hundreds of thousands of small raw messages per second (e.g. https://github.com/perlin-network/noise) or close to 100k msg/s even after protobuf marshal/unmarshal, overlay routing and encryption (e.g. https://github.com/nknorg/nnet), more than enough for tens of thousands of TPS.

Determinant commented 4 years ago

@yilunzhang For your curiosity: a typical C++/Rust implementation can easily do over 400k, with hundreds of bytes (say 256) as payload. I don't see there is any value of doing a benchmark with 4 byte string as payload. Plus, apart from other abstraction overhead, GC could be the real problem. There is one thing that I might agree with you, which is go-implemented systems are generally "slow" enough so it does not demand faster messaging. Anyway, we've decided to roll with pure go network implementation. There is no value for further discussion.