Closed yakra closed 7 months ago
- Con: More mutex contention; multiple travelers could be trying to add the same route even if not the same segment.
No noticeable difference. With so many routes in the system, the odds of 2+ travelers trying to add the same one at the same time are already vanishingly small. Performs better.
- Con: Indirection.
No, scratch that. Same amount.
- Con: More contention; mutex also used for marking labels in use. Faster to add another?
Still not enough contention to degrade performance.
On the contrary, 1 mutex performs better than 2, whether it's smaller sizeof
, just noise in the data, or whatever.
So let's keep the code simple & save RAM.
t->clinched_segments.push_back(hs);
yadda yadda
Leaving as is & accepting "the performance hit" is already a big performance boost.
Plus, ConcAugThread & TravelerList::clinched_segments
can be removed entirely.
See TravelMapping#151 & 0b6711d
on BiggaTomato.
y253 @ e7dad8c
, more locks/unlocks, fewer ternaries
Benchmark. Does this perform better or worse?
Appears to perform every-so-slightly worse. Plus, parent had cleaner code.
Undid a few things from parent, 90f08a1
:
else
block) to forward or backward?
block just above.
Plus mutexes: r1->mtx.lock(); r1->mark_label_in_use(fields[5]); r1->mtx.unlock();
etc.
Carved out of #221:
Eliminating HighwaySegment::clin_mtx would get
sizeof(HighwaySegment)
down to 72 B, with potential to get even smaller. This could potentially speed up multiple tasks. Calls to add_clinched_by could be removed, instead calling TMBitset::add_index directly and locking/unlockingRoute::mtx
before/after, however's most efficient.Overall pros & cons:
sizeof(HighwaySegment)
.Route::store_traveled_segments could handle all the segments it needs to with one lock/unlock per call.
t->clinched_segments.push_back(hs);
within the lock. Possible things to do include:t->clinched_segments
, creating a performance hit when augmenting concurrencies. Either...TravelerList::clinched_segments
storepair
s of waypoints. Push beginning & end once per call.For concurrency augments, multiple successive segments are likely to have the same route due to being added in series by
Route::store_traveled_segments
. We could...Or alternately, any of a number of more esoteric, incompletely-thought-out ideas to go mutex-free, involving 2D arrays, a separate threaded task for storing traveler with segments, etc. How about this?
clinched_segments = new std::vector<std::pair<HighwaySegment*,size_t>>[args::numthreads];
TravelerList::clinched_segments
to aTMBitset
.~ Nope. Not all stored in contiguous memory. Would have to do one of...unordered_set
. Yecch.threadnum
intoRoute::store_traveled_segments
, however I wanna do it.system->clinched_segments[threadnum].emplace_back(hs, index);
si.first->clinched_by.add_index[si.second];
delete[] clinched_segments;
This all comes with its own overhead, and may or may not be faster than whatever the fastest option above is.
For siteupdateST, skip this extra step and do things more or less as done now.
See also TravelMapping#151.