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

Add {Manifest, Project}.toml and optimize fit-bayes.jl #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

YingboMa
Copy link

@YingboMa YingboMa commented Jul 6, 2022

To have fast code in Julia, we need to make sure that the code is type stable. In addition to make the code type stable (avoid creating closures over global variables), I also added a buffer to minimize allocations and used LoopVectorization to accelerate log evaluation.

Before:

113.925800 seconds (350.11 M allocations: 112.508 GiB, 21.51% gc time, 0.01% compilation time)

Now:

7.521123 seconds (10.00 M allocations: 1.193 GiB, 3.59% gc time)

I add *.toml files so that one can just active the project and run the
scripts. This addresses the issue mentioned in README.md:

The Julia examples depend only on standard packages which are part of
the Julia package ecosystem, and are therefore easy to add, in
principle. But in my limited experience, package dependency conflicts
are even more of a problem in Julia than they are in Python, and that's
saying something.

YingboMa added 2 commits July 6, 2022 15:46
Before:
```julia
113.925800 seconds (350.11 M allocations: 112.508 GiB, 21.51% gc time, 0.01% compilation time)
```

Now:
```julia
17.208975 seconds (60.07 M allocations: 6.410 GiB, 9.11% gc time)
```

I add *.toml files so that one can just active the project and run the
scripts. This addresses the issue mentioned in README.md:

> The Julia examples depend only on standard packages which are part of
> the Julia package ecosystem, and are therefore easy to add, in
> principle. But in my limited experience, package dependency conflicts
> are even more of a problem in Julia than they are in Python, and that's
> saying something.
```julia
julia> out = @time mcmc(beta, kern, 10000, 1000);
100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2100 2200 2300 2400 2500 2600 2700 2800 2900 3000 3100 3200 3300 3400 3500 3600 3700 3800 3900 4000 4100 4200 4300 4400 4500 4600 4700 4800 4900 5000 5100 5200 5300 5400 5500 5600 5700 5800 5900 6000 6100 6200 6300 6400 6500 6600 6700 6800 6900 7000 7100 7200 7300 7400 7500 7600 7700 7800 7900 8000 8100 8200 8300 8400 8500 8600 8700 8800 8900 9000 9100 9200 9300 9400 9500 9600 9700 9800 9900 10000 .
  7.521123 seconds (10.00 M allocations: 1.193 GiB, 3.59% gc time)
```
@chriselrod
Copy link

But in my limited experience, package dependency conflicts
are even more of a problem in Julia than they are in Python, and that's
saying something.

FWIW, I tend to have separate projects for everything I do.
Not bringing in things I don't need means most version conflicts I face are in the repos I maintain and the result of breaking changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants