Repository navigation
Closed
TravelMapping/DataProcessing
#622Description
Using region/system TMBitsets for subgraph membership will require a separate pass through those objects to allocate space after the number of vertices is known. It could happen as early as here, then proceeding to populate as we do now, with HGVertex construction calling add_vertex (which would just need to do a TMBitset insertion instead of a vector emplacement).
...But that's dumb.
If we shrink_to_fit, there'd still need to be another pass after population.
Better yet...
- Phase 1:
Pass thru regions & systems after vertex creation, multi-threaded.
This can happen before any TMBitset conversion, using the vectors we have now.- No need for mutexes during vertex creation. Remove
add_vertexfunctions. - With less mutex contention, does vertex creation scale better?
Meh. Not really. - Review whether mutexes are still needed.
If not, what are the effects oncompute_statsand HighwaySystem'sUbuntu_16_04_7_LTSpadding?
- No need for mutexes during vertex creation. Remove
- Phase 2:
Convert vector -> TMBitset.- Size increases 8 B, so nix the
Ubuntu_16_04_7_LTSpadding. ...Unless we were able to lose the mutex; that could complicate things.
- Size increases 8 B, so nix the
- Phase 3:
TMBitset::shrink_to_fit()
A benefit here of one pass after construction is, we shrink one region/system's bitset before allocating the next. We don't allocate a boatload of extra RAM in an initial pass that takes up space while vertices are created.
What's faster?shrink_to_fitwith min & max hints after 1 pass- 1 pass to get min & max, allocate, another pass to populate
Remember tosize_t align = min_index%ubits; min -= align; len += align; - Finding min & max hints involves a lot of comparison & branching while checking each item.
I opted to KISS, just do one pass & haveshrink_to_fitwork on the TMBitset itself with no extra data passed in. Just find the first & last set bit and off we go. Hey, at least the branching while we're finding them will be 100% predictable!
Activity
yakra commentedon Feb 29, 2024
yakra commentedon Apr 3, 2024
@jteresco, I came across something interesting when working on this.
Here's the relevant part of a work-in-progress
Region::VertexThread:It produces the same* graphs as existing siteupdate.
(*meaning, same vertices & edges, but in a different order. Run them thru canonicaltmg and there's no diff.)
Now compare what I did originally:
This does the active/preview check at the Route level, without having to check every single Waypoint.
Diffs (HwyData @
1f85330):Worldwide, the bottom version omitted 5 points in 4 graphs in 3 regions. Check`em out in the HDX.
M3@COD/ZMBandM3Muf@ZMB/CODin the narrow southeastern part of the country that protrudes into Zambia.RN4@BDI/CODabout a mile N of Lake Tanganyika. Gotta zoom in a bit to see it clearly.H10@NPL/INDabout halfway along the India/Nepal borderAH21@VNM/KHMis easy to spot at the default zoom level in my browser.These vertices were excluded because there's no active/preview Waypoint in the relevant region itself.
They "do and do not" belong in these regions. I can see arguments for or against including them.
This is what we've been doing all along.
If there were an NMP here, there's no question the devel point would be left out, with either version of the code.
Looking at this another way...
Here's part of the
HGVertexconstructor in the current production code:DataProcessing/siteupdate/cplusplus/classes/GraphGeneration/HGVertex.cpp
Lines 30 to 35 in fd96ac6
Looks like siteupdate.py originally behaved the same way -- the a/p check wasn't done, and region graphs included vertices with only devel points there.
If this were instead
...or if the original siteupdate.py had had an equivalent check, we'd be getting the same results observed above.
Thoughts?
Any opinion on whether these points should be included or excluded?
The more I think about it, the more I lean toward exclusion.
We should be consistent in the "active/preview only" approach, and treat devel systems like they don't exist at all.
Oh, and simpler more efficient code is a plus too! ;)
Canonical Waypoint Name simplification is something to consider too -- "M3@COD/ZMB" indicates just one route (as there was only 1 route in the a/p coloc list). And M3 only exists in ZMB, not COD.
If the
codndevel system didn't exist,M3@COD/ZMBwould exist, with the same name, in ZMB only.yakra commentedon Apr 3, 2024
For curiosity's sake, here's an alternate "check every point" solution that inlines the functionality of
is_or_colocated_with_active_or_preview()andhashpoint(), using onecolocatedcheck that'd otherwise be done for each. Also saves the conditional on theis_or_coloc...call itself.In reality, there's little to no point in using this. Better to just go whole hog & either...
yakra commentedon May 15, 2024
Another reason I think omitting the vertices is justified:
In graphs restricted by system, edge names only include the route names from the relevant systems.
This is similar in that info not relevant to the graph's restrictions is omitted.
Let's just not think too hard about the counterexample, vertex
unique_names. ;) These are the same across the board, in tm-master & all subgraphs, regardless of any restrictions by region or system. Doing otherwise would require a lot of extra computation for little questionable gain. :)