# I'm new to Julia and am hoping to use Apple's MLX Framework with Julia

**URL:** <https://discourse.julialang.org/t/im-new-to-julia-and-am-hoping-to-use-apples-mlx-framework-with-julia/136073>\
**Category:** New to Julia\
**Tags:** question, performance\
**Created:** [March 6, 2026, 5:35pm UTC](https://discourse.julialang.org/t/im-new-to-julia-and-am-hoping-to-use-apples-mlx-framework-with-julia/136073 "2026-03-06T17:35:33Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [March 6, 2026, 10:49pm UTC](https://discourse.julialang.org/t/im-new-to-julia-and-am-hoping-to-use-apples-mlx-framework-with-julia/136073/10 "2026-03-06T22:49:49Z")

</div>

> [@Bill\_Oliver](#):
>
> 120.226431 seconds (2.13 G allocations: 1.692 TiB, 35.43% gc time)

That seems like a _lot_ of allocations. I think many of them are coming from your `norm(x .- y)`s — that allocates a temporary for `x .- y` on every call. That’s where I’m sure you could do significantly better, even on a plain old CPU. Changing those to `Distances.euclidean` from Distances.jl (and nothing else!) gets me down to 18s on my crappy old M1 laptop with _way_ fewer allocations:

```julia-auto
julia> @time radii, C_r = grassberger_procaccia(X)
250.868078 seconds (2.13 G allocations: 1.692 TiB, 37.04% gc time, 0.28% compilation time)

julia> @time radii, C_r = grassberger_procaccia_euclidean(X)
 18.588317 seconds (862.84 k allocations: 128.668 MiB, 0.02% gc time, 1.61% compilation time)

```

You’ll also want to avoid using `tid` to divide up your threads work; see [PSA: Thread-local state is no longer recommended; Common misconceptions about threadid() and nthreads()](https://discourse.julialang.org/t/psa-thread-local-state-is-no-longer-recommended-common-misconceptions-about-threadid-and-nthreads/101274) for more details there.

---

_[View the full topic](https://discourse.julialang.org/t/im-new-to-julia-and-am-hoping-to-use-apples-mlx-framework-with-julia/136073)._
