Using large NTuples makes Julia hang

@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 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ā€¦

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.

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).

1 Like

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

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 :slight_smile:

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
4 Likes