Skip to content

Commit

Permalink
Make CI Performance Comparison Test Deterministic (#4597)
Browse files Browse the repository at this point in the history
One performance test case, `dao.mo`, uses heartbeats that lead to non-deterministic results in instruction costs, as seen in #4587 and #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.
  • Loading branch information
luc-blaeser authored Jul 4, 2024
1 parent bbd557f commit c42ea02
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 7 additions & 4 deletions test/perf/dao.mo
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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
Expand All @@ -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
4 changes: 3 additions & 1 deletion test/perf/ok/dao.drun-run.ok
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c42ea02

Please sign in to comment.