mratsim / weave

A state-of-the-art multithreading runtime: message-passing based, fast, scalable, ultra-low overhead
Other
537 stars 20 forks source link

MPSC count can become negative #49

Closed mratsim closed 4 years ago

mratsim commented 4 years ago

Even though the count is done on the consumer side which should always underestimate the real count, the number of estimated enqueued item in the MPSC channel can be negative.

See https://github.com/mratsim/weave/pull/48#issuecomment-565815476 and CI https://dev.azure.com/numforge/Weave/_build/results?buildId=25&view=logs

This is not blocking as this count is only informative and used for adaptative stealing and for the memory pool to trigger batch reception of memory.

This is something I actualy remarked in the past but seems to happen rarely: https://github.com/mratsim/weave/blob/fffffd1ec50d52b601a5a5569ef1fe2ad10de7e8/weave/channels/channels_mpsc_unbounded_batch.nim#L208-L220

mratsim commented 4 years ago

Hopefully solved by partial model checking in #128 (memory bug on the model checker that interrupts it, ...)

mratsim commented 4 years ago

Still happening in the memory pool:

========================================================================================
Running [ c  ] weave/memory/memory_pools.nim
========================================================================================
Single-threaded: System alloc for 100 blocks: 0.9514 s
Single-threaded: Pool   alloc for 100 blocks: 0.4980 s
Multi-threaded: System alloc: 0.0331 s
fatal.nim(49)            sysFatal
Error: unhandled exception: contracts.nim(86, 15) `
0 <= chan.count.load(moRelaxed)` 
    Contract violated for post-condition at channels_mpsc_unbounded_batch.nim:250

0 <= chan.count.load(moRelaxed)
    The following values are contrary to expectations:

0 <= chan.count.load(moRelaxed)  [Worker N/A]
 [AssertionError]
Error: execution of an external program failed: '/home/vsts/work/1/s/build/memory_pools '
stack trace: (most recent call last)
/tmp/nimblecache/nimscriptapi.nim(165, 16)
/home/vsts/work/1/s/weave_5847.nims(46, 8) testTask
/home/vsts/work/1/s/weave_5847.nims(32, 8) test
/home/vsts/work/1/s/NimBinaries/nim-stable/lib/system/nimscript.nim(260, 7) exec
/home/vsts/work/1/s/NimBinaries/nim-stable/lib/system/nimscript.nim(260, 7) Error: unhandled exception: FAILED: nim c  --verbosity:0 --hints:off --warnings:off --threads:on -d:release --outdir:build -r weave/memory/memory_pools.nim [OSError]
       Tip: 1 messages have been suppressed, use --verbose to show them.
     Error: Exception raised during nimble script execution