Use IndexMap
for performance boost in qubit allocation
#215
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change pulls in the
IndexMap
struct from https://github.com/microsoft/qsharp/tree/main/compiler/qsc_data_structures to use for the qubit id mapping, rather thanFxHashMap
. In most use cases qubit ids tend to be dense and sequential, makingIndexMap
an optimal fit. This also cuts down on the execution time of thetest_large_state
unit test by an order of magnitude, and the new benchmark shows significant gains as well. Other benchmaks showed a small decrease in the perf (around 5%) but since those are measured in microseconds it seems to be a worthwile trade-off (for example, the X gate benchmark was slower by about 0.15 microsecods).