lf-lang / reactor-uc

A lightweight reactor runtime targeted at resource-constrained embedded systems
BSD 2-Clause "Simplified" License
2 stars 2 forks source link

Implement event payload allocator #71

Closed erlingrj closed 1 week ago

erlingrj commented 2 weeks ago

This PR is quite big and does several things.

  1. Introduces an event payload allocator and thus relaxing the constraint on having to schedule actions monotonically. This triggered a bit of a redesign of the Trigger type hierarchy. #70
  2. Updates LFC to use the new macros.
  3. Refactors the macros such that they match how lfc generates code #77
  4. Merges Physical+Logical Action, Delayed+Physical connections and Startup+Shutdown to avoid code duplication #76
  5. I commented out the entire federate example on POSIX because this is ported over to macros in #73
github-actions[bot] commented 1 week ago

Memory usage after merging this PR will be:

Memory Report ## action_microstep_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 71299 | 67193 | -5.76 | | data | 960 | 960 | 0.00 | | bss | 480 | 480 | 0.00 | | total | 72739 | 68633 | -5.64 | ## action_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 71099 | 66993 | -5.78 | | data | 960 | 960 | 0.00 | | bss | 480 | 480 | 0.00 | | total | 72539 | 68433 | -5.66 | ## delayed_conn_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 75610 | 69942 | -7.50 | | data | 952 | 952 | 0.00 | | bss | 480 | 480 | 0.00 | | total | 77042 | 71374 | -7.36 | ## event_payload_pool_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 23406 | 18297 | -21.83 | | data | 648 | 624 | -3.70 | | bss | 320 | 320 | 0.00 | | total | 24374 | 19241 | -21.06 | ## event_queue_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 72123 | 23203 | -67.83 | | data | 961 | 656 | -31.74 | | bss | 1952 | 320 | -83.61 | | total | 75036 | 24179 | -67.78 | ## physical_action_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 75576 | 68047 | -9.96 | | data | 952 | 961 | 0.95 | | bss | 480 | 2016 | 320.00 | | total | 77008 | 71024 | -7.77 | ## port_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 23083 | 69875 | 202.71 | | data | 648 | 952 | 46.91 | | bss | 320 | 480 | 50.00 | | total | 24051 | 71307 | 196.48 | ## reaction_queue_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 67430 | 22835 | -66.14 | | data | 960 | 656 | -31.67 | | bss | 480 | 320 | -33.33 | | total | 68870 | 23811 | -65.43 | ## shutdown_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 66746 | 64310 | -3.65 | | data | 960 | 960 | 0.00 | | bss | 480 | 480 | 0.00 | | total | 68186 | 65750 | -3.57 | ## startup_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 66583 | 63620 | -4.45 | | data | 952 | 960 | 0.84 | | bss | 480 | 480 | 0.00 | | total | 68015 | 65060 | -4.34 | ## timer_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 19344 | 63705 | 229.33 | | data | 648 | 952 | 46.91 | | bss | 320 | 480 | 50.00 | | total | 20312 | 65137 | 220.68 |
github-actions[bot] commented 1 week ago

Memory usage after merging this PR will be:

Memory Report ## action_microstep_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 71299 | 67193 | -5.76 | | data | 960 | 960 | 0.00 | | bss | 480 | 480 | 0.00 | | total | 72739 | 68633 | -5.64 | ## action_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 71099 | 66993 | -5.78 | | data | 960 | 960 | 0.00 | | bss | 480 | 480 | 0.00 | | total | 72539 | 68433 | -5.66 | ## delayed_conn_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 75610 | 69942 | -7.50 | | data | 952 | 952 | 0.00 | | bss | 480 | 480 | 0.00 | | total | 77042 | 71374 | -7.36 | ## event_payload_pool_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 23406 | 18297 | -21.83 | | data | 648 | 624 | -3.70 | | bss | 320 | 320 | 0.00 | | total | 24374 | 19241 | -21.06 | ## event_queue_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 72123 | 23203 | -67.83 | | data | 961 | 656 | -31.74 | | bss | 1952 | 320 | -83.61 | | total | 75036 | 24179 | -67.78 | ## physical_action_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 75576 | 68047 | -9.96 | | data | 952 | 961 | 0.95 | | bss | 480 | 2016 | 320.00 | | total | 77008 | 71024 | -7.77 | ## port_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 23083 | 69875 | 202.71 | | data | 648 | 952 | 46.91 | | bss | 320 | 480 | 50.00 | | total | 24051 | 71307 | 196.48 | ## reaction_queue_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 67430 | 22835 | -66.14 | | data | 960 | 656 | -31.67 | | bss | 480 | 320 | -33.33 | | total | 68870 | 23811 | -65.43 | ## shutdown_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 66746 | 64310 | -3.65 | | data | 960 | 960 | 0.00 | | bss | 480 | 480 | 0.00 | | total | 68186 | 65750 | -3.57 | ## startup_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 66583 | 63620 | -4.45 | | data | 952 | 960 | 0.84 | | bss | 480 | 480 | 0.00 | | total | 68015 | 65060 | -4.34 | ## timer_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 19344 | 63705 | 229.33 | | data | 648 | 952 | 46.91 | | bss | 320 | 480 | 50.00 | | total | 20312 | 65137 | 220.68 |
github-actions[bot] commented 1 week ago

Memory usage after merging this PR will be:

Memory Report ## action_microstep_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 71299 | 70535 | -1.07 | | data | 960 | 960 | 0.00 | | bss | 480 | 480 | 0.00 | | total | 72739 | 71975 | -1.05 | ## action_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 71099 | 70356 | -1.05 | | data | 960 | 960 | 0.00 | | bss | 480 | 480 | 0.00 | | total | 72539 | 71796 | -1.02 | ## delayed_conn_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 75610 | 74153 | -1.93 | | data | 952 | 952 | 0.00 | | bss | 480 | 480 | 0.00 | | total | 77042 | 75585 | -1.89 | ## event_payload_pool_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 23406 | 18297 | -21.83 | | data | 648 | 624 | -3.70 | | bss | 320 | 320 | 0.00 | | total | 24374 | 19241 | -21.06 | ## event_queue_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 72123 | 23427 | -67.52 | | data | 961 | 656 | -31.74 | | bss | 1952 | 320 | -83.61 | | total | 75036 | 24403 | -67.48 | ## physical_action_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 75576 | 71345 | -5.60 | | data | 952 | 961 | 0.95 | | bss | 480 | 2016 | 320.00 | | total | 77008 | 74322 | -3.49 | ## port_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 23083 | 74103 | 221.03 | | data | 648 | 952 | 46.91 | | bss | 320 | 480 | 50.00 | | total | 24051 | 75535 | 214.06 | ## reaction_queue_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 67430 | 23091 | -65.76 | | data | 960 | 656 | -31.67 | | bss | 480 | 320 | -33.33 | | total | 68870 | 24067 | -65.05 | ## shutdown_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 66746 | 67490 | 1.11 | | data | 960 | 960 | 0.00 | | bss | 480 | 480 | 0.00 | | total | 68186 | 68930 | 1.09 | ## startup_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 66583 | 66821 | 0.36 | | data | 952 | 960 | 0.84 | | bss | 480 | 480 | 0.00 | | total | 68015 | 68261 | 0.36 | ## timer_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 19344 | 66864 | 245.66 | | data | 648 | 952 | 46.91 | | bss | 320 | 480 | 50.00 | | total | 20312 | 68296 | 236.23 |
github-actions[bot] commented 1 week ago

Memory usage after merging this PR will be:

