# Using large NTuples makes Julia hang

**URL:** <https://discourse.julialang.org/t/using-large-ntuples-makes-julia-hang/78900>\
**Category:** General Usage\
**Tags:** hdf5, memory-allocation, data\_structures, ntuple\
**Created:** [April 2, 2022, 6:38am UTC](https://discourse.julialang.org/t/using-large-ntuples-makes-julia-hang/78900 "2022-04-02T06:38:56Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![Maurizio\_Tomasi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maurizio_tomasi/32/384_2.png) [@Maurizio\_Tomasi](https://discourse.julialang.org/u/Maurizio_Tomasi)\
**Post date:** [April 4, 2022, 11:01am UTC](https://discourse.julialang.org/t/using-large-ntuples-makes-julia-hang/78900/21 "2022-04-04T11:01:32Z")

</div>

@Sukera , @cjdoris , @simeonschaub , thanks a lot for your answers and sorry to answer only today! (I was away in the week-end.)

I learned a lot from your answers, and I think that I will go with @Sukera 's solution, as it lets me to keep most of my code unchanged.

Sorry to have misunderstood your idea, @cjdoris , I believed you were suggesting me to use existing primitive types rather than defining one on my own. (I was induced to believe this also because of the big [warning](https://docs.julialang.org/en/v1/manual/types/#Primitive-Types) in the documentation.)

However, I second @simeonschaub 's wish to have some way to specify padding in Julia structures: this would improve a lot the user’s experience. But I fail to imagine a nice syntax for this…

---

<div class="post-metadata">

**Author:** ![goerch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerch/32/29122_2.png) [@goerch](https://discourse.julialang.org/u/goerch)\
**Post date:** [April 4, 2022, 8:56pm UTC](https://discourse.julialang.org/t/using-large-ntuples-makes-julia-hang/78900/22 "2022-04-04T20:56:45Z")

</div>

Sorry for bothering you all again, but I haven’t heard of any rejections or confirmations of the claim that `NTuple` and `StaticVector` behave differently as mentioned [here](https://discourse.julialang.org/t/using-large-ntuples-makes-julia-hang/78900/16).

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [April 5, 2022, 12:04pm UTC](https://discourse.julialang.org/t/using-large-ntuples-makes-julia-hang/78900/23 "2022-04-05T12:04:34Z")

</div>

I haven’t checked, but my guess would be the difference stems from constant propagation handling it differently for some reason and the benchmark running in a function itself. Note that Benchmarks 2,3 and 4 are more or less the same, while the big difference is in compilation of `@time Foo[data]` (which imo isn’t surprising, since `StaticArrays` has heavily optimized those cases of compilation time already).

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [February 10, 2023, 10:40am UTC](https://discourse.julialang.org/t/using-large-ntuples-makes-julia-hang/78900/24 "2023-02-10T10:40:10Z")

</div>

Since someone pinged me through ❤ -ing one of my comments above, I decided to try the case again on a recent master:

```julia
julia> @time show(stdout, dataset)
Foo[Foo(0x0000000000000000, (0x74, 0x65 # again ommitting all the printed data..
))] 0.296913 seconds (365.83 k allocations: 52.791 MiB, 18.04% gc time, 60.43% compilation time)

```

so this seems fixed now 🙂

```julia
julia> versioninfo()
Julia Version 1.10.0-DEV.546
Commit d72a9a1d2a (2023-02-09 17:01 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: 24 × AMD Ryzen 9 7900X 12-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, znver3)
  Threads: 24 on 24 virtual cores
Environment:
  JULIA_NUM_THREADS = 24

```

[Previous page](https://discourse.julialang.org/t/using-large-ntuples-makes-julia-hang/78900.md?page=1)
