Repository navigation
Rework SparseVectorMap for performance and add API and tests - #1663
Conversation
Consolidate the three hand-copied specializations into a single implementation and fix the sort() typo in the keyT == classT version. Storage is now one vector holding two sorted runs: a main region and a small tail of keys inserted out of order. Inserting a key larger than every existing key is an O(1) append. Maps below 64 elements are always kept as a single sorted run; past that, out-of-order inserts go into their sorted position in the tail, which is merged into the main region with std::inplace_merge once it reaches max(64, 2*sqrt(size())) elements. contains() and operator[] search both runs and never move elements; begin(), end() and find() merge any pending tail first and return plain vector iterators. Keys are passed and compared by reference, so expensive keys such as std::string are not copied on every comparison, and sorting and merging use an inlinable function object for the comparison. The class comment documents reference/iterator validity and summarizes benchmarked performance against std::map: increasing-order inserts, vector construction and integer-key lookups are efficient; one-at-a-time out-of-order inserts past a few hundred elements are not. New functionality: - empty(), find() (const and non-const) and erase() - compact(): merges any pending tail and, by default, releases spare capacity; afterwards const begin()/end()/find() only read, so concurrent const access is safe until the next modification - KeyExtract template parameter for element types without a key() method, defaulting to key()/->key()/identity/pair detection - std::pair<keyT, V> elements, keyed by first, with value(), at() (like std::map::at()), findValue(), insert_or_assign() and a two-argument insert() that work on second; std::pair<const keyT, V> is rejected at compile time - size() is now const - serialization also stores the run boundary and tail limit, and the restore side is fixed Remove the ConfigGraph friend declaration; getNumComponents() now calls size(). Document bad_filtered_key_error as unrecoverable. Add a core utility testsuite (coreTest_Utility, testsuite_default_Utility) with eleven SparseVectorMap test cases, and SparseVectorMap round trips (including pair elements) in the serialization test.
|
Status Flag 'Pre-Test Inspection' - Auto Inspected - Inspection is Not Necessary for this Pull Request. |
|
Status Flag 'Pull Request AutoTester' - Testing Jenkins Projects: Pull Request Auto Testing STARTING (click to expand)Build InformationTest Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-elements
Build InformationTest Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-elements_MR-2
Build InformationTest Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-elements_MT-2
Build InformationTest Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-core_Make-Dist
Build InformationTest Name: SST__Autotest_OSX-15-XC16_OMPI-4.1.6_PY3.10_sst-elements
Using Repos:
Pull Request Author: feldergast |
|
Status Flag 'Pull Request AutoTester' - Jenkins Testing: all Jobs PASSED Pull Request Auto Testing has PASSED (click to expand)Build InformationTest Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-elements
Build InformationTest Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-elements_MR-2
Build InformationTest Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-elements_MT-2
Build InformationTest Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-core_Make-Dist
Build InformationTest Name: SST__Autotest_OSX-15-XC16_OMPI-4.1.6_PY3.10_sst-elements
|
|
Status Flag 'Pre-Merge Inspection' - - This Pull Request Requires Inspection... The code must be inspected by a member of the Team before Testing/Merging |
|
All Jobs Finished; status = PASSED, However Inspection must be performed before merge can occur... |
1 similar comment
|
All Jobs Finished; status = PASSED, However Inspection must be performed before merge can occur... |
The tests added with the SparseVectorMap rework only cover
SparseVectorMap, so name them for it. Names only; no code changes.
- Files: coreTest_Utility.{h,cc} -> coreTest_SparseVectorMap.{h,cc},
testsuite_default_Utility.py -> testsuite_default_SparseVectorMap.py,
test_Utility.py -> test_SparseVectorMap.py,
refFiles/test_Utility_default.out -> test_SparseVectorMap_default.out
- Component: coreTestElement.coreTestUtility ->
coreTestElement.coreTestSparseVectorMap (namespace
SST::CoreTestSparseVectorMap, class coreTestSparseVectorMap)
- Testsuite: testcase_SparseVectorMap, tests test_SparseVectorMap_<name>
|
Status Flag 'Pre-Test Inspection' - Auto Inspected - Inspection is Not Necessary for this Pull Request. |
|
Status Flag 'Pull Request AutoTester' - Testing Jenkins Projects: Pull Request Auto Testing STARTING (click to expand)Build InformationTest Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-elements
Build InformationTest Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-elements_MR-2
Build InformationTest Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-elements_MT-2
Build InformationTest Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-core_Make-Dist
Build InformationTest Name: SST__Autotest_OSX-15-XC16_OMPI-4.1.6_PY3.10_sst-elements
Using Repos:
Pull Request Author: feldergast |
|
Status Flag 'Pull Request AutoTester' - Jenkins Testing: all Jobs PASSED Pull Request Auto Testing has PASSED (click to expand)Build InformationTest Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-elements
Build InformationTest Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-elements_MR-2
Build InformationTest Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-elements_MT-2
Build InformationTest Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-core_Make-Dist
Build InformationTest Name: SST__Autotest_OSX-15-XC16_OMPI-4.1.6_PY3.10_sst-elements
|
|
Status Flag 'Pre-Merge Inspection' - SUCCESS: The last commit to this Pull Request has been INSPECTED AND APPROVED by [ gvoskuilen ]! |
|
Status Flag 'Pull Request AutoTester' - Pull Request MUST BE MERGED MANUALLY BY Project Team - This Repo does not support Automerge |
Consolidate the three hand-copied specializations into a single implementation and fix the sort() typo in the keyT == classT version.
Storage is now one vector holding two sorted runs: a main region and a small tail of keys inserted out of order. Inserting a key larger than every existing key is an O(1) append. Maps below 64 elements are always kept as a single sorted run; past that, out-of-order inserts go into their sorted position in the tail, which is merged into the main region with std::inplace_merge once it reaches max(64, 2*sqrt(size())) elements. contains() and operator[] search both runs and never move elements; begin(), end() and find() merge any pending tail first and return plain vector iterators. Keys are passed and compared by reference, so expensive keys such as std::string are not copied on every comparison, and sorting and merging use an inlinable function object for the comparison.
The class comment documents reference/iterator validity and summarizes benchmarked performance against std::map: increasing-order inserts, vector construction and integer-key lookups are efficient; one-at-a-time out-of-order inserts past a few hundred elements are not.
New functionality:
Remove the ConfigGraph friend declaration; getNumComponents() now calls size(). Document bad_filtered_key_error as unrecoverable.
Add a core utility testsuite (coreTest_Utility, testsuite_default_Utility) with eleven SparseVectorMap test cases, and SparseVectorMap round trips (including pair elements) in the serialization test.