Memory Report ## action_microstep_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 71299 | 70535 | -1.07 | | data | 960 | 960 | 0.00 | | bss | 480 | 480 | 0.00 | | total | 72739 | 71975 | -1.05 | ## action_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 71099 | 70356 | -1.05 | | data | 960 | 960 | 0.00 | | bss | 480 | 480 | 0.00 | | total | 72539 | 71796 | -1.02 | ## delayed_conn_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 75610 | 74153 | -1.93 | | data | 952 | 952 | 0.00 | | bss | 480 | 480 | 0.00 | | total | 77042 | 75585 | -1.89 | ## event_payload_pool_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 23406 | 18297 | -21.83 | | data | 648 | 624 | -3.70 | | bss | 320 | 320 | 0.00 | | total | 24374 | 19241 | -21.06 | ## event_queue_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 72123 | 23427 | -67.52 | | data | 961 | 656 | -31.74 | | bss | 1952 | 320 | -83.61 | | total | 75036 | 24403 | -67.48 | ## physical_action_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 75576 | 71345 | -5.60 | | data | 952 | 961 | 0.95 | | bss | 480 | 2016 | 320.00 | | total | 77008 | 74322 | -3.49 | ## port_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 23083 | 74103 | 221.03 | | data | 648 | 952 | 46.91 | | bss | 320 | 480 | 50.00 | | total | 24051 | 75535 | 214.06 | ## reaction_queue_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 67430 | 23091 | -65.76 | | data | 960 | 656 | -31.67 | | bss | 480 | 320 | -33.33 | | total | 68870 | 24067 | -65.05 | ## shutdown_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 66746 | 67490 | 1.11 | | data | 960 | 960 | 0.00 | | bss | 480 | 480 | 0.00 | | total | 68186 | 68930 | 1.09 | ## startup_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 66583 | 66821 | 0.36 | | data | 952 | 960 | 0.84 | | bss | 480 | 480 | 0.00 | | total | 68015 | 68261 | 0.36 | ## timer_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 19344 | 66864 | 245.66 | | data | 648 | 952 | 46.91 | | bss | 320 | 480 | 50.00 | | total | 20312 | 68296 | 236.23 |
github-actions[bot] commented 1 week ago

Memory usage after merging this PR will be:

Memory Report ## action_microstep_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 71299 | 70535 | -1.07 | | data | 960 | 960 | 0.00 | | bss | 480 | 480 | 0.00 | | total | 72739 | 71975 | -1.05 | ## action_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 71099 | 70356 | -1.05 | | data | 960 | 960 | 0.00 | | bss | 480 | 480 | 0.00 | | total | 72539 | 71796 | -1.02 | ## delayed_conn_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 75610 | 74153 | -1.93 | | data | 952 | 952 | 0.00 | | bss | 480 | 480 | 0.00 | | total | 77042 | 75585 | -1.89 | ## event_payload_pool_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 23406 | 18297 | -21.83 | | data | 648 | 624 | -3.70 | | bss | 320 | 320 | 0.00 | | total | 24374 | 19241 | -21.06 | ## event_queue_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 72123 | 23427 | -67.52 | | data | 961 | 656 | -31.74 | | bss | 1952 | 320 | -83.61 | | total | 75036 | 24403 | -67.48 | ## physical_action_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 75576 | 71345 | -5.60 | | data | 952 | 961 | 0.95 | | bss | 480 | 2016 | 320.00 | | total | 77008 | 74322 | -3.49 | ## port_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 23083 | 74103 | 221.03 | | data | 648 | 952 | 46.91 | | bss | 320 | 480 | 50.00 | | total | 24051 | 75535 | 214.06 | ## reaction_queue_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 67430 | 23091 | -65.76 | | data | 960 | 656 | -31.67 | | bss | 480 | 320 | -33.33 | | total | 68870 | 24067 | -65.05 | ## shutdown_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 66746 | 67490 | 1.11 | | data | 960 | 960 | 0.00 | | bss | 480 | 480 | 0.00 | | total | 68186 | 68930 | 1.09 | ## startup_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 66583 | 66821 | 0.36 | | data | 952 | 960 | 0.84 | | bss | 480 | 480 | 0.00 | | total | 68015 | 68261 | 0.36 | ## timer_test_c | | from | to | increase (%) | | -- | ---- | ------ | ------------ | | text | 19344 | 66864 | 245.66 | | data | 648 | 952 | 46.91 | | bss | 320 | 480 | 50.00 | | total | 20312 | 68296 | 236.23 |
github-actions[bot] commented 1 week ago

Coverage after merging allocator into main will be

