Skip to content

Rework SparseVectorMap for performance and add API and tests - #1663

Merged
gvoskuilen merged 2 commits into
sstsimulator:develfrom
feldergast:svm-opt
Nov 13, 2026
Merged

gvoskuilen merged 2 commits into
sstsimulator:develfrom
feldergast:svm-opt

Conversation

@feldergast

Copy link
Copy Markdown
Contributor

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.

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.
@feldergast feldergast self-assigned this Nov 10, 2026
@feldergast feldergast added the AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) label Nov 10, 2026
@github-actions github-actions Bot added AT: CLANG-FORMAT PASS and removed AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) labels Nov 10, 2026
@feldergast feldergast added the AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) label Nov 10, 2026
@gvoskuilen gvoskuilen removed the AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) label Nov 10, 2026
@sst-autotester

Copy link
Copy Markdown
Contributor

Status Flag 'Pre-Test Inspection' - Auto Inspected - Inspection is Not Necessary for this Pull Request.

@sst-autotester

Copy link
Copy Markdown
Contributor

Status Flag 'Pull Request AutoTester' - Testing Jenkins Projects:

Pull Request Auto Testing STARTING (click to expand)

Build Information

Test Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-elements

  • Build Num: 2953
  • Status: STARTED

Build Information

Test Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-elements_MR-2

  • Build Num: 2892
  • Status: STARTED

Build Information

Test Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-elements_MT-2

  • Build Num: 2890
  • Status: STARTED

Build Information

Test Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-core_Make-Dist

  • Build Num: 1237
  • Status: STARTED

Build Information

Test Name: SST__Autotest_OSX-15-XC16_OMPI-4.1.6_PY3.10_sst-elements

  • Build Num: 1425
  • Status: STARTED

Using Repos:

Repo: CORE (feldergast/sst-core)
  • Branch: svm-opt
  • SHA: fb3dd27
  • Mode: TEST_REPO
Repo: SQE (sstsimulator/sst-sqe)
  • Branch: devel
  • SHA: 59935dd24b390962e4083e5f1c69b45afe3241aa
  • Mode: SUPPORT_REPO
Repo: ELEMENTS (sstsimulator/sst-elements)
  • Branch: devel
  • SHA: df40da1233de216c8f8518348ceee9a4f86044ba
  • Mode: SUPPORT_REPO
Repo: MACRO (sstsimulator/sst-macro)
  • Branch: devel
  • SHA: 4f524aeda65401618bbd356f6782e419c5e05ca3
  • Mode: SUPPORT_REPO

Pull Request Author: feldergast

@sst-autotester

Copy link
Copy Markdown
Contributor

Status Flag 'Pull Request AutoTester' - Jenkins Testing: all Jobs PASSED

Pull Request Auto Testing has PASSED (click to expand)

Build Information

Test Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-elements

  • Build Num: 2953
  • Status: PASSED

Build Information

Test Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-elements_MR-2

  • Build Num: 2892
  • Status: PASSED

Build Information

Test Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-elements_MT-2

  • Build Num: 2890
  • Status: PASSED

Build Information

Test Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-core_Make-Dist

  • Build Num: 1237
  • Status: PASSED

Build Information

Test Name: SST__Autotest_OSX-15-XC16_OMPI-4.1.6_PY3.10_sst-elements

  • Build Num: 1425
  • Status: PASSED

@sst-autotester

Copy link
Copy Markdown
Contributor

Status Flag 'Pre-Merge Inspection' - - This Pull Request Requires Inspection... The code must be inspected by a member of the Team before Testing/Merging
NO REVIEWS HAVE BEEN PERFORMED ON THIS PULL REQUEST!

@sst-autotester

Copy link
Copy Markdown
Contributor

All Jobs Finished; status = PASSED, However Inspection must be performed before merge can occur...

1 similar comment
@sst-autotester

Copy link
Copy Markdown
Contributor

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>
@github-actions github-actions Bot added AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) and removed AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) labels Nov 12, 2026
@sst-autotester

Copy link
Copy Markdown
Contributor

Status Flag 'Pre-Test Inspection' - Auto Inspected - Inspection is Not Necessary for this Pull Request.

@sst-autotester

Copy link
Copy Markdown
Contributor

Status Flag 'Pull Request AutoTester' - Testing Jenkins Projects:

Pull Request Auto Testing STARTING (click to expand)

Build Information

Test Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-elements

  • Build Num: 2960
  • Status: STARTED

Build Information

Test Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-elements_MR-2

  • Build Num: 2899
  • Status: STARTED

Build Information

Test Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-elements_MT-2

  • Build Num: 2897
  • Status: STARTED

Build Information

Test Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-core_Make-Dist

  • Build Num: 1241
  • Status: STARTED

Build Information

Test Name: SST__Autotest_OSX-15-XC16_OMPI-4.1.6_PY3.10_sst-elements

  • Build Num: 1432
  • Status: STARTED

Using Repos:

Repo: CORE (feldergast/sst-core)
  • Branch: svm-opt
  • SHA: 619c9a3
  • Mode: TEST_REPO
Repo: SQE (sstsimulator/sst-sqe)
  • Branch: devel
  • SHA: 59935dd24b390962e4083e5f1c69b45afe3241aa
  • Mode: SUPPORT_REPO
Repo: ELEMENTS (sstsimulator/sst-elements)
  • Branch: devel
  • SHA: 0ba3b940eab57c8f1d19337285fe86f2a247b994
  • Mode: SUPPORT_REPO
Repo: MACRO (sstsimulator/sst-macro)
  • Branch: devel
  • SHA: 4f524aeda65401618bbd356f6782e419c5e05ca3
  • Mode: SUPPORT_REPO

Pull Request Author: feldergast

@sst-autotester

Copy link
Copy Markdown
Contributor

Status Flag 'Pull Request AutoTester' - Jenkins Testing: all Jobs PASSED

Pull Request Auto Testing has PASSED (click to expand)

Build Information

Test Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-elements

  • Build Num: 2960
  • Status: PASSED

Build Information

Test Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-elements_MR-2

  • Build Num: 2899
  • Status: PASSED

Build Information

Test Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-elements_MT-2

  • Build Num: 2897
  • Status: PASSED

Build Information

Test Name: SST__Autotest_sst-test_OMPI-4.1.4_PY3.9_sst-core_Make-Dist

  • Build Num: 1241
  • Status: PASSED

Build Information

Test Name: SST__Autotest_OSX-15-XC16_OMPI-4.1.6_PY3.10_sst-elements

  • Build Num: 1432
  • Status: PASSED

@sst-autotester

Copy link
Copy Markdown
Contributor

Status Flag 'Pre-Merge Inspection' - SUCCESS: The last commit to this Pull Request has been INSPECTED AND APPROVED by [ gvoskuilen ]!

@sst-autotester

Copy link
Copy Markdown
Contributor

Status Flag 'Pull Request AutoTester' - Pull Request MUST BE MERGED MANUALLY BY Project Team - This Repo does not support Automerge

@gvoskuilen
gvoskuilen merged commit d31e990 into sstsimulator:devel Nov 13, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants