Verified Commit 71d5da7b authored by Camil Staps's avatar Camil Staps 🚀

MemoryLeaks test: measure entire IWorld size, except share names

parent 54c6ce7a
Pipeline #47852 passed with stages
in 9 minutes and 7 seconds
......@@ -19,10 +19,10 @@ repetitions =: 1000
tests :: [UnitTest]
tests =:
[ memoryConsumptionOf "recursive step" getSharesSize
, memoryConsumptionOf "local share" (withShared 3 \_ -> getSharesSize)
, memoryConsumptionOf "parallel task" (viewInformation [] 3 ||- getSharesSize)
, memoryConsumptionOf "shared interaction task" (withShared 3 \sds -> viewSharedInformation [] sds ||- getSharesSize)
[ memoryConsumptionOf "recursive step" getIWorldSize
, memoryConsumptionOf "local share" (withShared 3 \_ -> getIWorldSize)
, memoryConsumptionOf "parallel task" (viewInformation [] 3 ||- getIWorldSize)
, memoryConsumptionOf "shared interaction task" (withShared 3 \sds -> viewSharedInformation [] sds ||- getIWorldSize)
]
memoryConsumptionOf :: !String !(Task Int) -> UnitTest
......@@ -54,9 +54,16 @@ where
CustomFailReason $
concat ["Memory consumption increased by ", toString $ endSize - initSize, " bytes."]
getSharesSize :: Task Int
getSharesSize = mkInstantTask \_ iworld=:{memoryShares}
-> (Ok ('Map'.foldrNoKey ((+) o nodeSize) 0 memoryShares), iworld)
where
nodeSize :: !.a -> Int
nodeSize x = size (copy_to_string x)
/* NB: We subtract the size of the names of shares. Because share names include
* TaskIds in string representation, and these IDs are incremented, including
* share names may cause the IWorld size to increase; we want to ignore these
* small changes.
*/
getIWorldSize :: Task Int
getIWorldSize = mkInstantTask \_ iworld=:{memoryShares}
# iworldString = copy_to_string iworld
# (iworldSize,iworldString) = usize iworldString
# (iworld,_) = copy_from_string iworldString
# shareNamesSize = 'Map'.foldrWithKey` (\k _ n -> n + size (copy_to_string k)) 0 memoryShares
// We cannot simply fold with `size k` due to padding in `copy_to_string`.
-> (Ok (iworldSize - shareNamesSize), iworld)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment