From c42ea0209d413e61887ba9afe1c99bf596d7d91e Mon Sep 17 00:00:00 2001 From: Luc Blaeser <112870813+luc-blaeser@users.noreply.github.com> Date: Thu, 4 Jul 2024 11:37:05 +0200 Subject: [PATCH] Make CI Performance Comparison Test Deterministic (#4597) One performance test case, `dao.mo`, uses heartbeats that lead to non-deterministic results in instruction costs, as seen in https://github.com/dfinity/motoko/pull/4587 and https://github.com/dfinity/motoko/pull/4596. This PR fixes this issue, by calling the former heartbeat function explicitly in the performance test. Special thanks to @crusso for giving the hint to this cause. --- test/perf/dao.mo | 11 +++++++---- test/perf/ok/dao.drun-run.ok | 4 +++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/test/perf/dao.mo b/test/perf/dao.mo index 42cd4155a9f..63eea6bc9bd 100644 --- a/test/perf/dao.mo +++ b/test/perf/dao.mo @@ -25,9 +25,10 @@ shared({caller = creator}) actor class DAO() = Self { stable var next_proposal_id : Nat = 0; stable var system_params : Types.SystemParams = init.system_params; - system func heartbeat() : async () { - await execute_accepted_proposals(); - }; + // Disabled because it leads to non-deterministic performance measurements. + // system func heartbeat() : async () { + // await execute_accepted_proposals(); + // }; func account_get(id : Principal) : ?Types.Tokens = Trie.get(accounts, Types.account_key(id), Principal.equal); func account_put(id : Principal, tokens : Types.Tokens) { @@ -197,7 +198,7 @@ shared({caller = creator}) actor class DAO() = Self { }; /// Execute all accepted proposals - func execute_accepted_proposals() : async () { + public func execute_accepted_proposals() : async () { let accepted_proposals = Trie.filter(proposals, func (_ : Nat, proposal : Types.Proposal) : Bool = proposal.state == #accepted); // Update proposal state, so that it won't be picked up by the next heartbeat for ((id, proposal) in Trie.iter(accepted_proposals)) { @@ -267,6 +268,7 @@ shared({caller = creator}) actor class DAO() = Self { //CALL ingress submit_proposal 0x4449444c026c03e1edeb4a71b3c4b1f20468c7ebc4d009016d7b0100087472616e73666572010a000000000000000001012a4449444c026c02fbca0168d8a38ca80d016c01b9ef9380087d0100010a00000000000000000101b0ea01 //CALL query list_proposals 0x4449444C0000 //CALL query list_accounts 0x4449444C0000 +//CALL ingress execute_accepted_proposals 0x4449444C0000 //CALL query get_proposal 0x4449444c00017d00 //CALL query get_proposal 0x4449444c00017d01 @@ -276,3 +278,4 @@ shared({caller = creator}) actor class DAO() = Self { //CALL ingress vote 0x4449444c026c02ea99cff204018882e69c0a7d6b02c1c0017fa7d2f0027f01000101 //CALL ingress vote 0x4449444c026c02ea99cff204018882e69c0a7d6b02c1c0017fa7d2f0027f01000101 //CALL query get_proposal 0x4449444c00017d01 +//CALL ingress execute_accepted_proposals 0x4449444C0000 diff --git a/test/perf/ok/dao.drun-run.ok b/test/perf/ok/dao.drun-run.ok index a4bd29320c1..bbb43dfac1c 100644 --- a/test/perf/ok/dao.drun-run.ok +++ b/test/perf/ok/dao.drun-run.ok @@ -8,10 +8,12 @@ Ok: Reply: 0x4449444c026c03e1edeb4a71b3c4b1f20468c7ebc4d009016d7b0100087472616e7 ingress Completed: Reply: 0x4449444c016b029cc2017de58eb4027101000001 Ok: Reply: 0x4449444c086d016c08dbb7017db793e6d10307abfec2a4060591ecada00804d6a9bbae0a7cb4bfd4960b68f18d9dc10b078effd6e90e026c03e1edeb4a71b3c4b1f20468c7ebc4d009036d7b6b06ca87d0cd047ffefe8fdc0a7fb2d5bc880b7fe7fadec00c7fbd8bfbbf0e71e1aca5d90f7f6e066c02006801056c01b9ef9380087d01000201000000b2af9d1401010400087472616e73666572010a000000000000000001012a4449444c026c02fbca0168d8a38ca80d016c01b9ef9380087d0100010a00000000000000000101b0ea0100000000b2af9d14010104000564756d6d79010a0000000000000000010100 Ok: Reply: 0x4449444c036d016c02b3b0dac30368daae9c8f09026c01b9ef9380087d010001010104e0b8b301 +ingress Completed: Reply: 0x4449444c0000 Ok: Reply: 0x4449444c086e016c08dbb7017db793e6d10307abfec2a4060591ecada00804d6a9bbae0a7cb4bfd4960b68f18d9dc10b078effd6e90e026c03e1edeb4a71b3c4b1f20468c7ebc4d009036d7b6b06ca87d0cd047ffefe8fdc0a7fb2d5bc880b7fe7fadec00c7fbd8bfbbf0e71e1aca5d90f7f6e066c02006801056c01b9ef9380087d01000100000000b2af9d14010104000564756d6d79010a0000000000000000010100 Ok: Reply: 0x4449444c086e016c08dbb7017db793e6d10307abfec2a4060591ecada00804d6a9bbae0a7cb4bfd4960b68f18d9dc10b078effd6e90e026c03e1edeb4a71b3c4b1f20468c7ebc4d009036d7b6b06ca87d0cd047ffefe8fdc0a7fb2d5bc880b7fe7fadec00c7fbd8bfbbf0e71e1aca5d90f7f6e066c02006801056c01b9ef9380087d01000101000000b2af9d1401010400087472616e73666572010a000000000000000001012a4449444c026c02fbca0168d8a38ca80d016c01b9ef9380087d0100010a00000000000000000101b0ea01 Ok: Reply: 0x4449444c086e016c08dbb7017db793e6d10307abfec2a4060591ecada00804d6a9bbae0a7cb4bfd4960b68f18d9dc10b078effd6e90e026c03e1edeb4a71b3c4b1f20468c7ebc4d009036d7b6b06ca87d0cd047ffefe8fdc0a7fb2d5bc880b7fe7fadec00c7fbd8bfbbf0e71e1aca5d90f7f6e066c02006801056c01b9ef9380087d010000 Ok: Reply: 0x4449444c026c02ea99cff204018882e69c0a7d6b02c1c0017fa7d2f0027f01000101 ingress Completed: Reply: 0x4449444c026b029cc20101e58eb402716b06ca87d0cd047ffefe8fdc0a7fb2d5bc880b7fe7fadec00c7fbd8bfbbf0e71e1aca5d90f7f01000003 ingress Completed: Reply: 0x4449444c026b029cc20101e58eb402716b06ca87d0cd047ffefe8fdc0a7fb2d5bc880b7fe7fadec00c7fbd8bfbbf0e71e1aca5d90f7f0100012150726f706f73616c2031206973206e6f74206f70656e20666f7220766f74696e67 -Ok: Reply: 0x4449444c086e016c08dbb7017db793e6d10307abfec2a4060591ecada00804d6a9bbae0a7cb4bfd4960b68f18d9dc10b078effd6e90e026c03e1edeb4a71b3c4b1f20468c7ebc4d009036d7b6b06ca87d0cd047ffefe8fdc0a7fb2d5bc880b7fe7fadec00c7fbd8bfbbf0e71e1aca5d90f7f6e066c02006801056c01b9ef9380087d0100010100010101040005b2af9d14010104e0b8b301087472616e73666572010a000000000000000001012a4449444c026c02fbca0168d8a38ca80d016c01b9ef9380087d0100010a00000000000000000101b0ea01 +Ok: Reply: 0x4449444c086e016c08dbb7017db793e6d10307abfec2a4060591ecada00804d6a9bbae0a7cb4bfd4960b68f18d9dc10b078effd6e90e026c03e1edeb4a71b3c4b1f20468c7ebc4d009036d7b6b06ca87d0cd047ffefe8fdc0a7fb2d5bc880b7fe7fadec00c7fbd8bfbbf0e71e1aca5d90f7f6e066c02006801056c01b9ef9380087d0100010100010101040003b2af9d14010104e0b8b301087472616e73666572010a000000000000000001012a4449444c026c02fbca0168d8a38ca80d016c01b9ef9380087d0100010a00000000000000000101b0ea01 +ingress Completed: Reply: 0x4449444c0000