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

[BOT-API] Build executable binary #43

Open
4TT1L4 opened this issue Apr 19, 2024 · 7 comments
Open

[BOT-API] Build executable binary #43

4TT1L4 opened this issue Apr 19, 2024 · 7 comments
Assignees
Labels
T-Shirt size - Medium High-Level effort estimation. Category "medium effort". Task A feature request or general task involving code changes.

Comments

@4TT1L4
Copy link
Contributor

4TT1L4 commented Apr 19, 2024

Problem:

The Bot API Server is started using cabal run. This is not optimal, since cabal needs to look up some dependencies on every startup:

======[geniusyield-server]======
Startup checks....
SERVER_CONFIG is set and contains a valid YAML document.
====================================
Replace placeholders....
[OK] Done. Replaced placeholders.
+ cabal run geniusyield-server -- serve
====================================
Starting geniusyield-server...
Warning: Requested index-state 2023-06-06T00:00:00Z is newer than
'hackage.haskell.org'! Falling back to older state (2023-06-05T23:38:20Z).
Resolving dependencies...

The process to resolve dependencies on startup takes way to long, adding 20-30 seconds to the startup time.

Solution:

  • Build an executable binary and start this instead of using cabal run to spin up the server.
@4TT1L4
Copy link
Contributor Author

4TT1L4 commented Apr 19, 2024

@sourabhxyz Could you please change the cabal config to provide an executable binary?

@4TT1L4 4TT1L4 changed the title Build executable binary [BOT-API] Build executable binary May 6, 2024
@sourabhxyz
Copy link
Member

@4TT1L4 There shouldn't be an overhead if source files have not changed. The delay that you are seeing is likely due to the time it requires to initialise the Atlas's blockchain provider which in general takes ~30 seconds.

@4TT1L4
Copy link
Contributor Author

4TT1L4 commented May 20, 2024

Could you please add a log message when the initialization starts and finished? Otherwise it is not really possible to tell where the time goes.

I am also not sure if we should be "resolving dependencies" in production. I still think that we should build a binary and distribute this.

cabal run is designed for development purposes. Is there a reason why we should not build an executable binary?

@4TT1L4 4TT1L4 added T-Shirt size - Medium High-Level effort estimation. Category "medium effort". Task A feature request or general task involving code changes. labels May 20, 2024
@sourabhxyz
Copy link
Member

sourabhxyz commented May 21, 2024

cabal run is designed for development purposes. Is there a reason why we should not build an executable binary?

You are free to use static binary, I simply meant that this would not solve the delay issue you are seeing.

Could you please add a log message when the initialization starts and finished? Otherwise it is not really possible to tell where the time goes.

Logging in itself rely on initialisation of provider.

I am also not sure if we should be "resolving dependencies" in production. I still think that we should build a binary and distribute this.

Normally one would use cabal install ... to get the static binary, but it does out-of-tree builds which would break compile time git revision fetch. But one can get the built binary, in build directory (after the execution of cabal build all). For my machine, it is, dist-newstyle/build/aarch64-osx/ghc-9.2.8/geniusyield-server-lib-0.5.0/x/geniusyield-server/build/geniusyield-server.

@4TT1L4
Copy link
Contributor Author

4TT1L4 commented May 22, 2024

You are free to use static binary, I simply meant that this would not solve the delay issue you are seeing.

Thank you for the notice.

Logging in itself rely on initialisation of provider.

Could you please add this? So we could see different events, like: application started, initializing, initialization is finished. If no log messages are logged, then it is not really possible to tell where the time goes.

cabal build all

Thank you for pointing me to the binary and sharing the command. I can try to do the same and locate the binary in the docker container.

I was trying to install it, but install was failing with some error message.

@4TT1L4 4TT1L4 assigned 4TT1L4 and unassigned sourabhxyz May 22, 2024
@sourabhxyz
Copy link
Member

Could you please add this? So we could see different events, like: application started, initializing, initialization is finished. If no log messages are logged, then it is not really possible to tell where the time goes.

Elaborating on my earlier message, to log we require to initialise a provider which takes ~30 seconds. So we cannot make a log before we initialise it.

@4TT1L4
Copy link
Contributor Author

4TT1L4 commented May 23, 2024

@sourabhxyz Please make sure that cabal install actually works for the server binary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-Shirt size - Medium High-Level effort estimation. Category "medium effort". Task A feature request or general task involving code changes.
Projects
None yet
Development

No branches or pull requests

2 participants