什么是最好的Haskell库来操作一个程序? [英] What are the best Haskell libraries to operationalize a program?

查看:131
本文介绍了什么是最好的Haskell库来操作一个程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我要将一个程序投入生产,那么我需要该程序执行以下几件事情,以便将其视为可操作化 - 即由工程师和工程师以可测量和可验证的方式运行和维护操作人员。对于我的目的,一个可操作的程序必须:


  • 能够在多个级别上记录(例如:debug,warning等)。

  • 能够收集和分享有关该计划正在进行的工作类型以及该工作需要多长时间的指标/统计数据。理想情况下,收集的指标可以采用与 Ganglia 等常用监控工具兼容的格式,也可以是所以很容易。

  • 可配置,理想情况下通过一个系统,允许在不重新启动所述程序的情况下更新配置的程序运行属性。 可部署到远程服务器。



在Scala世界中,有至少处理前三个需求的好库。例如:


  • Logula a>进行日志记录。

  • 指标鸵鸟用于收集和报告指标。 Configgy 进行配置。对于部署,Scala世界采取的一种方法是将组成程序的字节码和库与类似于<一个href =https://github.com/codahale/assembly-sbt =noreferrer> assembly-sbt ,然后用一个工具将产生的bundle(一个胖JAR)推送到远程服务器像通过SSH并行执行命令的 Capistrano 。这不是一个需要特定语言工具的问题,但我很好奇这个工具是否存在于Haskell社区中。



    可能有Haskell库提供我上面描述的特征。我想知道哪些可用的库被认为是最好的;那就是最成熟,维护得当,Haskell社区常用的,以及Haskell最佳实践的典范。



    如果有任何其他库,工具或实践让Haskell代码生产就绪,我也很想知道这些。

    解决方案

    这是一个很好的问题!这是第一次剪辑。


    可以在多个级别进行登录(例如:debug,warning等)。 b $ b

    hslogger 很容易最流行的日志框架。


    能够收集和分享有关该计划正在进行的工作类型以及该工作需要多长时间的指标/统计数据。理想情况下,收集的指标可以采用与Ganglia等常用监控工具兼容的格式,或者可以如此消耗。

    我不知道任何标准化的报告工具,但是,从 + RTS -s 流(或通过分析输出标记)提取报告是我在过去。


    $ b $

      $ ./A + RTS -s 
    在堆中分配64,952字节
    1 MB总内存使用中
    %GC时间0.0%(已用6.1%)
    生产力总用户数的100.0%,占已用总数的0.0%

    你也可以用机器可读的格式获得它:

      $ ./A + RTS -t  - 机器可读的

    [(bytes allocated,64952)
    ,(num_GCs,1)
    ,(average_bytes_used ,43784)
    ,(max_bytes_used,43784)
    ,(num_byte_usage_samples,1)
    ,(peak_megabytes_allocated,1)
    ,(init_cpu_seconds,0.00)
    ,(init_wall_seconds,0.00)
    ,(mutator_cpu_seconds,0.00)
    ,(mutator_wall_seconds, 0.00)
    ,(GC_cpu_seconds,0.00)
    ,(GC_wall_seconds,0.00)
    ]
    pre>

    理想情况下,您可以通过套接字附加到正在运行的GHC运行时,并以交互方式查看这些GC统计信息,但目前这不是非常容易的(需要FFI绑定到rts / Stats.h界面)。您可以使用 ThreadScope ,并监控GC和线程行为。



    类似标志可用于增量,记录时间 space 剖析,可用于监视(例如,这些可以逐步构建)。



    hpc 通过它的 Tix 类型收集了很多关于程序执行的统计信息, a href =http://hackage.haskell.org/package/hpc-strobe =noreferrer>书写工具,通过时间片记录执行的代码。


    可配置,理想情况下通过一个系统,允许在运行程序时配置的属性在不重新启动所述程序的情况下进行更新。

    有几种工具可用于此,您可以执行xmonad-style状态重装;或者通过 插件 *包或 提示


    可重复部署


    Galois最近发布了 cabal-dev ,这是一个可重复构建的工具(即依赖关系被限制和控制)。


    If I'm going to put a program into production, there are several things I need that program to do in order to consider it "operationalized" – that is, running and maintainable in a measurable and verifiable way by both engineers and operations staff. For my purposes, an operationalized program must:

    • Be able to log at multiple levels (ex: debug, warning, etc.).
    • Be able to collect and share metrics/statistics about the types of work the program is doing and how long that work is taking. Ideally, the collected metrics are available in a format that's compatible with commonly-used monitoring tools like Ganglia, or can be so munged.
    • Be configurable, ideally via a system that allows configured properties in running programs to be updated without restarting said programs.
    • Be deployable to remote servers in a repeatable way.

    In the Scala world, there are good libraries for dealing with at least the first three requirements. Examples:

    As for deployment, one approach taken in the Scala world is to bundle together the bytecode and libraries that comprise one's program with something like assembly-sbt, then push the resulting bundle (a "fat JAR") to remote servers with a tool like Capistrano that executes commands in parallel over SSH. This isn't a problem that necessitates language-specific tools, but I'm curious if such a tool exists in the Haskell community.

    There are probably Haskell libraries that provide the traits I've described above. I'd like to know which of the available libraries are considered "best"; that is, which are most mature, well-maintained, commonly used in the Haskell community, and exemplary of Haskell best practices.

    If there are any other libraries, tools, or practices around making Haskell code "production-ready", I'd love to know about those as well.

    解决方案

    This is a great question! Here's a first cut.

    Be able to log at multiple levels (ex: debug, warning, etc.).

    hslogger is easily the most popular logging framework.

    Be able to collect and share metrics/statistics about the types of work the program is doing and how long that work is taking. Ideally, the collected metrics are available in a format that's compatible with commonly-used monitoring tools like Ganglia, or can be so munged.

    I'm not aware of any standardized reporting tools, however, extracting reports from +RTS -s streams (or via profiling output flags) has been something I've done in the past.

    $ ./A +RTS -s
    64,952 bytes allocated in the heap
    1 MB total memory in use
     %GC time       0.0%  (6.1% elapsed)
     Productivity 100.0% of total user, 0.0% of total elapsed
    

    You can get this in machine-readable format too:

    $ ./A +RTS -t --machine-readable
    
     [("bytes allocated", "64952")
     ,("num_GCs", "1")
     ,("average_bytes_used", "43784")
     ,("max_bytes_used", "43784")
     ,("num_byte_usage_samples", "1")
     ,("peak_megabytes_allocated", "1")
     ,("init_cpu_seconds", "0.00")
     ,("init_wall_seconds", "0.00")
     ,("mutator_cpu_seconds", "0.00")
     ,("mutator_wall_seconds", "0.00")
     ,("GC_cpu_seconds", "0.00")
     ,("GC_wall_seconds", "0.00")
     ]
    

    Ideally you could attach to a running GHC runtime over a socket and look at these GC stats interactively, but currently that's not super easy (needs an FFI bindings to the "rts/Stats.h" interface). You can attach to a process using ThreadScope and monitor GC and threading behavior.

    Similar flags are available for incremental, logged time and space profiling, which can be used for monitoring (e.g. these graphs can be built incrementally).

    hpc collects a lot of statistics about program execution, via its Tix type, and people have written tools to log by time-slice what code is executing.

    Be configurable, ideally via a system that allows configured properties in running programs to be updated without restarting said programs.

    Several tools are available for this, you can do xmonad-style state reloading; or move up to code hotswapping via plugins* packages or hint. Some of these are more experimental than others.

    Reproducible deployments

    Galois recently released cabal-dev, which is a tool for doing reproducible builds (i.e. dependencies are scoped and controlled).

    这篇关于什么是最好的Haskell库来操作一个程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