使用并包括或至少包括更快的方式的并行性?

发布于 2025-01-26 18:29:21 字数 1768 浏览 3 评论 0原文

我开始有一个大项目,目前正在使用,包括许多软件包,.jl文件:

a = time()
@info "Loading JuMP"
using JuMP
@info "Loading Gurobi"
using Gurobi
# @info "Loading Combinatorics, DelimitedFiles, Dates and StatsBase"
# using Combinatorics, DelimitedFiles, Dates, StatsBase
@info "Loading Combinatorics, DelimitedFiles, Dates and Random"
using Combinatorics, DelimitedFiles, Dates, Random
@info "Loading Distributions, Graphs, GraphsFlows[TODO] and Plots"
using Distributions
# using Graphs, GraphsFlows, GraphPlot, Plots
using Graphs, GraphPlot, Plots
@info "Loading Parameters and Formatting"
using Parameters, Formatting #https://stackoverflow.com/a/58022378/10094437
@info "Loading Compose, Cairo and Fontconfig"
using Cairo, Fontconfig, Compose
@info "Loading .jl files $(lpad("0%",4))"

include("write_tikz.jl")
include("with_kw_mutable_structures.jl")
include("instance.jl")
include("solution_checker.jl")
@info "Loading .jl files $(lpad("25%",4))"
include("create_subtour_constraint.jl")
# include("ilp_rho_rsp_st_chains.jl")
include("ilp_rho_rsp_without_uc.jl")
include("benders_rho_rsp.jl")
include("benders_subproblem_poly.jl")
@info "Loading .jl files $(lpad("50%",4))"
include("benders_subproblem_ilp_primal.jl")
include("benders_subproblem_ilp_dual.jl")
include("print.jl")
include("three_four_rho_rsp.jl")
@info "Loading .jl files $(lpad("75%",4))"
include("utilities.jl")
include("rho_rsp_lb.jl")
include("./plots/plots.jl")
include("local_searches.jl")
@info "Loading .jl files $(lpad("100%",4))"
@info time()-a

所有这些使用 and incode income 每次发射朱莉娅每次34秒。它已经编译时的确更快,并且在执行时,第二次 includs includ(“ main.jl”),但在已经编译一次时仍需要2S45。

我想知道使用 packages和包括 julia文件的是否有更快的方法?

我正在使用朱莉娅1.7.2

I am starting to have a big project and I am currently using and including many of packages and .jl files:

a = time()
@info "Loading JuMP"
using JuMP
@info "Loading Gurobi"
using Gurobi
# @info "Loading Combinatorics, DelimitedFiles, Dates and StatsBase"
# using Combinatorics, DelimitedFiles, Dates, StatsBase
@info "Loading Combinatorics, DelimitedFiles, Dates and Random"
using Combinatorics, DelimitedFiles, Dates, Random
@info "Loading Distributions, Graphs, GraphsFlows[TODO] and Plots"
using Distributions
# using Graphs, GraphsFlows, GraphPlot, Plots
using Graphs, GraphPlot, Plots
@info "Loading Parameters and Formatting"
using Parameters, Formatting #https://stackoverflow.com/a/58022378/10094437
@info "Loading Compose, Cairo and Fontconfig"
using Cairo, Fontconfig, Compose
@info "Loading .jl files $(lpad("0%",4))"

include("write_tikz.jl")
include("with_kw_mutable_structures.jl")
include("instance.jl")
include("solution_checker.jl")
@info "Loading .jl files $(lpad("25%",4))"
include("create_subtour_constraint.jl")
# include("ilp_rho_rsp_st_chains.jl")
include("ilp_rho_rsp_without_uc.jl")
include("benders_rho_rsp.jl")
include("benders_subproblem_poly.jl")
@info "Loading .jl files $(lpad("50%",4))"
include("benders_subproblem_ilp_primal.jl")
include("benders_subproblem_ilp_dual.jl")
include("print.jl")
include("three_four_rho_rsp.jl")
@info "Loading .jl files $(lpad("75%",4))"
include("utilities.jl")
include("rho_rsp_lb.jl")
include("./plots/plots.jl")
include("local_searches.jl")
@info "Loading .jl files $(lpad("100%",4))"
@info time()-a

All these using and includes take 34 seconds each time a launch Julia. It is indeed faster when already compiled, and when doing include("main.jl") for the second time, but still it takes 2s45 when already compiled once.

I would like to know if there are faster ways to using packages and includes Julia files, maybe with parallelism?

I am using Julia 1.7.2

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

っ〆星空下的拥抱 2025-02-02 18:29:21

的步骤

  1. 这些是考虑将所有代码包装到Julia软件包中 。
    朱莉娅的软件包将在第一次使用中进行预编译,随后的时间将要短得多。您不想拥有很多代码包括 - 制作一个包裹来加快事物的速度。
  2. 很可能您会在步骤(1)之后没事。但是,下一个选项是使用PackageCompiler将软件包汇编为Julia System Image。
  3. 正如@Jing所提到的,每个新的朱莉娅版本都会在较短的时间内完成这项工作

These are the steps to consider

  1. Wrap all your code into a Julia package.
    The Julia packages will be precompiled on the first use and the subsequent times will be much shorter. You do not want to have a code with so many includes - make a package to speed up the things.
  2. Most likely you will be fine after step (1). However the next option is compiling the packages into Julia system image using PackageCompiler.
  3. As mentioned by @jing each new Julia version will do the job in a shorter time
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文