Branch: refs/heads/main
Revision: 441436e111a40c0a2ab3ec3f9d0f28d8d6524b31
Author: mppf
Link: Improve the performance of --dyno-scope-bundled by mppf · Pull Request #25853 · chapel-lang/chapel · GitHub
Log Message:
Improve the performance of --dyno-scope-bundled (#25853)
This PR improves the performance of the new scope resolver. We have
observed performance problems with --dyno-scope-bundled. These are
more pronounced with developer builds, but are also present with release
builds. The magnitude of the performance problems presents a challenge
to turning on --dyno-scope-bundled by default.
This table summarizes the score, with times in seconds:
main | this PR |
------------------------------------------------------------------------|------|---------|
chpl --dyno-scope-bundled hello.chpl(quickstart with CHPL_DEVELOPER)
16.1 | 12.8 |
chpl --dyno-scope-bundled hello.chpl(default, no CHPL_DEVELOPER) |
3.0 | 2.6 |
chpl hello.chpl(quickstart with CHPL_DEVELOPER) | 9.7 | 9.5 |
chpl hello.chpl(default, no CHPL_DEVELOPER) | 2.5 | 2.4 |
This PR takes the following steps in order to achieve this:
- Changes BorrowedIdsWithName to copy IDs rather than referring to
OwnedIdsWithName. The idea of referring to a list of overloads with the
same name was always an optimization. However, it did not seem to help
performance and it added some complexity. Along with this change,
renamed BorrowedIdsWithName to MatchingIdsWithName. There is no longer a
need forstd::vector<BorrowedIdsWithName>--MatchingIdsWithName
covers that. - Adds a query to compute the public contents of a module. After the
changes in PR #19306, the public symbols available in a module are
always fixed and at a single level (for shadowing purposes). This is
responsible for most of the speed improvement here for
--dyno-scope-bundled. - Removes certain
public uses in the standard library. The motivation
here is to remove the possibility for modules thatpublic useeach
other (potentially through an intermediate module). This case is
difficult to support efficiently in the new query to compute the public
contents of a module. Removing thesepublic usestatements can be
viewed as a continuation of PR #16119. - Adds a Flags to IdAndFlags to track Module-ness and Type-ness. These
are useful to optimize some of the code using scope lookup. In
particular, such code can use these flags instead of using
parsing::idToTag. - Adjusts the strategy for handling conditionals with variables (see PR
#21140) and do-while statements (see PR #22564). Both of these have
scoping behavior where the parent scope is not the scope for the parent
ID. Before this PR, that was handled withnextHigherScopewhich used
queries to check for these patterns. This PR changes the process of
constructing aScopeto take these patterns into account, so that
scope->parentScope()can be used even in these cases.
Future Work:
- It might be possible to further improve the new scope resolver by
caching the scopes that need to be traversed when looking for a symbol.
I prototyped something that saves such a linearized view of scopes in
GitHub - mppf/chapel at save-scopes-visited . However, it
will take more work to get this functional, and it's currently unclear
if this offers enough performance improvement to be worthwhile.
- full comm=none testing
- spot-checked that a program can compile and run with
CHPL_LOCALE_MODEL=gpu
Reviewed by @DanilaFe - thanks!
Diff:
M compiler/main/driver.cpp
M compiler/passes/scopeResolve.cpp
M frontend/include/chpl/framework/Context-detail.h
M frontend/include/chpl/framework/Context.h
M frontend/include/chpl/framework/query-impl.h
M frontend/include/chpl/resolution/resolution-error-classes-list.h
M frontend/include/chpl/resolution/resolution-queries.h
M frontend/include/chpl/resolution/scope-queries.h
M frontend/include/chpl/resolution/scope-types.h
M frontend/lib/framework/Context.cpp
M frontend/lib/framework/ErrorBase.cpp
M frontend/lib/framework/UniqueString.cpp
M frontend/lib/resolution/InitResolver.cpp
M frontend/lib/resolution/InitResolver.h
M frontend/lib/resolution/Resolver.cpp
M frontend/lib/resolution/Resolver.h
M frontend/lib/resolution/default-functions.cpp
M frontend/lib/resolution/disambiguation.cpp
M frontend/lib/resolution/resolution-error-classes-list.cpp
M frontend/lib/resolution/resolution-queries.cpp
M frontend/lib/resolution/scope-queries.cpp
M frontend/lib/resolution/scope-types.cpp
M frontend/test/resolution/testGetSymbolsAvailableInScope.cpp
M frontend/test/resolution/testMethodCalls.cpp
M frontend/test/resolution/testReductions.cpp
M frontend/test/resolution/testScopeTypes.cpp
M frontend/test/test-common.cpp
M frontend/util/analyze-query-trace
M modules/internal/ChapelArray.chpl
M modules/internal/ChapelArrayViewElision.chpl
M modules/internal/ChapelAutoLocalAccess.chpl
M modules/internal/ChapelLocale.chpl
M modules/internal/ChapelSerializedBroadcast.chpl
M modules/internal/ChapelStandard.chpl
M modules/internal/ChapelStaticVars.chpl
M modules/internal/DefaultRectangular.chpl
M modules/internal/LocaleModelHelpFlat.chpl
M modules/internal/LocaleModelHelpGPU.chpl
M modules/internal/LocaleModelHelpSetup.chpl
M modules/internal/localeModels/flat/LocaleModel.chpl
M modules/internal/localeModels/gpu/LocaleModel.chpl
M modules/packages/CopyAggregation.chpl
M test/classes/generic/typeOfGenericField-fromTypeVariable.bad
M test/compflags/ferguson/print-module-resolution.good
M test/execflags/configs/privateconfigs-help-set.comm-none.good
M test/execflags/configs/privateconfigs-help-set.good
M test/execflags/configs/privateconfigs-help.comm-none.good
M test/execflags/configs/privateconfigs-help.good
M test/execflags/ferguson/help2.good
M test/execflags/shannon/configs/help/basehelp.txt
M test/execflags/shannon/help.good
M test/modules/sungeun/init/printModuleInitOrder.good
M test/unstable/unstableConfigs.help.comm-none.good
M test/unstable/unstableConfigs.help.good
M tools/chapel-py/src/resolution.cpp
M util/chpl-completion.bash
https://github.com/chapel-lang/chapel/pull/25853.diff