缓慢的 Julia 启动时间 [英] Slow Julia Startup Time

查看:24
本文介绍了缓慢的 Julia 启动时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在探索将 Julia 用作通用科学计算语言(而不是 python),但它的启动时间相当缓慢.

I am exploring using Julia as a general purpose scientific computing language (as opposed to python), but it's startup time is pretty sluggish.

有什么办法可以加快速度?

Is there any way of speeding this up?

$ time python -c 'print "Hello"'
Hello

real    0m0.030s
user    0m0.018s
sys 0m0.010s

$ time julia -e 'println("Hello")'
Hello

real    0m4.614s
user    0m4.644s
sys 0m0.116s

<小时>

ADDENDUM:这里是去年 Julia 的一位作者的引述.这个策略有什么困难吗?


ADDENDUM: Here is a quote from one of the Julia authors last year. Was there some difficulty with this strategy?

大部分 Julia 都是自己编写的,然后经过解析、类型推断和jitted,所以从头开始引导整个系统需要一些时间15-20 秒.为了让它更快,我们有一个分阶段的系统,我们解析、类型推断,然后缓存文件 sys.ji 中类型推断的 AST.然后加载该文件并用于在运行 julia 时运行系统.没有 LLVM 代码或机器但是,代码缓存在 sys.ji 中,因此仍然需要所有 LLVM jitting每次 Julia 启动时都要完成,因此大约需要 2秒.

Most of Julia is written in itself, then parsed, type-inferred and jitted, so bootstrapping the entire system from scratch takes some 15-20 seconds. To make it faster, we have a staged system where we parse, type-infer, and then cache a serialized version of the type-inferred AST in the file sys.ji. This file is then loaded and used to run the system when you run julia. No LLVM code or machine code is cached in sys.ji, however, so all the LLVM jitting still needs to be done every time julia starts up, which therefore takes about 2 seconds.

这 2 秒的启动延迟非常烦人,我们有一个计划修复它.基本计划是能够编译整个 Julia二进制程序:可以运行的可执行文件或 .so/.dylib可以从其他程序调用的共享库,就好像它们一样只是共享的 C 库.二进制文件的启动时间为与任何其他 C 程序一样,因此 2 秒的启动延迟将消失.

This 2-second startup delay is quite annoying and we have a plan for fixing it. The basic plan is to be able to compile whole Julia programs to binaries: either executables that can be run or .so/.dylib shared libraries that can be called from other programs as though they were simply shared C libraries. The startup time for a binary will be like any other C program, so the 2-second startup delay will vanish.

推荐答案

我在评论中提到的分支现在已合并,并且 julia 比以往任何时候都更适合启动(并且什么都不做).

The branch I mentioned in the comment has now been merged and julia is more optimized for startup (and doing nothing), than ever.

$> time julia -e 'println("Hello")'
Hello

real    0m0.622s
user    0m1.013s
sys     0m0.624s

现在可在夜间构建中使用,并将包含在下一个 0.3 版本中.

This is now available in the nightly builds, and will be included in the next 0.3 release.

这篇关于缓慢的 Julia 启动时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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