Question: derefing named tuples

I need to pass a bunch of vectors (from a typed table) into a function that is called in a hot loop. I had previously avoided the time cost of derefing the columns from the table in the loop.

Now, I am putting the needed columns in a named tuple, as in <abbreviated as there are 11 columns>: spread_cols = (agegrp=c_agegrp, status=c_status, <...more columns>)

I have timing built-in to the code because performance tuning was so important for this simulation app.

Derefing the named tuple has no affect on a loop that runs 180 times with nested loops that run 1.8 million times. Note that the functions run within the loops are inlined.

Does derefing the named tuple get compiled away? Or by inlining do I eliminate the pack and unpack of the named tuple?

Just curious. I originally built this way back around Julia 1.4 when passing the vectors instead of a container of vectors made a meaningful difference in performance. Now it seems to make no difference.

There shouldn’t really be any noticeable difference in accessing a column from a TypedTable, or a field from a namedtuple, or simply a plain variable.

1 Like