Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testnet GC, metering #5

Merged
merged 4 commits into from
May 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions xs/sources/xsMapSet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,9 @@ txBoolean fxDeleteEntry(txMachine* the, txSlot* table, txSlot* list, txSlot* key
address = &slot->next;
}
}
#ifdef __XSNAP__
the->mapSetRemoveCount += 1;
#endif
return 1;
}
}
Expand Down Expand Up @@ -1098,6 +1101,9 @@ void fxSetEntry(txMachine* the, txSlot* table, txSlot* list, txSlot* key, txSlot
txSlot* first;
txSlot* last;
txSlot* slot;
#ifdef __XSNAP__
txUnsigned qty = 0;
#endif
while ((entry = *address)) {
if (entry->value.entry.sum == sum) {
first = entry->value.entry.slot;
Expand All @@ -1110,8 +1116,17 @@ void fxSetEntry(txMachine* the, txSlot* table, txSlot* list, txSlot* key, txSlot
return;
}
}
#ifdef __XSNAP__
qty += 1;
#endif
address = &entry->next;
}
#ifdef __XSNAP__
the->mapSetAddCount += 1;
if (qty > the->maxBucketSize) {
the->maxBucketSize = qty;
}
#endif
first = fxNewSlot(the);
first->kind = key->kind;
first->value = key->value;
Expand Down
4 changes: 2 additions & 2 deletions xs/sources/xsMemory.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ void fxCollect(txMachine* the, txBoolean theFlag)
(long)(the->peakHeapCount * sizeof(txSlot)),
the->collectFlag & XS_TRASHING_FLAG);
#endif
#ifdef mxInstrument
#if defined(mxInstrument) || defined(__XSNAP__)
the->garbageCollectionCount++;
#endif
#ifdef mxProfile
Expand Down Expand Up @@ -428,7 +428,7 @@ void fxGrowChunks(txMachine* the, txSize theSize)
if (!(the->collectFlag & XS_SKIPPED_COLLECT_FLAG)) {
txSize modulo = theSize % the->minimumChunksSize;
if (modulo)
fxAddChunkSizes(the, theSize, the->minimumChunksSize - modulo);
theSize = fxAddChunkSizes(the, theSize, the->minimumChunksSize - modulo);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, good catch.

}
theSize = fxAddChunkSizes(the, theSize, sizeof(txBlock));
aData = fxAllocateChunks(the, theSize);
Expand Down