35.28%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
external/nanopb
   pb_common.c0%0%0%0%100, 100, 100, 100, 100, 102, 106, 110, 110, 110, 110, 110, 112, 116, 119, 122, 124, 126, 126, 126, 129–132, 14, 14, 14, 142–144, 15, 150–152, 152, 152, 152, 152, 154, 156, 158, 160–161, 163, 166, 168, 17, 171–172, 172, 172, 177, 18, 181, 184–185, 188, 190–192, 195, 197, 197, 197, 199, 20, 20, 20, 20, 20, 201, 201, 201, 203, 207, 210, 210, 210, 215, 22, 221, 224, 226, 226, 226, 229, 231, 231, 231–232, 232, 232, 235, 238, 238, 238, 24, 241–242, 246, 248, 248, 248, 25, 250, 254, 26, 260, 263, 265, 265, 265, 267, 269, 269, 269, 27, 272–273, 277, 28, 286–287, 29, 290, 292, 295, 297, 300, 302, 302, 302, 304, 306, 306, 306, 308, 308, 308, 308, 308, 310, 313, 313, 313, 313, 313, 315, 32, 320, 34, 36–41, 44, 46–48, 50–55, 58, 60–63, 65–70, 74, 74, 74, 77–78, 8, 82, 84, 84, 84, 86, 88, 88, 88–89, 89, 89–90, 90, 90, 93, 97
   pb_decode.c0%0%0%0%100, 1000–1001, 1003–1004, 1007, 1007, 1007, 1009, 1009, 1009, 1011, 1011, 1011–1012, 1012, 1012, 1016, 1016, 1016, 1022, 1022, 1022, 1024, 1024, 1024–1025, 1027, 1030, 1030, 1030, 1032, 1032, 1032, 1034, 1038, 1038, 1038, 104, 104, 104, 1042, 1042, 1042, 1042, 1042, 1045, 1045, 1045, 1047, 1047, 1047, 1049, 105, 105, 105, 1050, 1053, 1053, 1053, 1055, 1059, 1059, 1059, 1061, 1063, 1063, 1063–1064, 1066, 1066, 1066, 1069, 1074, 1074, 1074–1076, 108, 108, 108, 1082, 1082, 1082, 1082, 1082, 1084, 1084, 1084, 1089, 1089, 1089, 109, 109, 109, 1090, 1090, 1090, 1092, 1092, 1092, 1095–1097, 1100, 1103, 1103, 1103–1104, 1104, 1104, 1106–1107, 1110, 1110, 1110–1111, 1115, 1115, 1115–1116, 1116, 1116, 1118, 1118, 1118, 1123, 1125, 1125, 1125, 1129, 1129, 1129–1130, 1133, 1133, 1133, 1135, 1135, 1135–1136, 1136, 1136, 1140, 1140, 1140, 1142–1143, 1143, 1143, 1145, 1145, 1145, 115, 115, 115, 1151, 1154, 1158, 1158, 1158, 116, 1160, 1165, 1165, 1165–1166, 1168, 1170, 1170, 1170–1171, 1179, 118, 1182, 1186, 1193, 120, 125, 127, 127, 127–128, 128, 128, 131, 131, 131–132, 132, 132, 1336, 1341, 1346, 1349, 1349, 1349–1350, 1352–1353, 1356, 1359, 1359, 1359–1360, 1362, 1362, 1362–1363, 1365, 1367, 1370, 1377, 1377, 1377–1378, 138, 1382, 1389, 1393, 140, 1400, 1400, 1400–1401, 1405, 1416, 1420, 1422, 1425, 1427, 1427, 1427, 143, 1430, 1430, 1430–1431, 1434, 1434, 1434–1436, 1436, 1436–1438, 1438, 1438–1440, 1440, 1440–1441, 1443, 1443, 1443, 1445, 1445, 1445–1446, 1446, 1446, 1448, 1456, 1456, 1456, 1458, 1458, 1458–1459, 1463, 1463, 1463–1464, 1472, 1472, 1472–1473, 1475, 1479, 1479, 1479–1481, 1481, 1481–1483, 1483, 1483–1485, 1485, 1485–1486, 1488, 1488, 1488, 1490, 1490, 1490–1491, 1491, 1491, 1493, 1497, 1503, 1503, 1503–1504, 1506, 1506, 1506–1507, 1507, 1507, 1509–1510, 1510, 1510–1511, 1511, 1511, 1513, 1513, 1513, 1516, 1516, 1516, 1528, 1528, 1528–1529, 1529, 1529–1530, 1533–1534, 1537, 1541, 1543, 1543, 1543–1544, 1546, 1546, 1546–1547, 1547, 1547, 1550, 1552, 1552, 1552–1553, 1553, 1553, 1555,