[Chapel Merge] Only reference count a distribution's domains

Branch: refs/heads/master
Revision: a58a4c9
Author: ronawho
Log Message:

Merge pull request #16528 from ronawho/only-ref-count-dists

Only reference count a distribution’s domains

[reviewed by @e-kayrakli]

Previously, a distribution would keep track of all the domains declared
over it. When only a single domain is declared over the distribution,
the tracking got more expensive when we switched from using a list of
domains to a set of domains in #15895. This hurt the performance of
creating rank-change/reindex array views, which create a single-use
distribution and domain.

It turns out that nothing actually uses the distributions list/set of
domains, only the count of how many we have. Given that, switch to just
tracking the count, which is much cheaper.

There is a potential desire to be able to change domains declared over a
distribution when the distribution changes in the future (like how we
resize arrays declared over a domain if the domain changes), but today
that’s an unimplemented feature that will halt. If we decide to support
that in the future, we can always revert this change, but for now we
don’t need to pay the performance penalty.

At this point we’re just using a lock to bump a counter, so we could
switch to an atomic, but I didn’t want to make more drastic changes this
close to the release. Cleaning this up in the future is captured in
https://github.com/Cray/chapel-private/issues/1378

Resolves https://github.com/Cray/chapel-private/issues/1096

Modified Files:
M modules/internal/ChapelArray.chpl
M modules/internal/ChapelDistribution.chpl
M test/distributions/vass/changeBoundingBox.chpl

Compare: https://github.com/chapel-lang/chapel/compare/b8e3e767ced5...a58a4c9c0639