hasura graphql-engine 源码构建问题

基于centos 7 构建

安装haskell 构建工具

curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh

依赖包问题

  • gmp
yum install -y gmp-devel
  • pcre
yum install -y pcre-devel 
  • mysql

The program 'mysql_config' is required but it could not be found

yum install -y mariadb-devel
  • error "AES/PCLMUL instructions not enabled"

    禁用aesni

 
cabal build all --constraint="cryptonite -support_aesni"
  • pg

    注意版本问题,此方法可能会太低了

The program 'pg_config' is required but it could not be found

yum install -y postgresql-devel
  • Missing (or bad) C library: odbc
yum install -y unixODBC-devel
  • 可能需要的安装
yum  install -y libstdc++-devel libstdc++-static gcc-c++ ncurses-devel

构建

git clone https://github.com/hasura/graphql-engine.git
cd graphql-engine/server
cabal build all --constraint="cryptonite -support_aesni"

一些问题

适合内存不够用的场景,通过swap 解决,就是构建会比较慢,实际推荐使用一台配置比较好的机器构建(cpu,内存,以及磁盘)

dd if=/dev/zero of=/var/swapfile bs=1G count=10
mkswap /var/swapfile
swapon /var/swapfile
/etc/fstab
/var/swapfile swap swap defaults 0 0
 vim /etc/sysctl.conf
vm.swappiness = 60
sysctl -p

性能相关参数

默认没有开启profile 我们可以通过手工开启,方便性能优化
server/graphql-engine.cabal

 
flag profiling
  description: Configures the project to be profiling-compatible
  default: True
  manual: True

说明

以上是一个构建实践说明,推荐还是使用高版本的系统haskell 构建问题是不少,因为对于haskell 不是很了解,性能参数上边的还需要研究下

参考资料

https://gmplib.org/
https://www.haskell.org/ghcup/install/
https://github.com/hasura/graphql-engine
https://github.com/haskell-crypto/cryptonite
https://github.com/input-output-hk/cardano-node/issues/1747
https://www.haskell.org/ghcup/install/
https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/rts
https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/rts/config
https://downloads.haskell.org/~ghc/9.2.3/docs/html/users_guide/profiling.html#prof-compiler-options
https://downloads.haskell.org/~ghc/9.2.3/docs/html/users_guide/debug-info.html#implementor-s-notes-dwarf-annotations
https://github.com/fpco/ghc-prof-flamegraph
https://www.fpcomplete.com/blog/2015/04/ghc-prof-flamegraph/
https://downloads.haskell.org/~ghc/9.2.3/docs/html/users_guide/profiling.html
https://www.tweag.io/blog/2020-01-30-haskell-profiling/
http://cnhaskell.com/chp/25.html

posted on 2022-07-04 22:49  荣锋亮  阅读(117)  评论(0编辑  收藏  举报

导航