MistInHLS improvements and speedups, part 2/2

This commit is contained in:
Marco van Dijk 2023-06-29 17:28:56 +02:00 committed by Thulinma
parent ed1c291955
commit 9e30444476
6 changed files with 378 additions and 243 deletions

View file

@ -2272,15 +2272,46 @@ namespace DTSC{
}
}
Track &t = tracks[trackIdx];
DONTEVEN_MSG("Deleting parts: %" PRIu64 "->%" PRIu64 " del'd, %zu pres", t.parts.getDeleted(), t.parts.getDeleted()+t.keys.getInt(t.keyPartsField, t.keys.getDeleted()), t.parts.getPresent());
t.parts.deleteRecords(t.keys.getInt(t.keyPartsField, t.keys.getDeleted()));
DONTEVEN_MSG("Deleting key: %" PRIu64 "->%" PRIu64 " del'd, %zu pres", t.keys.getDeleted(), t.keys.getDeleted()+1, t.keys.getPresent());
uint64_t deletedPartCount = t.keys.getInt(t.keyPartsField, t.keys.getDeleted());
DONTEVEN_MSG("Deleting parts: %" PRIu64 "->%" PRIu64 " del'd, %zu pres", t.parts.getDeleted(), t.parts.getDeleted()+deletedPartCount, t.parts.getPresent());
t.parts.deleteRecords(deletedPartCount);
uint64_t deletedKeyNum = t.keys.getDeleted();
DONTEVEN_MSG("Deleting key: %" PRIu64 "->%" PRIu64 " del'd, %zu pres", deletedKeyNum, deletedKeyNum+1, t.keys.getPresent());
t.keys.deleteRecords(1);
if (t.fragments.getInt(t.fragmentFirstKeyField, t.fragments.getDeleted()) < t.keys.getDeleted()){
t.fragments.deleteRecords(1);
setMissedFragments(trackIdx, getMissedFragments(trackIdx) + 1);
}
if (t.pages.getPresent() > 1 && t.pages.getInt("firstkey", t.pages.getDeleted() + 1) < t.keys.getDeleted()){
// Check if any page contains the just-deleted key
for (uint64_t i = t.pages.getDeleted(); i < t.pages.getEndPos(); i++){
uint64_t thisKey = t.pages.getInt("firstkey", i);
uint64_t avtmp = t.pages.getInt("avail", i);
uint64_t keycount = t.pages.getInt("keycount", i);
DONTEVEN_MSG("Found page idx=%lu number=%lu avail=%lu, keycount=%lu", i, thisKey, avtmp, keycount);
uint64_t pageNum = t.pages.getInt("firstkey", i);
if (pageNum > deletedKeyNum) continue;
uint64_t keyCount = t.pages.getInt("keycount", i);
if (keyCount){
if (pageNum + keyCount - 1 < deletedKeyNum) continue;
}else if (pageNum < deletedKeyNum) continue;
uint64_t avail = t.pages.getInt("avail", i);
if (avail){
break;
}
// 'Resize' the page to whatever keys are still available
if (t.pages.getInt("keycount", i) > 1){
DONTEVEN_MSG("Key count %lu -> %lu", t.pages.getInt("keycount", i), t.pages.getInt("keycount", i) - 1);
t.pages.setInt("keycount", t.pages.getInt("keycount", i) - 1, i);
DONTEVEN_MSG("Part count %lu -> %lu", t.pages.getInt("parts", i), t.pages.getInt("parts", i) - deletedPartCount);
t.pages.setInt("parts", t.pages.getInt("parts", i) - deletedPartCount, i);
DONTEVEN_MSG("First key %lu -> %lu", t.pages.getInt("firstkey", i), t.pages.getInt("firstkey", i) + 1);
t.pages.setInt("firstkey", t.pages.getInt("firstkey", i) + 1, i);
break;
}
// Unload the page if there are no more keys left on it
// Initialize the correct page, make it master so it gets cleaned up when leaving scope.
char thisPageName[NAME_BUFFER_SIZE];
snprintf(thisPageName, NAME_BUFFER_SIZE, SHM_TRACK_DATA, streamName.c_str(), trackIdx,
@ -2290,6 +2321,7 @@ namespace DTSC{
// Then delete the page entry
t.pages.deleteRecords(1);
break;
}
setFirstms(trackIdx, t.keys.getInt(t.keyTimeField, t.keys.getDeleted()));
if (resizeLock){resizeLock.unlink();}