revert memory leak fix so we can run tests with new DHT

This commit is contained in:
gmega 2023-11-17 20:17:29 -03:00
parent bb00e3958b
commit b6321dc91c
No known key found for this signature in database
GPG Key ID: FFD8DAF00660270F
2 changed files with 20 additions and 22 deletions

View File

@ -124,8 +124,6 @@ proc handleFutureComplete*[TFutureBase](self: var AsyncProfiler[TFutureBase],
self.futureSummaryMetrics.withValue(loc, metric): self.futureSummaryMetrics.withValue(loc, metric):
metric[].addRun(runMetrics) metric[].addRun(runMetrics)
self.perFutureMetrics.del(fut.id)
if not isNil(self.onChange): if not isNil(self.onChange):
self.onChange() self.onChange()

View File

@ -1,31 +1,31 @@
import pkg/asynctest # import pkg/asynctest
import pkg/chronos # import pkg/chronos
import pkg/codex/utils/asyncprofiler # import pkg/codex/utils/asyncprofiler
type # type
FakeFuture = object # FakeFuture = object
id: uint # id: uint
internalLocation*: array[LocationKind, ptr SrcLoc] # internalLocation*: array[LocationKind, ptr SrcLoc]
suite "asyncprofiler": # suite "asyncprofiler":
test "should not keep metrics for a pending future in memory after it completes": # test "should not keep metrics for a pending future in memory after it completes":
var fakeLoc = SrcLoc(procedure: "foo", file: "foo.nim", line: 1) # var fakeLoc = SrcLoc(procedure: "foo", file: "foo.nim", line: 1)
let future = FakeFuture( # let future = FakeFuture(
id: 1, # id: 1,
internalLocation: [ # internalLocation: [
LocationKind.Create: addr fakeLoc, # LocationKind.Create: addr fakeLoc,
LocationKind.Finish: addr fakeLoc, # LocationKind.Finish: addr fakeLoc,
]) # ])
var profiler = AsyncProfiler[FakeFuture]() # var profiler = AsyncProfiler[FakeFuture]()
profiler.handleFutureCreate(future) # profiler.handleFutureCreate(future)
profiler.handleFutureComplete(future) # profiler.handleFutureComplete(future)
check len(profiler.getPerFutureMetrics()) == 0 # check len(profiler.getPerFutureMetrics()) == 0