diff --git a/crates/bashkit-bench/results/bench-a9d59d0fdfe3-linux-x86_64-1795316001.json b/crates/bashkit-bench/results/bench-a9d59d0fdfe3-linux-x86_64-1795316001.json new file mode 100644 index 000000000..d68bf02bd --- /dev/null +++ b/crates/bashkit-bench/results/bench-a9d59d0fdfe3-linux-x86_64-1795316001.json @@ -0,0 +1,4842 @@ +{ + "moniker": "a9d59d0fdfe3-linux-x86_64", + "timestamp": "1795316001", + "system": { + "hostname": "a9d59d0fdfe3", + "os": "linux", + "arch": "x86_64", + "cpus": 4, + "moniker": "a9d59d0fdfe3-linux-x86_64" + }, + "iterations": 10, + "warmup": 2, + "prewarm_cases": 3, + "runners": [ + "bashkit", + "bash" + ], + "runner_versions": { + "bash": "/usr/bin/bash (GNU Bash 5.2.37(1)-release)" + }, + "results": [ + { + "runner": "bashkit", + "case_name": "startup_empty", + "category": "startup", + "iterations": 10, + "times_ns": [ + 85923, + 76424, + 74824, + 145893, + 93542, + 75784, + 73536, + 73485, + 77943, + 228279 + ], + "mean_ns": 100563.3, + "stddev_ns": 47396.55798905655, + "min_ns": 73485, + "max_ns": 228279, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "startup_empty", + "category": "startup", + "iterations": 10, + "times_ns": [ + 1749176, + 2014247, + 1617758, + 1871458, + 1606842, + 1452430, + 1493636, + 1464659, + 1831506, + 1907624 + ], + "mean_ns": 1700933.6, + "stddev_ns": 191223.61001623204, + "min_ns": 1452430, + "max_ns": 2014247, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "startup_true", + "category": "startup", + "iterations": 10, + "times_ns": [ + 77305, + 75424, + 83561, + 72531, + 71557, + 106707, + 73597, + 70129, + 70421, + 70653 + ], + "mean_ns": 77188.5, + "stddev_ns": 10581.73406630501, + "min_ns": 70129, + "max_ns": 106707, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "startup_true", + "category": "startup", + "iterations": 10, + "times_ns": [ + 1740002, + 2324763, + 1779903, + 1595774, + 1629895, + 1600826, + 1705838, + 1985560, + 1847481, + 1977098 + ], + "mean_ns": 1818714.0, + "stddev_ns": 215199.70093101898, + "min_ns": 1595774, + "max_ns": 2324763, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "startup_echo", + "category": "startup", + "iterations": 10, + "times_ns": [ + 81890, + 79011, + 78016, + 75910, + 122356, + 77849, + 75037, + 74930, + 75694, + 75687 + ], + "mean_ns": 81638.0, + "stddev_ns": 13727.787687752168, + "min_ns": 74930, + "max_ns": 122356, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "startup_echo", + "category": "startup", + "iterations": 10, + "times_ns": [ + 1717834, + 2056823, + 1685533, + 1836441, + 1690009, + 1615801, + 1737078, + 1602310, + 1715482, + 1944961 + ], + "mean_ns": 1760227.2, + "stddev_ns": 137312.04570888894, + "min_ns": 1602310, + "max_ns": 2056823, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "startup_exit", + "category": "startup", + "iterations": 10, + "times_ns": [ + 83218, + 76247, + 74860, + 73660, + 73798, + 72975, + 72186, + 122475, + 76065, + 72424 + ], + "mean_ns": 79790.8, + "stddev_ns": 14548.187988887139, + "min_ns": 72186, + "max_ns": 122475, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "startup_exit", + "category": "startup", + "iterations": 10, + "times_ns": [ + 1575217, + 1849693, + 1925855, + 1978181, + 1770945, + 1729928, + 1576139, + 1603836, + 1537148, + 1629903 + ], + "mean_ns": 1717684.5, + "stddev_ns": 150066.26185139015, + "min_ns": 1537148, + "max_ns": 1978181, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "var_assign_simple", + "category": "variables", + "iterations": 10, + "times_ns": [ + 87035, + 84418, + 82431, + 81965, + 79816, + 80797, + 80934, + 79843, + 108929, + 80770 + ], + "mean_ns": 84693.8, + "stddev_ns": 8351.702590490157, + "min_ns": 79816, + "max_ns": 108929, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "var_assign_simple", + "category": "variables", + "iterations": 10, + "times_ns": [ + 2372319, + 1602235, + 1774192, + 1707781, + 1907247, + 2040109, + 1804573, + 1635184, + 1729521, + 1657202 + ], + "mean_ns": 1823036.3, + "stddev_ns": 221860.71169860158, + "min_ns": 1602235, + "max_ns": 2372319, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "var_assign_many", + "category": "variables", + "iterations": 10, + "times_ns": [ + 115393, + 109527, + 108877, + 105089, + 375956, + 160464, + 118698, + 99931, + 240224, + 151700 + ], + "mean_ns": 158585.9, + "stddev_ns": 82826.45701278064, + "min_ns": 99931, + "max_ns": 375956, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "var_assign_many", + "category": "variables", + "iterations": 10, + "times_ns": [ + 1762788, + 2167430, + 1885160, + 1756658, + 1738808, + 1595564, + 1815868, + 1592370, + 1631170, + 1857761 + ], + "mean_ns": 1780357.7, + "stddev_ns": 161988.4391615957, + "min_ns": 1592370, + "max_ns": 2167430, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "var_default", + "category": "variables", + "iterations": 10, + "times_ns": [ + 86829, + 341541, + 101296, + 83323, + 82459, + 110809, + 91519, + 81900, + 86843, + 79104 + ], + "mean_ns": 114562.3, + "stddev_ns": 76228.95384438908, + "min_ns": 79104, + "max_ns": 341541, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "var_default", + "category": "variables", + "iterations": 10, + "times_ns": [ + 1687429, + 1726192, + 1653224, + 1612785, + 1665935, + 1651451, + 1665750, + 1603382, + 1630544, + 1654105 + ], + "mean_ns": 1655079.7, + "stddev_ns": 33787.84514599888, + "min_ns": 1603382, + "max_ns": 1726192, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "var_length", + "category": "variables", + "iterations": 10, + "times_ns": [ + 90055, + 115183, + 85444, + 118314, + 86088, + 84383, + 81986, + 253033, + 93347, + 82796 + ], + "mean_ns": 109062.9, + "stddev_ns": 49574.81459864475, + "min_ns": 81986, + "max_ns": 253033, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "var_length", + "category": "variables", + "iterations": 10, + "times_ns": [ + 2040488, + 1617188, + 1839012, + 1584390, + 1752432, + 1605978, + 1745694, + 1615968, + 1764387, + 1577875 + ], + "mean_ns": 1714341.2, + "stddev_ns": 139004.31098336485, + "min_ns": 1577875, + "max_ns": 2040488, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "var_substring", + "category": "variables", + "iterations": 10, + "times_ns": [ + 119485, + 94937, + 85291, + 84242, + 252097, + 135432, + 85739, + 82123, + 81715, + 120405 + ], + "mean_ns": 114146.6, + "stddev_ns": 49529.080403738575, + "min_ns": 81715, + "max_ns": 252097, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "var_substring", + "category": "variables", + "iterations": 10, + "times_ns": [ + 1732138, + 2364376, + 1817525, + 1623496, + 1556518, + 1778112, + 1622109, + 2045107, + 1742967, + 1549918 + ], + "mean_ns": 1783226.6, + "stddev_ns": 238548.07200989907, + "min_ns": 1549918, + "max_ns": 2364376, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "var_replace", + "category": "variables", + "iterations": 10, + "times_ns": [ + 281679, + 135954, + 93148, + 89225, + 87166, + 108118, + 86830, + 86191, + 85044, + 86479 + ], + "mean_ns": 113983.4, + "stddev_ns": 57886.86825904473, + "min_ns": 85044, + "max_ns": 281679, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "var_replace", + "category": "variables", + "iterations": 10, + "times_ns": [ + 1640674, + 1726749, + 1657140, + 1638587, + 1627234, + 1734138, + 1769524, + 1699589, + 1712081, + 1584000 + ], + "mean_ns": 1678971.6, + "stddev_ns": 55061.49583729087, + "min_ns": 1584000, + "max_ns": 1769524, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "var_nested", + "category": "variables", + "iterations": 10, + "times_ns": [ + 101578, + 92840, + 90427, + 89927, + 117482, + 89191, + 88916, + 88119, + 88970, + 90565 + ], + "mean_ns": 93801.5, + "stddev_ns": 8716.636200392903, + "min_ns": 88119, + "max_ns": 117482, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "var_nested", + "category": "variables", + "iterations": 10, + "times_ns": [ + 1994454, + 1992268, + 1629571, + 1669312, + 1627665, + 1772147, + 1610093, + 1660292, + 1811196, + 1583643 + ], + "mean_ns": 1735064.1, + "stddev_ns": 145510.09100708444, + "min_ns": 1583643, + "max_ns": 1994454, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "var_export", + "category": "variables", + "iterations": 10, + "times_ns": [ + 116818, + 92530, + 89279, + 89052, + 88277, + 87617, + 85700, + 88265, + 87833, + 87235 + ], + "mean_ns": 91260.6, + "stddev_ns": 8681.141643816209, + "min_ns": 85700, + "max_ns": 116818, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "var_export", + "category": "variables", + "iterations": 10, + "times_ns": [ + 2298222, + 1984760, + 2036198, + 1807260, + 1590129, + 1682627, + 1780184, + 1838986, + 1606645, + 2267207 + ], + "mean_ns": 1889221.8, + "stddev_ns": 239583.3263045657, + "min_ns": 1590129, + "max_ns": 2298222, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "arith_basic", + "category": "arithmetic", + "iterations": 10, + "times_ns": [ + 86374, + 81587, + 81293, + 79608, + 80176, + 79057, + 78274, + 322946, + 89384, + 81423 + ], + "mean_ns": 106012.2, + "stddev_ns": 72384.64552071798, + "min_ns": 78274, + "max_ns": 322946, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "arith_basic", + "category": "arithmetic", + "iterations": 10, + "times_ns": [ + 1905584, + 1909797, + 1723690, + 1776560, + 1816149, + 1694131, + 1620759, + 1750044, + 1536420, + 1728351 + ], + "mean_ns": 1746148.5, + "stddev_ns": 110125.44684245327, + "min_ns": 1536420, + "max_ns": 1909797, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "arith_complex", + "category": "arithmetic", + "iterations": 10, + "times_ns": [ + 87941, + 84306, + 83196, + 81393, + 82942, + 126095, + 84459, + 81652, + 163597, + 108985 + ], + "mean_ns": 98456.6, + "stddev_ns": 25830.021204791916, + "min_ns": 81393, + "max_ns": 163597, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "arith_complex", + "category": "arithmetic", + "iterations": 10, + "times_ns": [ + 1638866, + 1591894, + 1561666, + 1837110, + 1640321, + 1637184, + 1974716, + 1646714, + 1821225, + 1831413 + ], + "mean_ns": 1718110.9, + "stddev_ns": 129560.89780597386, + "min_ns": 1561666, + "max_ns": 1974716, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "arith_variables", + "category": "arithmetic", + "iterations": 10, + "times_ns": [ + 94988, + 93223, + 91609, + 89390, + 88539, + 89641, + 89058, + 115610, + 91477, + 87774 + ], + "mean_ns": 93130.9, + "stddev_ns": 7786.931211330943, + "min_ns": 87774, + "max_ns": 115610, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "arith_variables", + "category": "arithmetic", + "iterations": 10, + "times_ns": [ + 2596041, + 2255710, + 1822718, + 1633672, + 1728184, + 1804843, + 1676546, + 1649605, + 1778300, + 2108112 + ], + "mean_ns": 1905373.1, + "stddev_ns": 299490.1534346163, + "min_ns": 1633672, + "max_ns": 2596041, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "arith_increment", + "category": "arithmetic", + "iterations": 10, + "times_ns": [ + 130728, + 98207, + 93613, + 91977, + 92583, + 90675, + 90293, + 87976, + 89071, + 89337 + ], + "mean_ns": 95446.0, + "stddev_ns": 12079.364718394754, + "min_ns": 87976, + "max_ns": 130728, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "arith_increment", + "category": "arithmetic", + "iterations": 10, + "times_ns": [ + 1889864, + 1981420, + 1849434, + 1764945, + 1816082, + 2098919, + 1648918, + 1813904, + 1606089, + 1614516 + ], + "mean_ns": 1808409.1, + "stddev_ns": 151192.0236159633, + "min_ns": 1606089, + "max_ns": 2098919, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "arith_modulo", + "category": "arithmetic", + "iterations": 10, + "times_ns": [ + 115874, + 112789, + 113894, + 111331, + 108572, + 106896, + 129933, + 108267, + 107309, + 105918 + ], + "mean_ns": 112078.3, + "stddev_ns": 6722.572930805585, + "min_ns": 105918, + "max_ns": 129933, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "arith_modulo", + "category": "arithmetic", + "iterations": 10, + "times_ns": [ + 1673108, + 1932241, + 1562173, + 1609615, + 1617436, + 1746613, + 1603858, + 1617394, + 1723266, + 1759822 + ], + "mean_ns": 1684552.6, + "stddev_ns": 104218.60195588885, + "min_ns": 1562173, + "max_ns": 1932241, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "arith_loop_sum", + "category": "arithmetic", + "iterations": 10, + "times_ns": [ + 184034, + 177116, + 197494, + 180808, + 165068, + 132748, + 132314, + 132129, + 131299, + 152434 + ], + "mean_ns": 158544.4, + "stddev_ns": 24250.424574427558, + "min_ns": 131299, + "max_ns": 197494, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "arith_loop_sum", + "category": "arithmetic", + "iterations": 10, + "times_ns": [ + 1710591, + 1733965, + 1861377, + 1695255, + 1808515, + 1666080, + 1792807, + 1853922, + 1598457, + 1932581 + ], + "mean_ns": 1765355.0, + "stddev_ns": 97084.5903210185, + "min_ns": 1598457, + "max_ns": 1932581, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "ctrl_if_simple", + "category": "control", + "iterations": 10, + "times_ns": [ + 252217, + 129332, + 87061, + 86553, + 84606, + 84082, + 117555, + 85040, + 84183, + 83051 + ], + "mean_ns": 109368.0, + "stddev_ns": 50060.773344006586, + "min_ns": 83051, + "max_ns": 252217, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "ctrl_if_simple", + "category": "control", + "iterations": 10, + "times_ns": [ + 1732044, + 1567181, + 1806804, + 1509369, + 2012987, + 1689506, + 1625620, + 1572222, + 1626624, + 1605080 + ], + "mean_ns": 1674743.7, + "stddev_ns": 139413.27126285358, + "min_ns": 1509369, + "max_ns": 2012987, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "ctrl_if_else", + "category": "control", + "iterations": 10, + "times_ns": [ + 93890, + 90306, + 90063, + 224440, + 157607, + 91720, + 91527, + 153364, + 122053, + 88979 + ], + "mean_ns": 120394.9, + "stddev_ns": 42977.0568663095, + "min_ns": 88979, + "max_ns": 224440, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "ctrl_if_else", + "category": "control", + "iterations": 10, + "times_ns": [ + 1523455, + 1618982, + 1649839, + 1678445, + 1946482, + 1515928, + 1542334, + 1537346, + 1747585, + 1631140 + ], + "mean_ns": 1639153.6, + "stddev_ns": 125158.60097108787, + "min_ns": 1515928, + "max_ns": 1946482, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "ctrl_for_list", + "category": "control", + "iterations": 10, + "times_ns": [ + 142066, + 119241, + 113425, + 113019, + 112144, + 112292, + 111721, + 129591, + 114558, + 134094 + ], + "mean_ns": 120215.1, + "stddev_ns": 10435.047028643427, + "min_ns": 111721, + "max_ns": 142066, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "ctrl_for_list", + "category": "control", + "iterations": 10, + "times_ns": [ + 1603226, + 1707092, + 1573174, + 1811187, + 1542466, + 1728889, + 1557972, + 1556017, + 1781487, + 1578847 + ], + "mean_ns": 1644035.7, + "stddev_ns": 97167.70614154683, + "min_ns": 1542466, + "max_ns": 1811187, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "ctrl_for_range", + "category": "control", + "iterations": 10, + "times_ns": [ + 125927, + 119020, + 118136, + 119059, + 143479, + 118019, + 116363, + 116976, + 116384, + 115211 + ], + "mean_ns": 120857.4, + "stddev_ns": 8041.570010887177, + "min_ns": 115211, + "max_ns": 143479, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "ctrl_for_range", + "category": "control", + "iterations": 10, + "times_ns": [ + 1736791, + 1640114, + 1865564, + 1619056, + 2105879, + 1895048, + 1809622, + 1779412, + 1718755, + 1881301 + ], + "mean_ns": 1805154.2, + "stddev_ns": 135150.19731084374, + "min_ns": 1619056, + "max_ns": 2105879, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "ctrl_while", + "category": "control", + "iterations": 10, + "times_ns": [ + 211249, + 172026, + 166042, + 1927664, + 202653, + 168250, + 537939, + 266992, + 170657, + 195318 + ], + "mean_ns": 401879.0, + "stddev_ns": 519607.7896254058, + "min_ns": 166042, + "max_ns": 1927664, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "ctrl_while", + "category": "control", + "iterations": 10, + "times_ns": [ + 1975869, + 1795348, + 1739107, + 1957645, + 1805993, + 1865376, + 1651257, + 2494915, + 2648311, + 1822816 + ], + "mean_ns": 1975663.7, + "stddev_ns": 313117.78806674335, + "min_ns": 1651257, + "max_ns": 2648311, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "ctrl_case", + "category": "control", + "iterations": 10, + "times_ns": [ + 104334, + 104475, + 380111, + 103669, + 116826, + 127461, + 95060, + 94666, + 218857, + 99621 + ], + "mean_ns": 144508.0, + "stddev_ns": 85977.92069246616, + "min_ns": 94666, + "max_ns": 380111, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "ctrl_case", + "category": "control", + "iterations": 10, + "times_ns": [ + 2188527, + 1685025, + 1663622, + 1712279, + 1670861, + 1597657, + 1488356, + 1544873, + 1526369, + 1606951 + ], + "mean_ns": 1668452.0, + "stddev_ns": 186919.9910218273, + "min_ns": 1488356, + "max_ns": 2188527, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "ctrl_function", + "category": "control", + "iterations": 10, + "times_ns": [ + 104620, + 103569, + 101011, + 125662, + 104534, + 93974, + 94122, + 91432, + 91414, + 92308 + ], + "mean_ns": 100264.6, + "stddev_ns": 9953.190415138253, + "min_ns": 91414, + "max_ns": 125662, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "ctrl_function", + "category": "control", + "iterations": 10, + "times_ns": [ + 1595878, + 1631089, + 1595089, + 1631645, + 1614477, + 1570909, + 1564538, + 6489679, + 2165523, + 1873215 + ], + "mean_ns": 2173204.2, + "stddev_ns": 1449900.525478338, + "min_ns": 1564538, + "max_ns": 6489679, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "ctrl_function_return", + "category": "control", + "iterations": 10, + "times_ns": [ + 154412, + 161268, + 122504, + 118164, + 114007, + 121111, + 123416, + 217054, + 169444, + 119998 + ], + "mean_ns": 142137.8, + "stddev_ns": 31478.65955468879, + "min_ns": 114007, + "max_ns": 217054, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "ctrl_function_return", + "category": "control", + "iterations": 10, + "times_ns": [ + 2253127, + 2496877, + 2191779, + 2238815, + 2215370, + 2194044, + 2427793, + 2160362, + 2482713, + 2206893 + ], + "mean_ns": 2286777.3, + "stddev_ns": 122856.13900741795, + "min_ns": 2160362, + "max_ns": 2496877, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "ctrl_nested_loops", + "category": "control", + "iterations": 10, + "times_ns": [ + 152553, + 250001, + 148616, + 141935, + 138692, + 176476, + 138040, + 134552, + 134139, + 135213 + ], + "mean_ns": 155021.7, + "stddev_ns": 33914.983733005094, + "min_ns": 134139, + "max_ns": 250001, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "ctrl_nested_loops", + "category": "control", + "iterations": 10, + "times_ns": [ + 1774649, + 1738613, + 1678323, + 1814213, + 1586493, + 1600722, + 1683769, + 2088516, + 1794791, + 2074880 + ], + "mean_ns": 1783496.9, + "stddev_ns": 165628.81742103334, + "min_ns": 1586493, + "max_ns": 2088516, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "str_concat", + "category": "strings", + "iterations": 10, + "times_ns": [ + 95100, + 92115, + 90065, + 90411, + 90573, + 87642, + 86555, + 253758, + 92562, + 84646 + ], + "mean_ns": 106342.7, + "stddev_ns": 49223.45597385457, + "min_ns": 84646, + "max_ns": 253758, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "str_concat", + "category": "strings", + "iterations": 10, + "times_ns": [ + 1678128, + 1966329, + 1666229, + 1618894, + 1683279, + 1566439, + 1838710, + 1873611, + 1706394, + 1831462 + ], + "mean_ns": 1742947.5, + "stddev_ns": 120625.79467199376, + "min_ns": 1566439, + "max_ns": 1966329, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "str_printf", + "category": "strings", + "iterations": 10, + "times_ns": [ + 87029, + 82068, + 81429, + 78966, + 78131, + 79559, + 79065, + 100418, + 84796, + 77595 + ], + "mean_ns": 82905.6, + "stddev_ns": 6500.85979236593, + "min_ns": 77595, + "max_ns": 100418, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "str_printf", + "category": "strings", + "iterations": 10, + "times_ns": [ + 1672790, + 1643535, + 1589162, + 1576223, + 1940825, + 1559574, + 1663177, + 1812135, + 1590703, + 1556873 + ], + "mean_ns": 1660499.7, + "stddev_ns": 118325.50751638465, + "min_ns": 1556873, + "max_ns": 1940825, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "str_printf_pad", + "category": "strings", + "iterations": 10, + "times_ns": [ + 492924, + 154241, + 153813, + 118513, + 112423, + 81075, + 81099, + 79902, + 78317, + 77606 + ], + "mean_ns": 142991.3, + "stddev_ns": 120138.55123235838, + "min_ns": 77606, + "max_ns": 492924, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "str_printf_pad", + "category": "strings", + "iterations": 10, + "times_ns": [ + 1767871, + 1619159, + 1657522, + 1535125, + 1580430, + 1551988, + 1695578, + 1888827, + 1755295, + 1728406 + ], + "mean_ns": 1678020.1, + "stddev_ns": 105376.89068714259, + "min_ns": 1535125, + "max_ns": 1888827, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "str_echo_escape", + "category": "strings", + "iterations": 10, + "times_ns": [ + 81708, + 78826, + 121842, + 78258, + 77237, + 76322, + 75290, + 75577, + 74633, + 74580 + ], + "mean_ns": 81427.3, + "stddev_ns": 13633.785923579699, + "min_ns": 74580, + "max_ns": 121842, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "str_echo_escape", + "category": "strings", + "iterations": 10, + "times_ns": [ + 1708484, + 1541062, + 1574306, + 1790318, + 1650696, + 1598093, + 1660701, + 1584920, + 1551951, + 1639942 + ], + "mean_ns": 1630047.3, + "stddev_ns": 73133.43634624315, + "min_ns": 1541062, + "max_ns": 1790318, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "str_prefix_strip", + "category": "strings", + "iterations": 10, + "times_ns": [ + 95231, + 92413, + 90036, + 89366, + 89511, + 107851, + 95338, + 87231, + 108060, + 85418 + ], + "mean_ns": 94045.5, + "stddev_ns": 7564.031534175409, + "min_ns": 85418, + "max_ns": 108060, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "str_prefix_strip", + "category": "strings", + "iterations": 10, + "times_ns": [ + 1612708, + 1686423, + 2362615, + 1674654, + 1931986, + 1586698, + 1671187, + 1537607, + 1601548, + 1686969 + ], + "mean_ns": 1735239.5, + "stddev_ns": 232121.9913352675, + "min_ns": 1537607, + "max_ns": 2362615, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "str_suffix_strip", + "category": "strings", + "iterations": 10, + "times_ns": [ + 91361, + 88242, + 86632, + 87442, + 86322, + 109194, + 86233, + 101636, + 89311, + 84711 + ], + "mean_ns": 91108.4, + "stddev_ns": 7553.254360869889, + "min_ns": 84711, + "max_ns": 109194, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "str_suffix_strip", + "category": "strings", + "iterations": 10, + "times_ns": [ + 1682515, + 1572191, + 1613623, + 1554006, + 1851285, + 1598300, + 1559341, + 1639117, + 1583103, + 1593706 + ], + "mean_ns": 1624718.7, + "stddev_ns": 83921.64012583405, + "min_ns": 1554006, + "max_ns": 1851285, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "str_uppercase", + "category": "strings", + "iterations": 10, + "times_ns": [ + 88844, + 85867, + 83485, + 83384, + 80929, + 81843, + 82546, + 82244, + 105148, + 86054 + ], + "mean_ns": 86034.4, + "stddev_ns": 6759.770960616936, + "min_ns": 80929, + "max_ns": 105148, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "str_uppercase", + "category": "strings", + "iterations": 10, + "times_ns": [ + 1565641, + 1623521, + 2831607, + 1611633, + 1772883, + 1755267, + 1765939, + 1812286, + 1627577, + 1840405 + ], + "mean_ns": 1820675.9, + "stddev_ns": 348840.780944674, + "min_ns": 1565641, + "max_ns": 2831607, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "str_lowercase", + "category": "strings", + "iterations": 10, + "times_ns": [ + 88675, + 85255, + 83899, + 84569, + 82611, + 83575, + 82041, + 81558, + 81703, + 104586 + ], + "mean_ns": 85847.2, + "stddev_ns": 6562.116500032593, + "min_ns": 81558, + "max_ns": 104586, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "str_lowercase", + "category": "strings", + "iterations": 10, + "times_ns": [ + 1761691, + 1686993, + 2297648, + 1659202, + 2012010, + 1653646, + 1885293, + 1741268, + 2038044, + 1767345 + ], + "mean_ns": 1850314.0, + "stddev_ns": 197793.87157543583, + "min_ns": 1653646, + "max_ns": 2297648, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "arr_create", + "category": "arrays", + "iterations": 10, + "times_ns": [ + 106255, + 304556, + 97809, + 90215, + 89167, + 129521, + 91430, + 88293, + 87429, + 85237 + ], + "mean_ns": 116991.2, + "stddev_ns": 63773.92757357821, + "min_ns": 85237, + "max_ns": 304556, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "arr_create", + "category": "arrays", + "iterations": 10, + "times_ns": [ + 1801540, + 1736631, + 1861032, + 2474455, + 1985546, + 1912239, + 1723296, + 1797717, + 1695926, + 1684413 + ], + "mean_ns": 1867279.5, + "stddev_ns": 222367.38105992525, + "min_ns": 1684413, + "max_ns": 2474455, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "arr_all", + "category": "arrays", + "iterations": 10, + "times_ns": [ + 186692, + 132908, + 126066, + 122026, + 132106, + 144767, + 136581, + 114393, + 88492, + 87234 + ], + "mean_ns": 127126.5, + "stddev_ns": 26981.776614040817, + "min_ns": 87234, + "max_ns": 186692, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "arr_all", + "category": "arrays", + "iterations": 10, + "times_ns": [ + 1706397, + 1629290, + 1697336, + 1733672, + 1632157, + 1724318, + 1642335, + 1610863, + 1921115, + 1765059 + ], + "mean_ns": 1706254.2, + "stddev_ns": 86821.53389891243, + "min_ns": 1610863, + "max_ns": 1921115, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "arr_length", + "category": "arrays", + "iterations": 10, + "times_ns": [ + 95089, + 91445, + 92075, + 90175, + 196446, + 127435, + 91909, + 89037, + 164166, + 118413 + ], + "mean_ns": 115619.0, + "stddev_ns": 35374.54805647699, + "min_ns": 89037, + "max_ns": 196446, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "arr_length", + "category": "arrays", + "iterations": 10, + "times_ns": [ + 1930206, + 1597172, + 1748091, + 1807406, + 1713051, + 1858157, + 1626774, + 1615974, + 1975966, + 1616981 + ], + "mean_ns": 1748977.8, + "stddev_ns": 131941.16595194998, + "min_ns": 1597172, + "max_ns": 1975966, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "arr_iterate", + "category": "arrays", + "iterations": 10, + "times_ns": [ + 106435, + 104906, + 155889, + 108752, + 101954, + 216564, + 115100, + 101460, + 98997, + 106164 + ], + "mean_ns": 121622.1, + "stddev_ns": 35285.45099456715, + "min_ns": 98997, + "max_ns": 216564, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "arr_iterate", + "category": "arrays", + "iterations": 10, + "times_ns": [ + 1570946, + 1611769, + 1680247, + 1712003, + 2589395, + 1652738, + 1741371, + 1662575, + 1982052, + 1580916 + ], + "mean_ns": 1778401.2, + "stddev_ns": 292166.06551336515, + "min_ns": 1570946, + "max_ns": 2589395, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "arr_slice", + "category": "arrays", + "iterations": 10, + "times_ns": [ + 105958, + 96352, + 204293, + 99205, + 126203, + 94123, + 91967, + 91689, + 91631, + 89183 + ], + "mean_ns": 109060.4, + "stddev_ns": 33387.63971651785, + "min_ns": 89183, + "max_ns": 204293, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "arr_slice", + "category": "arrays", + "iterations": 10, + "times_ns": [ + 1561370, + 1903171, + 1552821, + 1595470, + 1691297, + 1670482, + 1774285, + 1823449, + 1609659, + 1756652 + ], + "mean_ns": 1693865.6, + "stddev_ns": 112153.6977510773, + "min_ns": 1552821, + "max_ns": 1903171, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "arr_assign_index", + "category": "arrays", + "iterations": 10, + "times_ns": [ + 107650, + 101190, + 337225, + 127334, + 95498, + 91930, + 126256, + 97641, + 89187, + 88941 + ], + "mean_ns": 126285.2, + "stddev_ns": 71549.44245876413, + "min_ns": 88941, + "max_ns": 337225, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "arr_assign_index", + "category": "arrays", + "iterations": 10, + "times_ns": [ + 1653770, + 1582229, + 1678387, + 1652944, + 1726884, + 1546906, + 1771238, + 1610784, + 1703528, + 1714353 + ], + "mean_ns": 1664102.3, + "stddev_ns": 65738.48688409249, + "min_ns": 1546906, + "max_ns": 1771238, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "pipe_simple", + "category": "pipes", + "iterations": 10, + "times_ns": [ + 169681, + 147379, + 145668, + 139307, + 175230, + 141593, + 106470, + 109355, + 107096, + 105223 + ], + "mean_ns": 134700.2, + "stddev_ns": 25072.533764260843, + "min_ns": 105223, + "max_ns": 175230, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "pipe_simple", + "category": "pipes", + "iterations": 10, + "times_ns": [ + 3223993, + 3150848, + 3286014, + 3578210, + 3275789, + 3080880, + 3144622, + 3174471, + 3152757, + 4561265 + ], + "mean_ns": 3362884.9, + "stddev_ns": 420362.24734018394, + "min_ns": 3080880, + "max_ns": 4561265, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "pipe_multi", + "category": "pipes", + "iterations": 10, + "times_ns": [ + 264243, + 214763, + 215597, + 206113, + 319405, + 303281, + 256144, + 211226, + 267495, + 269538 + ], + "mean_ns": 252780.5, + "stddev_ns": 37896.875676630654, + "min_ns": 206113, + "max_ns": 319405, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "pipe_multi", + "category": "pipes", + "iterations": 10, + "times_ns": [ + 3929759, + 4576614, + 3954158, + 4256962, + 3936700, + 3895039, + 3971734, + 4421021, + 3901564, + 3623777 + ], + "mean_ns": 4046732.8, + "stddev_ns": 269819.13536100433, + "min_ns": 3623777, + "max_ns": 4576614, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "pipe_command_subst", + "category": "pipes", + "iterations": 10, + "times_ns": [ + 103454, + 99831, + 98972, + 95619, + 138213, + 96772, + 95029, + 93422, + 94245, + 93126 + ], + "mean_ns": 100868.3, + "stddev_ns": 12820.59028321239, + "min_ns": 93126, + "max_ns": 138213, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "pipe_command_subst", + "category": "pipes", + "iterations": 10, + "times_ns": [ + 2297989, + 2426328, + 2252817, + 2305570, + 2338255, + 2329023, + 2415092, + 2174675, + 2700207, + 2332043 + ], + "mean_ns": 2357199.9, + "stddev_ns": 133398.83164214744, + "min_ns": 2174675, + "max_ns": 2700207, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "pipe_heredoc", + "category": "pipes", + "iterations": 10, + "times_ns": [ + 102479, + 98211, + 96663, + 95255, + 94361, + 95218, + 138341, + 97354, + 92174, + 159296 + ], + "mean_ns": 106935.2, + "stddev_ns": 21612.468391185677, + "min_ns": 92174, + "max_ns": 159296, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "pipe_heredoc", + "category": "pipes", + "iterations": 10, + "times_ns": [ + 2882373, + 3087569, + 3131133, + 4151607, + 3254583, + 2857521, + 3884677, + 3059043, + 3132159, + 3077372 + ], + "mean_ns": 3251803.7, + "stddev_ns": 403181.42577059526, + "min_ns": 2857521, + "max_ns": 4151607, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "pipe_herestring", + "category": "pipes", + "iterations": 10, + "times_ns": [ + 102050, + 98423, + 139933, + 95969, + 95180, + 94069, + 93440, + 95908, + 94032, + 92246 + ], + "mean_ns": 100125.0, + "stddev_ns": 13532.75801158064, + "min_ns": 92246, + "max_ns": 139933, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "pipe_herestring", + "category": "pipes", + "iterations": 10, + "times_ns": [ + 3045113, + 3299455, + 3141041, + 3457490, + 3098509, + 2899593, + 3190932, + 3197456, + 3057854, + 3207616 + ], + "mean_ns": 3159505.9, + "stddev_ns": 144276.7480534892, + "min_ns": 2899593, + "max_ns": 3457490, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "pipe_discard", + "category": "pipes", + "iterations": 10, + "times_ns": [ + 101051, + 96296, + 96157, + 94372, + 124036, + 105320, + 96149, + 93346, + 91409, + 92634 + ], + "mean_ns": 99077.0, + "stddev_ns": 9197.547553560134, + "min_ns": 91409, + "max_ns": 124036, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "pipe_discard", + "category": "pipes", + "iterations": 10, + "times_ns": [ + 2377672, + 2418841, + 2287803, + 2359418, + 2241222, + 2164868, + 3896586, + 2698986, + 2299666, + 4913480 + ], + "mean_ns": 2765854.2, + "stddev_ns": 861040.3038230905, + "min_ns": 2164868, + "max_ns": 4913480, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "tool_grep_simple", + "category": "tools", + "iterations": 10, + "times_ns": [ + 192817, + 437309, + 193094, + 146307, + 179350, + 250767, + 250069, + 406184, + 171250, + 356733 + ], + "mean_ns": 258388.0, + "stddev_ns": 99307.83242524228, + "min_ns": 146307, + "max_ns": 437309, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "tool_grep_simple", + "category": "tools", + "iterations": 10, + "times_ns": [ + 5615543, + 5189952, + 4254768, + 5048135, + 5548035, + 4139144, + 5094001, + 4470800, + 3966434, + 4085844 + ], + "mean_ns": 4741265.6, + "stddev_ns": 594766.498083273, + "min_ns": 3966434, + "max_ns": 5615543, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "tool_grep_case", + "category": "tools", + "iterations": 10, + "times_ns": [ + 276139, + 621908, + 234264, + 217401, + 204247, + 208470, + 279093, + 302449, + 235191, + 317089 + ], + "mean_ns": 289625.1, + "stddev_ns": 116937.27264773197, + "min_ns": 204247, + "max_ns": 621908, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "tool_grep_case", + "category": "tools", + "iterations": 10, + "times_ns": [ + 7109666, + 23476982, + 4552854, + 5136288, + 5054898, + 12238869, + 11309396, + 6774167, + 5705444, + 5132884 + ], + "mean_ns": 8649144.8, + "stddev_ns": 5556808.299044799, + "min_ns": 4552854, + "max_ns": 23476982, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "tool_grep_count", + "category": "tools", + "iterations": 10, + "times_ns": [ + 196657, + 606152, + 1817535, + 393501, + 179662, + 170353, + 200039, + 196782, + 193552, + 135360 + ], + "mean_ns": 408959.3, + "stddev_ns": 488642.57772078144, + "min_ns": 135360, + "max_ns": 1817535, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "tool_grep_count", + "category": "tools", + "iterations": 10, + "times_ns": [ + 10887145, + 5908850, + 4323353, + 3829045, + 4267433, + 3702574, + 3952820, + 4058038, + 3702438, + 3902491 + ], + "mean_ns": 4853418.7, + "stddev_ns": 2102157.242424936, + "min_ns": 3702438, + "max_ns": 10887145, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "tool_grep_invert", + "category": "tools", + "iterations": 10, + "times_ns": [ + 130990, + 117351, + 111768, + 114307, + 117823, + 262355, + 124321, + 112178, + 195051, + 124425 + ], + "mean_ns": 141056.9, + "stddev_ns": 46685.98965739079, + "min_ns": 111768, + "max_ns": 262355, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "tool_grep_invert", + "category": "tools", + "iterations": 10, + "times_ns": [ + 3766691, + 3729884, + 5335807, + 3824588, + 4280522, + 3737941, + 4064341, + 4158380, + 3501950, + 3786100 + ], + "mean_ns": 4018620.4, + "stddev_ns": 490864.214840968, + "min_ns": 3501950, + "max_ns": 5335807, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "tool_grep_regex", + "category": "tools", + "iterations": 10, + "times_ns": [ + 922601, + 304504, + 182195, + 219071, + 166198, + 146188, + 153590, + 407116, + 175026, + 292473 + ], + "mean_ns": 296896.2, + "stddev_ns": 223188.1414967202, + "min_ns": 146188, + "max_ns": 922601, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "tool_grep_regex", + "category": "tools", + "iterations": 10, + "times_ns": [ + 3691732, + 3949960, + 3658973, + 3551389, + 3635670, + 3497325, + 3998654, + 3403391, + 3623004, + 3623847 + ], + "mean_ns": 3663394.5, + "stddev_ns": 175223.13138353053, + "min_ns": 3403391, + "max_ns": 3998654, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "tool_sed_replace", + "category": "tools", + "iterations": 10, + "times_ns": [ + 116538, + 109878, + 107435, + 106372, + 104149, + 208007, + 144310, + 107301, + 104696, + 176629 + ], + "mean_ns": 128531.5, + "stddev_ns": 34525.295107355705, + "min_ns": 104149, + "max_ns": 208007, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "tool_sed_replace", + "category": "tools", + "iterations": 10, + "times_ns": [ + 3995487, + 4046076, + 5648775, + 4376827, + 4539489, + 4304059, + 4461581, + 4552423, + 3933573, + 4172798 + ], + "mean_ns": 4403108.8, + "stddev_ns": 466222.4843730298, + "min_ns": 3933573, + "max_ns": 5648775, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "tool_sed_global", + "category": "tools", + "iterations": 10, + "times_ns": [ + 111156, + 107271, + 152877, + 118204, + 105284, + 104423, + 102583, + 102332, + 100417, + 98726 + ], + "mean_ns": 110327.3, + "stddev_ns": 15164.253796675917, + "min_ns": 98726, + "max_ns": 152877, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "tool_sed_global", + "category": "tools", + "iterations": 10, + "times_ns": [ + 3982320, + 4392156, + 3907709, + 4088126, + 3603549, + 3651030, + 3848384, + 3728083, + 3658591, + 3549013 + ], + "mean_ns": 3840896.1, + "stddev_ns": 247602.77127627225, + "min_ns": 3549013, + "max_ns": 4392156, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "tool_sed_delete", + "category": "tools", + "iterations": 10, + "times_ns": [ + 140304, + 109335, + 105042, + 102996, + 140209, + 107376, + 100499, + 98649, + 99405, + 100575 + ], + "mean_ns": 110439.0, + "stddev_ns": 15264.839075470138, + "min_ns": 98649, + "max_ns": 140304, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "tool_sed_delete", + "category": "tools", + "iterations": 10, + "times_ns": [ + 5477332, + 3874286, + 4460378, + 3633062, + 4171083, + 3875567, + 3853438, + 4272664, + 4065446, + 4008814 + ], + "mean_ns": 4169207.0, + "stddev_ns": 490258.6118456258, + "min_ns": 3633062, + "max_ns": 5477332, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "tool_sed_lines", + "category": "tools", + "iterations": 10, + "times_ns": [ + 173873, + 136932, + 134566, + 321915, + 139994, + 107726, + 137405, + 103732, + 99398, + 97182 + ], + "mean_ns": 145272.3, + "stddev_ns": 63124.50661201242, + "min_ns": 97182, + "max_ns": 321915, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "tool_sed_lines", + "category": "tools", + "iterations": 10, + "times_ns": [ + 3656028, + 3403084, + 3455694, + 3799799, + 4005949, + 3879437, + 3877768, + 3830301, + 4182779, + 3786109 + ], + "mean_ns": 3787694.8, + "stddev_ns": 223093.40938799604, + "min_ns": 3403084, + "max_ns": 4182779, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "tool_sed_backrefs", + "category": "tools", + "iterations": 10, + "times_ns": [ + 161737, + 209995, + 178406, + 147711, + 141412, + 189782, + 143433, + 132005, + 130824, + 127919 + ], + "mean_ns": 156322.4, + "stddev_ns": 26510.689263766795, + "min_ns": 127919, + "max_ns": 209995, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "tool_sed_backrefs", + "category": "tools", + "iterations": 10, + "times_ns": [ + 4475782, + 4187846, + 4135856, + 3800125, + 4093782, + 3964574, + 3627728, + 3806438, + 3730603, + 3916227 + ], + "mean_ns": 3973896.1, + "stddev_ns": 240612.2976106791, + "min_ns": 3627728, + "max_ns": 4475782, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "tool_awk_print", + "category": "tools", + "iterations": 10, + "times_ns": [ + 130095, + 229244, + 133080, + 114225, + 111146, + 165489, + 118551, + 108915, + 108277, + 105530 + ], + "mean_ns": 132455.2, + "stddev_ns": 36481.099774540795, + "min_ns": 105530, + "max_ns": 229244, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "tool_awk_print", + "category": "tools", + "iterations": 10, + "times_ns": [ + 3275905, + 3432039, + 3504601, + 3701857, + 3558946, + 3612058, + 3334144, + 3335882, + 3295865, + 3486773 + ], + "mean_ns": 3453807.0, + "stddev_ns": 136596.98400770055, + "min_ns": 3275905, + "max_ns": 3701857, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "tool_awk_sum", + "category": "tools", + "iterations": 10, + "times_ns": [ + 125969, + 119071, + 116502, + 113632, + 113555, + 113692, + 146430, + 117071, + 112410, + 214291 + ], + "mean_ns": 129262.3, + "stddev_ns": 29947.004905499314, + "min_ns": 112410, + "max_ns": 214291, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "tool_awk_sum", + "category": "tools", + "iterations": 10, + "times_ns": [ + 3564796, + 3616699, + 3435515, + 3863477, + 3409013, + 4141233, + 3755268, + 3758876, + 3518515, + 3418980 + ], + "mean_ns": 3648237.2, + "stddev_ns": 222011.78428533924, + "min_ns": 3409013, + "max_ns": 4141233, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "tool_awk_pattern", + "category": "tools", + "iterations": 10, + "times_ns": [ + 201786, + 227841, + 159032, + 144473, + 140138, + 138527, + 263023, + 201421, + 143981, + 451313 + ], + "mean_ns": 207153.5, + "stddev_ns": 90918.0230100171, + "min_ns": 138527, + "max_ns": 451313, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "tool_awk_pattern", + "category": "tools", + "iterations": 10, + "times_ns": [ + 3281473, + 3662599, + 3503498, + 3465261, + 3332715, + 3332208, + 3276994, + 3318069, + 3243228, + 3342291 + ], + "mean_ns": 3375833.6, + "stddev_ns": 122886.7566975384, + "min_ns": 3243228, + "max_ns": 3662599, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "tool_awk_fieldsep", + "category": "tools", + "iterations": 10, + "times_ns": [ + 123689, + 115425, + 113905, + 112822, + 112508, + 110259, + 138959, + 112430, + 111243, + 264158 + ], + "mean_ns": 131539.8, + "stddev_ns": 44963.89880070455, + "min_ns": 110259, + "max_ns": 264158, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "tool_awk_fieldsep", + "category": "tools", + "iterations": 10, + "times_ns": [ + 4432290, + 3386028, + 3854560, + 3352319, + 3490899, + 3345662, + 3574137, + 3785150, + 3280011, + 4483880 + ], + "mean_ns": 3698493.6, + "stddev_ns": 419857.656601663, + "min_ns": 3280011, + "max_ns": 4483880, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "tool_awk_nf", + "category": "tools", + "iterations": 10, + "times_ns": [ + 116709, + 115058, + 150758, + 113568, + 113569, + 109811, + 106345, + 107779, + 110839, + 375799 + ], + "mean_ns": 142023.5, + "stddev_ns": 78848.1904551398, + "min_ns": 106345, + "max_ns": 375799, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "tool_awk_nf", + "category": "tools", + "iterations": 10, + "times_ns": [ + 3635434, + 3810360, + 3653355, + 3521324, + 3469352, + 3382882, + 3353993, + 3675903, + 3465199, + 3362973 + ], + "mean_ns": 3533077.5, + "stddev_ns": 146492.42318649113, + "min_ns": 3353993, + "max_ns": 3810360, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "tool_awk_compute", + "category": "tools", + "iterations": 10, + "times_ns": [ + 121323, + 114807, + 111122, + 110581, + 109250, + 286207, + 123559, + 110085, + 108581, + 108147 + ], + "mean_ns": 130366.2, + "stddev_ns": 52195.65424783944, + "min_ns": 108147, + "max_ns": 286207, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "tool_awk_compute", + "category": "tools", + "iterations": 10, + "times_ns": [ + 3688954, + 3311532, + 5077324, + 3768058, + 3544112, + 3326777, + 3586660, + 3499072, + 3425985, + 3439400 + ], + "mean_ns": 3666787.4, + "stddev_ns": 490047.2424954965, + "min_ns": 3311532, + "max_ns": 5077324, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "tool_jq_identity", + "category": "tools", + "iterations": 10, + "times_ns": [ + 1140128, + 1147178, + 1092653, + 948596, + 1035249, + 1072229, + 1261170, + 922691, + 916846, + 953587 + ], + "mean_ns": 1049032.7, + "stddev_ns": 108718.36924278252, + "min_ns": 916846, + "max_ns": 1261170, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "tool_jq_identity", + "category": "tools", + "iterations": 10, + "times_ns": [ + 5534655, + 4960376, + 5009590, + 4795289, + 4800412, + 4824027, + 5064862, + 4842431, + 7018147, + 4849069 + ], + "mean_ns": 5169885.8, + "stddev_ns": 650872.2729732463, + "min_ns": 4795289, + "max_ns": 7018147, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "tool_jq_field", + "category": "tools", + "iterations": 10, + "times_ns": [ + 1353485, + 977832, + 1042866, + 953158, + 1134830, + 947476, + 924517, + 962640, + 1152940, + 963560 + ], + "mean_ns": 1041330.4, + "stddev_ns": 128507.81388398139, + "min_ns": 924517, + "max_ns": 1353485, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "tool_jq_field", + "category": "tools", + "iterations": 10, + "times_ns": [ + 5109298, + 5222729, + 4776954, + 5405925, + 4953798, + 5195211, + 5309913, + 6095716, + 5205951, + 5195282 + ], + "mean_ns": 5247077.7, + "stddev_ns": 329095.3416698723, + "min_ns": 4776954, + "max_ns": 6095716, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "tool_jq_array", + "category": "tools", + "iterations": 10, + "times_ns": [ + 1018844, + 978763, + 1047686, + 913023, + 868625, + 3165080, + 1124611, + 1126005, + 930626, + 1287413 + ], + "mean_ns": 1246067.6, + "stddev_ns": 650292.8082601252, + "min_ns": 868625, + "max_ns": 3165080, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "tool_jq_array", + "category": "tools", + "iterations": 10, + "times_ns": [ + 4935089, + 4939270, + 5486775, + 6122592, + 5020457, + 5156318, + 5007997, + 4914106, + 5241869, + 5025197 + ], + "mean_ns": 5184967.0, + "stddev_ns": 354170.4954125908, + "min_ns": 4914106, + "max_ns": 6122592, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "tool_jq_filter", + "category": "tools", + "iterations": 10, + "times_ns": [ + 999591, + 1055331, + 987314, + 964652, + 960415, + 932221, + 948714, + 1001253, + 953440, + 973342 + ], + "mean_ns": 977627.3, + "stddev_ns": 33373.637686203765, + "min_ns": 932221, + "max_ns": 1055331, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "tool_jq_filter", + "category": "tools", + "iterations": 10, + "times_ns": [ + 6768211, + 5525125, + 5371645, + 5032559, + 5633206, + 5096214, + 5253881, + 5647815, + 5178784, + 5257605 + ], + "mean_ns": 5476504.5, + "stddev_ns": 475772.21217180183, + "min_ns": 5032559, + "max_ns": 6768211, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "tool_jq_map", + "category": "tools", + "iterations": 10, + "times_ns": [ + 1824358, + 954082, + 3783633, + 1012059, + 1212114, + 1398112, + 1129245, + 1250769, + 969678, + 976393 + ], + "mean_ns": 1451044.3, + "stddev_ns": 817347.8241539584, + "min_ns": 954082, + "max_ns": 3783633, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "tool_jq_map", + "category": "tools", + "iterations": 10, + "times_ns": [ + 5316406, + 5554236, + 7615833, + 4960992, + 5512493, + 5293932, + 5364594, + 4952077, + 5153857, + 4912940 + ], + "mean_ns": 5463736.0, + "stddev_ns": 749426.8040317213, + "min_ns": 4912940, + "max_ns": 7615833, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "complex_fibonacci", + "category": "complex", + "iterations": 10, + "times_ns": [ + 8110493, + 8035609, + 9006965, + 10448319, + 8613311, + 8705860, + 8866512, + 8274202, + 8691351, + 8545938 + ], + "mean_ns": 8729856.0, + "stddev_ns": 645852.6413873369, + "min_ns": 8035609, + "max_ns": 10448319, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "complex_fibonacci", + "category": "complex", + "iterations": 10, + "times_ns": [ + 113077450, + 112715795, + 110330026, + 165803602, + 246217236, + 114994412, + 111510214, + 112797555, + 119500073, + 118980909 + ], + "mean_ns": 132592727.2, + "stddev_ns": 40972891.81820619, + "min_ns": 110330026, + "max_ns": 246217236, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "complex_fibonacci_iter", + "category": "complex", + "iterations": 10, + "times_ns": [ + 302910, + 193689, + 170543, + 204638, + 174222, + 166367, + 168642, + 165158, + 167492, + 193587 + ], + "mean_ns": 190724.8, + "stddev_ns": 39686.39451701301, + "min_ns": 165158, + "max_ns": 302910, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "complex_fibonacci_iter", + "category": "complex", + "iterations": 10, + "times_ns": [ + 1931116, + 2096559, + 1608986, + 1700215, + 2011073, + 1914433, + 2388338, + 2003759, + 2188131, + 1883631 + ], + "mean_ns": 1972624.1, + "stddev_ns": 213667.2913234265, + "min_ns": 1608986, + "max_ns": 2388338, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "complex_nested_subst", + "category": "complex", + "iterations": 10, + "times_ns": [ + 155284, + 151026, + 147540, + 144094, + 170052, + 144446, + 143094, + 141536, + 142459, + 298206 + ], + "mean_ns": 163773.7, + "stddev_ns": 45548.77003838852, + "min_ns": 141536, + "max_ns": 298206, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "complex_nested_subst", + "category": "complex", + "iterations": 10, + "times_ns": [ + 3486932, + 3972027, + 3431914, + 3317010, + 3229397, + 3135223, + 3156984, + 3326494, + 3323344, + 3315596 + ], + "mean_ns": 3369492.1, + "stddev_ns": 225841.29702224524, + "min_ns": 3135223, + "max_ns": 3972027, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "complex_loop_compute", + "category": "complex", + "iterations": 10, + "times_ns": [ + 170889, + 339078, + 264112, + 203399, + 164271, + 158444, + 156946, + 153851, + 154380, + 295868 + ], + "mean_ns": 206123.8, + "stddev_ns": 64958.24074249549, + "min_ns": 153851, + "max_ns": 339078, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "complex_loop_compute", + "category": "complex", + "iterations": 10, + "times_ns": [ + 1714101, + 1673434, + 1790931, + 1787508, + 1802022, + 1808610, + 1689512, + 2005297, + 1656719, + 1619360 + ], + "mean_ns": 1754749.4, + "stddev_ns": 105239.08536109577, + "min_ns": 1619360, + "max_ns": 2005297, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "complex_string_build", + "category": "complex", + "iterations": 10, + "times_ns": [ + 111819, + 147182, + 106316, + 105160, + 102360, + 102800, + 101689, + 102473, + 101260, + 101097 + ], + "mean_ns": 108215.6, + "stddev_ns": 13351.238019000337, + "min_ns": 101097, + "max_ns": 147182, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "complex_string_build", + "category": "complex", + "iterations": 10, + "times_ns": [ + 1703853, + 1662051, + 2017407, + 1755581, + 1804950, + 1893766, + 2362897, + 3406414, + 1854811, + 1706697 + ], + "mean_ns": 2016842.7, + "stddev_ns": 502518.72510167223, + "min_ns": 1662051, + "max_ns": 3406414, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "complex_json_transform", + "category": "complex", + "iterations": 10, + "times_ns": [ + 1017830, + 1315499, + 1161851, + 921635, + 908939, + 1006356, + 1048872, + 1235161, + 1132399, + 1050730 + ], + "mean_ns": 1079927.2, + "stddev_ns": 124272.0705515121, + "min_ns": 908939, + "max_ns": 1315499, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "complex_json_transform", + "category": "complex", + "iterations": 10, + "times_ns": [ + 5277344, + 5224074, + 5010449, + 5532426, + 5192069, + 5318118, + 4702316, + 4792226, + 4837362, + 4895518 + ], + "mean_ns": 5078190.2, + "stddev_ns": 256285.2656930554, + "min_ns": 4702316, + "max_ns": 5532426, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "complex_pipeline_text", + "category": "complex", + "iterations": 10, + "times_ns": [ + 267311, + 249761, + 278305, + 209547, + 444137, + 261048, + 234514, + 281450, + 248310, + 231633 + ], + "mean_ns": 270601.6, + "stddev_ns": 61541.401843311956, + "min_ns": 209547, + "max_ns": 444137, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "complex_pipeline_text", + "category": "complex", + "iterations": 10, + "times_ns": [ + 4311029, + 4411151, + 4074633, + 3772225, + 3617406, + 3713399, + 4152008, + 3938059, + 3629260, + 4263854 + ], + "mean_ns": 3988302.4, + "stddev_ns": 280070.6844702601, + "min_ns": 3617406, + "max_ns": 4411151, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "large_loop_1000", + "category": "large", + "iterations": 10, + "times_ns": [ + 5097807, + 5308026, + 4890355, + 4435679, + 4437673, + 4902765, + 4602308, + 4667989, + 6220982, + 4481704 + ], + "mean_ns": 4904528.8, + "stddev_ns": 519351.83274689614, + "min_ns": 4435679, + "max_ns": 6220982, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "large_loop_1000", + "category": "large", + "iterations": 10, + "times_ns": [ + 5117555, + 4373122, + 7286665, + 4886262, + 4666447, + 4475793, + 4720826, + 4243138, + 4379399, + 5271321 + ], + "mean_ns": 4942052.8, + "stddev_ns": 843242.4952597917, + "min_ns": 4243138, + "max_ns": 7286665, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "large_string_append_100", + "category": "large", + "iterations": 10, + "times_ns": [ + 501854, + 434772, + 455114, + 566210, + 465663, + 427341, + 457426, + 505531, + 471747, + 444323 + ], + "mean_ns": 472998.1, + "stddev_ns": 39452.85539083325, + "min_ns": 427341, + "max_ns": 566210, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "large_string_append_100", + "category": "large", + "iterations": 10, + "times_ns": [ + 2030285, + 2018001, + 3325490, + 1985332, + 1966571, + 2031221, + 2150453, + 2133671, + 1949615, + 1871996 + ], + "mean_ns": 2146263.5, + "stddev_ns": 400745.54966967506, + "min_ns": 1871996, + "max_ns": 3325490, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "large_array_fill_200", + "category": "large", + "iterations": 10, + "times_ns": [ + 1936102, + 2047044, + 1998123, + 3594732, + 2168365, + 1904283, + 2223011, + 2068566, + 2264620, + 1910611 + ], + "mean_ns": 2211545.7, + "stddev_ns": 476645.75870557164, + "min_ns": 1904283, + "max_ns": 3594732, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "large_array_fill_200", + "category": "large", + "iterations": 10, + "times_ns": [ + 2238618, + 2362991, + 2812440, + 2159063, + 2385688, + 2201203, + 2224928, + 2507598, + 2081077, + 2056186 + ], + "mean_ns": 2302979.2, + "stddev_ns": 215247.1633061862, + "min_ns": 2056186, + "max_ns": 2812440, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "large_nested_loops", + "category": "large", + "iterations": 10, + "times_ns": [ + 2403621, + 2209268, + 2082926, + 2115933, + 2044085, + 2110122, + 2048146, + 2364469, + 2240218, + 2306615 + ], + "mean_ns": 2192540.3, + "stddev_ns": 125397.7652608291, + "min_ns": 2044085, + "max_ns": 2403621, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "large_nested_loops", + "category": "large", + "iterations": 10, + "times_ns": [ + 3799243, + 3025493, + 3108155, + 3158668, + 3063244, + 3681955, + 2824763, + 2806124, + 2668332, + 3069071 + ], + "mean_ns": 3120504.8, + "stddev_ns": 343981.2547926994, + "min_ns": 2668332, + "max_ns": 3799243, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "large_fibonacci_12", + "category": "large", + "iterations": 10, + "times_ns": [ + 21273393, + 23290038, + 22919890, + 23149527, + 22958447, + 21823240, + 24632295, + 21966263, + 23460837, + 21707867 + ], + "mean_ns": 22718179.7, + "stddev_ns": 964433.0576386367, + "min_ns": 21273393, + "max_ns": 24632295, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "large_fibonacci_12", + "category": "large", + "iterations": 10, + "times_ns": [ + 335213905, + 308089095, + 308140394, + 332934029, + 296845371, + 477795675, + 318691236, + 301999190, + 308518080, + 316757617 + ], + "mean_ns": 330498459.2, + "stddev_ns": 50480488.22988703, + "min_ns": 296845371, + "max_ns": 477795675, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "large_function_calls_500", + "category": "large", + "iterations": 10, + "times_ns": [ + 10031802, + 10092682, + 11605705, + 11116711, + 10596680, + 9668136, + 9975366, + 12433488, + 10061266, + 10350625 + ], + "mean_ns": 10593246.1, + "stddev_ns": 826489.3709902687, + "min_ns": 9668136, + "max_ns": 12433488, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "large_function_calls_500", + "category": "large", + "iterations": 10, + "times_ns": [ + 272306690, + 259785782, + 258459866, + 255184719, + 245100573, + 246677635, + 277549295, + 443812687, + 245170008, + 239207375 + ], + "mean_ns": 274325463.0, + "stddev_ns": 57681619.65366445, + "min_ns": 239207375, + "max_ns": 443812687, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "large_multiline_script", + "category": "large", + "iterations": 10, + "times_ns": [ + 520043, + 792455, + 699158, + 525633, + 908359, + 549710, + 494102, + 521695, + 922870, + 717991 + ], + "mean_ns": 665201.6, + "stddev_ns": 157927.08807940452, + "min_ns": 494102, + "max_ns": 922870, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "large_multiline_script", + "category": "large", + "iterations": 10, + "times_ns": [ + 2577480, + 2180367, + 4129173, + 2810584, + 1953931, + 1889630, + 1977545, + 1928051, + 1794434, + 2008547 + ], + "mean_ns": 2324974.2, + "stddev_ns": 675475.5650850445, + "min_ns": 1794434, + "max_ns": 4129173, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "large_pipeline_chain", + "category": "large", + "iterations": 10, + "times_ns": [ + 1696355, + 1357129, + 1313885, + 1370994, + 1354660, + 1254760, + 1424243, + 1289074, + 1243405, + 1241128 + ], + "mean_ns": 1354563.3, + "stddev_ns": 127703.3253255764, + "min_ns": 1241128, + "max_ns": 1696355, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "large_pipeline_chain", + "category": "large", + "iterations": 10, + "times_ns": [ + 4305853, + 4301879, + 4305450, + 4153659, + 4254301, + 4561854, + 4187177, + 4227727, + 4116567, + 5438040 + ], + "mean_ns": 4385250.7, + "stddev_ns": 369621.07615639287, + "min_ns": 4116567, + "max_ns": 5438040, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "large_assoc_array", + "category": "large", + "iterations": 10, + "times_ns": [ + 117065, + 108998, + 105794, + 103900, + 102750, + 237731, + 172302, + 109667, + 103790, + 165004 + ], + "mean_ns": 132700.1, + "stddev_ns": 42739.09022768267, + "min_ns": 102750, + "max_ns": 237731, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "large_assoc_array", + "category": "large", + "iterations": 10, + "times_ns": [ + 1799381, + 1888148, + 1966438, + 1678476, + 1673668, + 1837534, + 1711261, + 1618107, + 1620944, + 1690039 + ], + "mean_ns": 1748399.6, + "stddev_ns": 112291.96422291311, + "min_ns": 1618107, + "max_ns": 1966438, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "subshell_simple", + "category": "subshell", + "iterations": 10, + "times_ns": [ + 93781, + 231754, + 95199, + 87041, + 84993, + 83226, + 81483, + 120677, + 82572, + 83000 + ], + "mean_ns": 104372.6, + "stddev_ns": 43894.545650228574, + "min_ns": 81483, + "max_ns": 231754, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "subshell_simple", + "category": "subshell", + "iterations": 10, + "times_ns": [ + 1991118, + 2003728, + 2308977, + 2157634, + 4706701, + 2142188, + 1978498, + 2071728, + 2144163, + 2015799 + ], + "mean_ns": 2352053.4, + "stddev_ns": 790827.3920129729, + "min_ns": 1978498, + "max_ns": 4706701, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "subshell_isolation", + "category": "subshell", + "iterations": 10, + "times_ns": [ + 106668, + 101214, + 128657, + 110089, + 101039, + 97759, + 338215, + 108857, + 97746, + 96593 + ], + "mean_ns": 128683.7, + "stddev_ns": 70419.47427672263, + "min_ns": 96593, + "max_ns": 338215, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "subshell_isolation", + "category": "subshell", + "iterations": 10, + "times_ns": [ + 2129892, + 2175675, + 2011297, + 2178707, + 2398230, + 1972423, + 2151399, + 1989324, + 2148021, + 2143236 + ], + "mean_ns": 2129820.4, + "stddev_ns": 116650.8100822279, + "min_ns": 1972423, + "max_ns": 2398230, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "subshell_nested", + "category": "subshell", + "iterations": 10, + "times_ns": [ + 133505, + 126163, + 124791, + 124954, + 127575, + 123204, + 152560, + 119986, + 493976, + 158762 + ], + "mean_ns": 168547.6, + "stddev_ns": 109173.03237997927, + "min_ns": 119986, + "max_ns": 493976, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "subshell_nested", + "category": "subshell", + "iterations": 10, + "times_ns": [ + 3637183, + 3877723, + 3599463, + 3568336, + 4230660, + 3623755, + 3721092, + 3731364, + 4016699, + 4082934 + ], + "mean_ns": 3808920.9, + "stddev_ns": 219115.38660187696, + "min_ns": 3568336, + "max_ns": 4230660, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "subshell_pipeline", + "category": "subshell", + "iterations": 10, + "times_ns": [ + 148115, + 288561, + 180108, + 154107, + 183752, + 154374, + 134007, + 144197, + 145490, + 142984 + ], + "mean_ns": 167569.5, + "stddev_ns": 43077.296050820085, + "min_ns": 134007, + "max_ns": 288561, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "subshell_pipeline", + "category": "subshell", + "iterations": 10, + "times_ns": [ + 3190999, + 3278001, + 3373314, + 3460473, + 3130195, + 3350688, + 3090415, + 4352307, + 3881606, + 3344642 + ], + "mean_ns": 3445264.0, + "stddev_ns": 368159.3074485555, + "min_ns": 3090415, + "max_ns": 4352307, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "subshell_capture_loop", + "category": "subshell", + "iterations": 10, + "times_ns": [ + 219684, + 386370, + 217494, + 176858, + 199701, + 171434, + 171102, + 166668, + 165809, + 166900 + ], + "mean_ns": 204202.0, + "stddev_ns": 63885.14520763023, + "min_ns": 165809, + "max_ns": 386370, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "subshell_capture_loop", + "category": "subshell", + "iterations": 10, + "times_ns": [ + 3891270, + 4479990, + 4021348, + 4153395, + 3994357, + 4042641, + 4267294, + 4094155, + 4231183, + 4180130 + ], + "mean_ns": 4135576.3, + "stddev_ns": 158253.84232052628, + "min_ns": 3891270, + "max_ns": 4479990, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "subshell_process_subst", + "category": "subshell", + "iterations": 10, + "times_ns": [ + 172111, + 137941, + 134808, + 129972, + 125963, + 125619, + 125209, + 147258, + 127423, + 123376 + ], + "mean_ns": 134968.0, + "stddev_ns": 14210.926394855474, + "min_ns": 123376, + "max_ns": 172111, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "subshell_process_subst", + "category": "subshell", + "iterations": 10, + "times_ns": [ + 2701711, + 2523660, + 2752934, + 2760405, + 2599509, + 2680262, + 2657213, + 2704372, + 2875215, + 2750016 + ], + "mean_ns": 2700529.7, + "stddev_ns": 91151.77323568643, + "min_ns": 2523660, + "max_ns": 2875215, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "io_redirect_write", + "category": "io", + "iterations": 10, + "times_ns": [ + 143230, + 139019, + 134275, + 133957, + 158520, + 142961, + 131345, + 131168, + 132898, + 131454 + ], + "mean_ns": 137882.7, + "stddev_ns": 8148.636892756973, + "min_ns": 131168, + "max_ns": 158520, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "io_redirect_write", + "category": "io", + "iterations": 10, + "times_ns": [ + 5705417, + 4122495, + 3958071, + 3969002, + 4083974, + 4039348, + 3955135, + 3953756, + 4134427, + 4410952 + ], + "mean_ns": 4233257.7, + "stddev_ns": 508112.4853848899, + "min_ns": 3953756, + "max_ns": 5705417, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "io_append", + "category": "io", + "iterations": 10, + "times_ns": [ + 191434, + 170935, + 204174, + 190728, + 162110, + 157864, + 156519, + 155060, + 153554, + 190167 + ], + "mean_ns": 173254.5, + "stddev_ns": 18009.829262100182, + "min_ns": 153554, + "max_ns": 204174, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "io_append", + "category": "io", + "iterations": 10, + "times_ns": [ + 3970751, + 3819185, + 4392106, + 4101118, + 4214516, + 4337688, + 4356787, + 4060660, + 4553932, + 4102989 + ], + "mean_ns": 4190973.2, + "stddev_ns": 210068.6067735015, + "min_ns": 3819185, + "max_ns": 4553932, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "io_dev_null", + "category": "io", + "iterations": 10, + "times_ns": [ + 205860, + 98109, + 86295, + 83430, + 117393, + 84034, + 81844, + 81804, + 82023, + 79871 + ], + "mean_ns": 100066.3, + "stddev_ns": 36903.62716061932, + "min_ns": 79871, + "max_ns": 205860, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "io_dev_null", + "category": "io", + "iterations": 10, + "times_ns": [ + 1693059, + 1691538, + 1578425, + 1681626, + 1753708, + 1862441, + 1744896, + 1771791, + 1592553, + 1528649 + ], + "mean_ns": 1689868.6, + "stddev_ns": 95686.29160877748, + "min_ns": 1528649, + "max_ns": 1862441, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "io_stderr_redirect", + "category": "io", + "iterations": 10, + "times_ns": [ + 122378, + 129816, + 116738, + 115007, + 113210, + 111280, + 113126, + 137293, + 112452, + 110739 + ], + "mean_ns": 118203.9, + "stddev_ns": 8464.634256127078, + "min_ns": 110739, + "max_ns": 137293, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "io_stderr_redirect", + "category": "io", + "iterations": 10, + "times_ns": [ + 1585303, + 1624469, + 1645997, + 1852891, + 1690761, + 1741237, + 1626350, + 1563868, + 1612609, + 1630760 + ], + "mean_ns": 1657424.5, + "stddev_ns": 80745.92333517526, + "min_ns": 1563868, + "max_ns": 1852891, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "io_read_lines", + "category": "io", + "iterations": 10, + "times_ns": [ + 168226, + 157394, + 151629, + 151948, + 149930, + 192438, + 152740, + 149762, + 149391, + 151006 + ], + "mean_ns": 157446.4, + "stddev_ns": 12840.38096163817, + "min_ns": 149391, + "max_ns": 192438, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "io_read_lines", + "category": "io", + "iterations": 10, + "times_ns": [ + 1706885, + 2069642, + 1710340, + 1642526, + 1623401, + 1789154, + 1795105, + 2029745, + 1675143, + 1788358 + ], + "mean_ns": 1783029.9, + "stddev_ns": 145317.14279633356, + "min_ns": 1623401, + "max_ns": 2069642, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bashkit", + "case_name": "io_multiline_heredoc", + "category": "io", + "iterations": 10, + "times_ns": [ + 192082, + 166428, + 152658, + 202018, + 151717, + 183948, + 150390, + 160065, + 160899, + 185445 + ], + "mean_ns": 170565.0, + "stddev_ns": 17766.615575286138, + "min_ns": 150390, + "max_ns": 202018, + "errors": 0, + "error_messages": [], + "output_match": true + }, + { + "runner": "bash", + "case_name": "io_multiline_heredoc", + "category": "io", + "iterations": 10, + "times_ns": [ + 3545696, + 3435220, + 3487818, + 4013603, + 3437269, + 3477348, + 5107583, + 3493185, + 3242134, + 3540418 + ], + "mean_ns": 3678027.4, + "stddev_ns": 510904.0800679125, + "min_ns": 3242134, + "max_ns": 5107583, + "errors": 0, + "error_messages": [], + "output_match": true + } + ], + "summary": { + "total_cases": 96, + "runner_stats": { + "bashkit": { + "total_time_ms": 72.02369489999997, + "avg_time_ms": 0.7502468218749997, + "error_count": 0, + "error_rate": 0.0, + "output_match_rate": 1.0 + }, + "bash": { + "total_time_ms": 997.8718887, + "avg_time_ms": 10.394498840625, + "error_count": 0, + "error_rate": 0.0, + "output_match_rate": 1.0 + } + } + } +} \ No newline at end of file diff --git a/crates/bashkit-bench/results/bench-a9d59d0fdfe3-linux-x86_64-1795316001.md b/crates/bashkit-bench/results/bench-a9d59d0fdfe3-linux-x86_64-1795316001.md new file mode 100644 index 000000000..d066d09c3 --- /dev/null +++ b/crates/bashkit-bench/results/bench-a9d59d0fdfe3-linux-x86_64-1795316001.md @@ -0,0 +1,307 @@ +# Bashkit Benchmark Report + +## System Information + +- **Moniker**: `a9d59d0fdfe3-linux-x86_64` +- **Hostname**: a9d59d0fdfe3 +- **OS**: linux +- **Architecture**: x86_64 +- **CPUs**: 4 +- **Timestamp**: 1795316001 +- **Iterations**: 10 +- **Warmup**: 2 +- **Prewarm cases**: 3 + +- **bash executable**: `/usr/bin/bash (GNU Bash 5.2.37(1)-release)` + +## Summary + +Benchmarked 96 cases across 2 runners. + +| Runner | Total Time (ms) | Avg/Case (ms) | Errors | Error Rate | Output Match | +|--------|-----------------|---------------|--------|------------|-------------| +| bashkit | 72.02 | 0.750 | 0 | 0.0% | 100.0% | +| bash | 997.87 | 10.394 | 0 | 0.0% | 100.0% | + +## Performance Comparison + +**Bashkit is 13.9x faster** than bash on average. + +## Results by Category + +### Arithmetic + +| Benchmark | Runner | Mean (ms) | StdDev | Errors | Match | +|-----------|--------|-----------|--------|--------|-------| +| arith_basic | bashkit | 0.106 | ±0.072 | - | ✓ | +| arith_basic | bash | 1.746 | ±0.110 | - | ✓ | +| arith_complex | bashkit | 0.098 | ±0.026 | - | ✓ | +| arith_complex | bash | 1.718 | ±0.130 | - | ✓ | +| arith_variables | bashkit | 0.093 | ±0.008 | - | ✓ | +| arith_variables | bash | 1.905 | ±0.299 | - | ✓ | +| arith_increment | bashkit | 0.095 | ±0.012 | - | ✓ | +| arith_increment | bash | 1.808 | ±0.151 | - | ✓ | +| arith_modulo | bashkit | 0.112 | ±0.007 | - | ✓ | +| arith_modulo | bash | 1.685 | ±0.104 | - | ✓ | +| arith_loop_sum | bashkit | 0.159 | ±0.024 | - | ✓ | +| arith_loop_sum | bash | 1.765 | ±0.097 | - | ✓ | + +### Arrays + +| Benchmark | Runner | Mean (ms) | StdDev | Errors | Match | +|-----------|--------|-----------|--------|--------|-------| +| arr_create | bashkit | 0.117 | ±0.064 | - | ✓ | +| arr_create | bash | 1.867 | ±0.222 | - | ✓ | +| arr_all | bashkit | 0.127 | ±0.027 | - | ✓ | +| arr_all | bash | 1.706 | ±0.087 | - | ✓ | +| arr_length | bashkit | 0.116 | ±0.035 | - | ✓ | +| arr_length | bash | 1.749 | ±0.132 | - | ✓ | +| arr_iterate | bashkit | 0.122 | ±0.035 | - | ✓ | +| arr_iterate | bash | 1.778 | ±0.292 | - | ✓ | +| arr_slice | bashkit | 0.109 | ±0.033 | - | ✓ | +| arr_slice | bash | 1.694 | ±0.112 | - | ✓ | +| arr_assign_index | bashkit | 0.126 | ±0.072 | - | ✓ | +| arr_assign_index | bash | 1.664 | ±0.066 | - | ✓ | + +### Complex + +| Benchmark | Runner | Mean (ms) | StdDev | Errors | Match | +|-----------|--------|-----------|--------|--------|-------| +| complex_fibonacci | bashkit | 8.730 | ±0.646 | - | ✓ | +| complex_fibonacci | bash | 132.593 | ±40.973 | - | ✓ | +| complex_fibonacci_iter | bashkit | 0.191 | ±0.040 | - | ✓ | +| complex_fibonacci_iter | bash | 1.973 | ±0.214 | - | ✓ | +| complex_nested_subst | bashkit | 0.164 | ±0.046 | - | ✓ | +| complex_nested_subst | bash | 3.369 | ±0.226 | - | ✓ | +| complex_loop_compute | bashkit | 0.206 | ±0.065 | - | ✓ | +| complex_loop_compute | bash | 1.755 | ±0.105 | - | ✓ | +| complex_string_build | bashkit | 0.108 | ±0.013 | - | ✓ | +| complex_string_build | bash | 2.017 | ±0.503 | - | ✓ | +| complex_json_transform | bashkit | 1.080 | ±0.124 | - | ✓ | +| complex_json_transform | bash | 5.078 | ±0.256 | - | ✓ | +| complex_pipeline_text | bashkit | 0.271 | ±0.062 | - | ✓ | +| complex_pipeline_text | bash | 3.988 | ±0.280 | - | ✓ | + +### Control + +| Benchmark | Runner | Mean (ms) | StdDev | Errors | Match | +|-----------|--------|-----------|--------|--------|-------| +| ctrl_if_simple | bashkit | 0.109 | ±0.050 | - | ✓ | +| ctrl_if_simple | bash | 1.675 | ±0.139 | - | ✓ | +| ctrl_if_else | bashkit | 0.120 | ±0.043 | - | ✓ | +| ctrl_if_else | bash | 1.639 | ±0.125 | - | ✓ | +| ctrl_for_list | bashkit | 0.120 | ±0.010 | - | ✓ | +| ctrl_for_list | bash | 1.644 | ±0.097 | - | ✓ | +| ctrl_for_range | bashkit | 0.121 | ±0.008 | - | ✓ | +| ctrl_for_range | bash | 1.805 | ±0.135 | - | ✓ | +| ctrl_while | bashkit | 0.402 | ±0.520 | - | ✓ | +| ctrl_while | bash | 1.976 | ±0.313 | - | ✓ | +| ctrl_case | bashkit | 0.145 | ±0.086 | - | ✓ | +| ctrl_case | bash | 1.668 | ±0.187 | - | ✓ | +| ctrl_function | bashkit | 0.100 | ±0.010 | - | ✓ | +| ctrl_function | bash | 2.173 | ±1.450 | - | ✓ | +| ctrl_function_return | bashkit | 0.142 | ±0.031 | - | ✓ | +| ctrl_function_return | bash | 2.287 | ±0.123 | - | ✓ | +| ctrl_nested_loops | bashkit | 0.155 | ±0.034 | - | ✓ | +| ctrl_nested_loops | bash | 1.783 | ±0.166 | - | ✓ | + +### Io + +| Benchmark | Runner | Mean (ms) | StdDev | Errors | Match | +|-----------|--------|-----------|--------|--------|-------| +| io_redirect_write | bashkit | 0.138 | ±0.008 | - | ✓ | +| io_redirect_write | bash | 4.233 | ±0.508 | - | ✓ | +| io_append | bashkit | 0.173 | ±0.018 | - | ✓ | +| io_append | bash | 4.191 | ±0.210 | - | ✓ | +| io_dev_null | bashkit | 0.100 | ±0.037 | - | ✓ | +| io_dev_null | bash | 1.690 | ±0.096 | - | ✓ | +| io_stderr_redirect | bashkit | 0.118 | ±0.008 | - | ✓ | +| io_stderr_redirect | bash | 1.657 | ±0.081 | - | ✓ | +| io_read_lines | bashkit | 0.157 | ±0.013 | - | ✓ | +| io_read_lines | bash | 1.783 | ±0.145 | - | ✓ | +| io_multiline_heredoc | bashkit | 0.171 | ±0.018 | - | ✓ | +| io_multiline_heredoc | bash | 3.678 | ±0.511 | - | ✓ | + +### Large + +| Benchmark | Runner | Mean (ms) | StdDev | Errors | Match | +|-----------|--------|-----------|--------|--------|-------| +| large_loop_1000 | bashkit | 4.905 | ±0.519 | - | ✓ | +| large_loop_1000 | bash | 4.942 | ±0.843 | - | ✓ | +| large_string_append_100 | bashkit | 0.473 | ±0.039 | - | ✓ | +| large_string_append_100 | bash | 2.146 | ±0.401 | - | ✓ | +| large_array_fill_200 | bashkit | 2.212 | ±0.477 | - | ✓ | +| large_array_fill_200 | bash | 2.303 | ±0.215 | - | ✓ | +| large_nested_loops | bashkit | 2.193 | ±0.125 | - | ✓ | +| large_nested_loops | bash | 3.121 | ±0.344 | - | ✓ | +| large_fibonacci_12 | bashkit | 22.718 | ±0.964 | - | ✓ | +| large_fibonacci_12 | bash | 330.498 | ±50.480 | - | ✓ | +| large_function_calls_500 | bashkit | 10.593 | ±0.826 | - | ✓ | +| large_function_calls_500 | bash | 274.325 | ±57.682 | - | ✓ | +| large_multiline_script | bashkit | 0.665 | ±0.158 | - | ✓ | +| large_multiline_script | bash | 2.325 | ±0.675 | - | ✓ | +| large_pipeline_chain | bashkit | 1.355 | ±0.128 | - | ✓ | +| large_pipeline_chain | bash | 4.385 | ±0.370 | - | ✓ | +| large_assoc_array | bashkit | 0.133 | ±0.043 | - | ✓ | +| large_assoc_array | bash | 1.748 | ±0.112 | - | ✓ | + +### Pipes + +| Benchmark | Runner | Mean (ms) | StdDev | Errors | Match | +|-----------|--------|-----------|--------|--------|-------| +| pipe_simple | bashkit | 0.135 | ±0.025 | - | ✓ | +| pipe_simple | bash | 3.363 | ±0.420 | - | ✓ | +| pipe_multi | bashkit | 0.253 | ±0.038 | - | ✓ | +| pipe_multi | bash | 4.047 | ±0.270 | - | ✓ | +| pipe_command_subst | bashkit | 0.101 | ±0.013 | - | ✓ | +| pipe_command_subst | bash | 2.357 | ±0.133 | - | ✓ | +| pipe_heredoc | bashkit | 0.107 | ±0.022 | - | ✓ | +| pipe_heredoc | bash | 3.252 | ±0.403 | - | ✓ | +| pipe_herestring | bashkit | 0.100 | ±0.014 | - | ✓ | +| pipe_herestring | bash | 3.160 | ±0.144 | - | ✓ | +| pipe_discard | bashkit | 0.099 | ±0.009 | - | ✓ | +| pipe_discard | bash | 2.766 | ±0.861 | - | ✓ | + +### Startup + +| Benchmark | Runner | Mean (ms) | StdDev | Errors | Match | +|-----------|--------|-----------|--------|--------|-------| +| startup_empty | bashkit | 0.101 | ±0.047 | - | ✓ | +| startup_empty | bash | 1.701 | ±0.191 | - | ✓ | +| startup_true | bashkit | 0.077 | ±0.011 | - | ✓ | +| startup_true | bash | 1.819 | ±0.215 | - | ✓ | +| startup_echo | bashkit | 0.082 | ±0.014 | - | ✓ | +| startup_echo | bash | 1.760 | ±0.137 | - | ✓ | +| startup_exit | bashkit | 0.080 | ±0.015 | - | ✓ | +| startup_exit | bash | 1.718 | ±0.150 | - | ✓ | + +### Strings + +| Benchmark | Runner | Mean (ms) | StdDev | Errors | Match | +|-----------|--------|-----------|--------|--------|-------| +| str_concat | bashkit | 0.106 | ±0.049 | - | ✓ | +| str_concat | bash | 1.743 | ±0.121 | - | ✓ | +| str_printf | bashkit | 0.083 | ±0.007 | - | ✓ | +| str_printf | bash | 1.660 | ±0.118 | - | ✓ | +| str_printf_pad | bashkit | 0.143 | ±0.120 | - | ✓ | +| str_printf_pad | bash | 1.678 | ±0.105 | - | ✓ | +| str_echo_escape | bashkit | 0.081 | ±0.014 | - | ✓ | +| str_echo_escape | bash | 1.630 | ±0.073 | - | ✓ | +| str_prefix_strip | bashkit | 0.094 | ±0.008 | - | ✓ | +| str_prefix_strip | bash | 1.735 | ±0.232 | - | ✓ | +| str_suffix_strip | bashkit | 0.091 | ±0.008 | - | ✓ | +| str_suffix_strip | bash | 1.625 | ±0.084 | - | ✓ | +| str_uppercase | bashkit | 0.086 | ±0.007 | - | ✓ | +| str_uppercase | bash | 1.821 | ±0.349 | - | ✓ | +| str_lowercase | bashkit | 0.086 | ±0.007 | - | ✓ | +| str_lowercase | bash | 1.850 | ±0.198 | - | ✓ | + +### Subshell + +| Benchmark | Runner | Mean (ms) | StdDev | Errors | Match | +|-----------|--------|-----------|--------|--------|-------| +| subshell_simple | bashkit | 0.104 | ±0.044 | - | ✓ | +| subshell_simple | bash | 2.352 | ±0.791 | - | ✓ | +| subshell_isolation | bashkit | 0.129 | ±0.070 | - | ✓ | +| subshell_isolation | bash | 2.130 | ±0.117 | - | ✓ | +| subshell_nested | bashkit | 0.169 | ±0.109 | - | ✓ | +| subshell_nested | bash | 3.809 | ±0.219 | - | ✓ | +| subshell_pipeline | bashkit | 0.168 | ±0.043 | - | ✓ | +| subshell_pipeline | bash | 3.445 | ±0.368 | - | ✓ | +| subshell_capture_loop | bashkit | 0.204 | ±0.064 | - | ✓ | +| subshell_capture_loop | bash | 4.136 | ±0.158 | - | ✓ | +| subshell_process_subst | bashkit | 0.135 | ±0.014 | - | ✓ | +| subshell_process_subst | bash | 2.701 | ±0.091 | - | ✓ | + +### Tools + +| Benchmark | Runner | Mean (ms) | StdDev | Errors | Match | +|-----------|--------|-----------|--------|--------|-------| +| tool_grep_simple | bashkit | 0.258 | ±0.099 | - | ✓ | +| tool_grep_simple | bash | 4.741 | ±0.595 | - | ✓ | +| tool_grep_case | bashkit | 0.290 | ±0.117 | - | ✓ | +| tool_grep_case | bash | 8.649 | ±5.557 | - | ✓ | +| tool_grep_count | bashkit | 0.409 | ±0.489 | - | ✓ | +| tool_grep_count | bash | 4.853 | ±2.102 | - | ✓ | +| tool_grep_invert | bashkit | 0.141 | ±0.047 | - | ✓ | +| tool_grep_invert | bash | 4.019 | ±0.491 | - | ✓ | +| tool_grep_regex | bashkit | 0.297 | ±0.223 | - | ✓ | +| tool_grep_regex | bash | 3.663 | ±0.175 | - | ✓ | +| tool_sed_replace | bashkit | 0.129 | ±0.035 | - | ✓ | +| tool_sed_replace | bash | 4.403 | ±0.466 | - | ✓ | +| tool_sed_global | bashkit | 0.110 | ±0.015 | - | ✓ | +| tool_sed_global | bash | 3.841 | ±0.248 | - | ✓ | +| tool_sed_delete | bashkit | 0.110 | ±0.015 | - | ✓ | +| tool_sed_delete | bash | 4.169 | ±0.490 | - | ✓ | +| tool_sed_lines | bashkit | 0.145 | ±0.063 | - | ✓ | +| tool_sed_lines | bash | 3.788 | ±0.223 | - | ✓ | +| tool_sed_backrefs | bashkit | 0.156 | ±0.027 | - | ✓ | +| tool_sed_backrefs | bash | 3.974 | ±0.241 | - | ✓ | +| tool_awk_print | bashkit | 0.132 | ±0.036 | - | ✓ | +| tool_awk_print | bash | 3.454 | ±0.137 | - | ✓ | +| tool_awk_sum | bashkit | 0.129 | ±0.030 | - | ✓ | +| tool_awk_sum | bash | 3.648 | ±0.222 | - | ✓ | +| tool_awk_pattern | bashkit | 0.207 | ±0.091 | - | ✓ | +| tool_awk_pattern | bash | 3.376 | ±0.123 | - | ✓ | +| tool_awk_fieldsep | bashkit | 0.132 | ±0.045 | - | ✓ | +| tool_awk_fieldsep | bash | 3.698 | ±0.420 | - | ✓ | +| tool_awk_nf | bashkit | 0.142 | ±0.079 | - | ✓ | +| tool_awk_nf | bash | 3.533 | ±0.146 | - | ✓ | +| tool_awk_compute | bashkit | 0.130 | ±0.052 | - | ✓ | +| tool_awk_compute | bash | 3.667 | ±0.490 | - | ✓ | +| tool_jq_identity | bashkit | 1.049 | ±0.109 | - | ✓ | +| tool_jq_identity | bash | 5.170 | ±0.651 | - | ✓ | +| tool_jq_field | bashkit | 1.041 | ±0.129 | - | ✓ | +| tool_jq_field | bash | 5.247 | ±0.329 | - | ✓ | +| tool_jq_array | bashkit | 1.246 | ±0.650 | - | ✓ | +| tool_jq_array | bash | 5.185 | ±0.354 | - | ✓ | +| tool_jq_filter | bashkit | 0.978 | ±0.033 | - | ✓ | +| tool_jq_filter | bash | 5.477 | ±0.476 | - | ✓ | +| tool_jq_map | bashkit | 1.451 | ±0.817 | - | ✓ | +| tool_jq_map | bash | 5.464 | ±0.749 | - | ✓ | + +### Variables + +| Benchmark | Runner | Mean (ms) | StdDev | Errors | Match | +|-----------|--------|-----------|--------|--------|-------| +| var_assign_simple | bashkit | 0.085 | ±0.008 | - | ✓ | +| var_assign_simple | bash | 1.823 | ±0.222 | - | ✓ | +| var_assign_many | bashkit | 0.159 | ±0.083 | - | ✓ | +| var_assign_many | bash | 1.780 | ±0.162 | - | ✓ | +| var_default | bashkit | 0.115 | ±0.076 | - | ✓ | +| var_default | bash | 1.655 | ±0.034 | - | ✓ | +| var_length | bashkit | 0.109 | ±0.050 | - | ✓ | +| var_length | bash | 1.714 | ±0.139 | - | ✓ | +| var_substring | bashkit | 0.114 | ±0.050 | - | ✓ | +| var_substring | bash | 1.783 | ±0.239 | - | ✓ | +| var_replace | bashkit | 0.114 | ±0.058 | - | ✓ | +| var_replace | bash | 1.679 | ±0.055 | - | ✓ | +| var_nested | bashkit | 0.094 | ±0.009 | - | ✓ | +| var_nested | bash | 1.735 | ±0.146 | - | ✓ | +| var_export | bashkit | 0.091 | ±0.009 | - | ✓ | +| var_export | bash | 1.889 | ±0.240 | - | ✓ | + +## Runner Descriptions + +| Runner | Type | Description | +|--------|------|-------------| +| bashkit | in-process | Rust library call, no fork/exec | +| bashkit-cli | subprocess | bashkit binary, new process per run | +| bashkit-js | persistent child | Node.js + @everruns/bashkit, warm interpreter | +| bashkit-py | persistent child | Python + bashkit package, warm interpreter | +| bash | subprocess | PATH-selected Bash >=4, new process per run | +| gbash | subprocess | gbash binary (Go), new process per run | +| gbash-server | persistent child | gbash JSON-RPC server, warm interpreter | +| just-bash | subprocess | just-bash CLI, new process per run | +| just-bash-inproc | persistent child | Node.js + just-bash library, warm interpreter | + +## Assumptions & Notes + +- Times measured in nanoseconds, displayed in milliseconds +- Prewarm phase runs first few cases to warm up JIT/compilation +- Per-benchmark warmup iterations excluded from timing +- Output match compares against bash output when available +- Errors include execution failures and exit code mismatches +- In-process: interpreter runs inside the benchmark process +- Subprocess: new process spawned per benchmark run +- Persistent child: long-lived child process, amortizes startup cost diff --git a/crates/bashkit/benches/results/criterion-parallel-a9d59d0fdfe3-linux-x86_64-1795314525.md b/crates/bashkit/benches/results/criterion-parallel-a9d59d0fdfe3-linux-x86_64-1795314525.md new file mode 100644 index 000000000..d26e2a78c --- /dev/null +++ b/crates/bashkit/benches/results/criterion-parallel-a9d59d0fdfe3-linux-x86_64-1795314525.md @@ -0,0 +1,75 @@ +# Criterion Parallel Execution Benchmark + +## System Information + +- **Moniker**: `a9d59d0fdfe3-linux-x86_64` +- **Hostname**: a9d59d0fdfe3 +- **OS**: linux +- **Architecture**: x86_64 +- **CPUs**: 5 +- **Timestamp**: 1795314525 + +## Workload Comparison (50 sessions) + +| Benchmark | Time | +|-----------|------| +| workload_types/light_sequential | 6.1603 ms | +| workload_types/light_parallel | 2.3878 ms | +| workload_types/medium_sequential | 26.670 ms | +| workload_types/medium_parallel | 8.2585 ms | +| workload_types/heavy_sequential | 68.155 ms | +| workload_types/heavy_parallel | 26.163 ms | + +## Parallel Scaling (medium workload) + +| Benchmark | Time | +|-----------|------| +| parallel_scaling/medium_seq/10 | 4.7173 ms | +| parallel_scaling/medium_par/10 | 1.8414 ms | +| parallel_scaling/shared_fs/10 | 1.3012 ms | +| parallel_scaling/medium_seq/50 | 23.725 ms | +| parallel_scaling/medium_par/50 | 8.2302 ms | +| parallel_scaling/shared_fs/50 | 7.2815 ms | +| parallel_scaling/medium_seq/100 | 46.450 ms | +| parallel_scaling/medium_par/100 | 17.274 ms | +| parallel_scaling/shared_fs/100 | 11.391 ms | +| parallel_scaling/medium_seq/200 | 115.18 ms | +| parallel_scaling/medium_par/200 | 34.851 ms | +| parallel_scaling/shared_fs/200 | 23.454 ms | +| parallel_scaling/medium_seq/500 | 232.87 ms | +| parallel_scaling/medium_par/500 | 78.240 ms | +| parallel_scaling/shared_fs/500 | 64.056 ms | +| parallel_scaling/medium_seq/1000 | 472.17 ms | +| parallel_scaling/medium_par/1000 | 202.24 ms | +| parallel_scaling/shared_fs/1000 | 164.85 ms | + +## Single Operations + +| Benchmark | Time | +|-----------|------| +| single_bash_new | 61.917 µs | +| single_echo | 77.953 µs | +| single_file_write_read | 124.68 µs | +| single_grep | 129.28 µs | +| single_awk | 134.93 µs | +| single_sed | 124.53 µs | +| single_light_script | 117.01 µs | +| single_medium_script | 583.28 µs | +| single_heavy_script | 1.4084 ms | + +## Speedup Summary + +| Workload | Sequential | Parallel | Speedup | +|----------|-----------|----------|---------| +| light | 6.160 ms | 2.388 ms | **2.58x** | +| medium | 26.670 ms | 8.258 ms | **3.23x** | +| heavy | 68.155 ms | 26.163 ms | **2.61x** | + +| Sessions | Sequential | Parallel | Shared FS | Par Speedup | +|----------|-----------|----------|-----------|-------------| +| 10 | 4.717 ms | 1.841 ms | 1.301 ms | **2.56x** | +| 50 | 23.725 ms | 8.230 ms | 7.282 ms | **2.88x** | +| 100 | 46.450 ms | 17.274 ms | 11.391 ms | **2.69x** | +| 200 | 115.180 ms | 34.851 ms | 23.454 ms | **3.30x** | +| 500 | 232.870 ms | 78.240 ms | 64.056 ms | **2.98x** | +| 1000 | 472.170 ms | 202.240 ms | 164.850 ms | **2.33x** | diff --git a/crates/bashkit/docs/jq.md b/crates/bashkit/docs/jq.md index 37fd893aa..f4d5e7cf7 100644 --- a/crates/bashkit/docs/jq.md +++ b/crates/bashkit/docs/jq.md @@ -103,10 +103,13 @@ catch its way around it. Output is capped by `max_stdout_bytes`, and a filter that loops without emitting (`until(false; .)`) stops at the execution timeout with `jq: execution timed out`. -`--stream` produces path events incrementally, sharing ancestor keys. Event -and traversal storage obey the same memory limit, and traversal checks work, -cancellation and timeout limits even with an `empty` filter. `--slurp` -retains events and can hit the memory limit on otherwise small JSON input. +`--stream` produces path events directly from tokens without building a JSON +tree, sharing ancestor keys. Path, event and container storage obey the same +memory limit, and scanning checks work, cancellation and timeout limits even +with an `empty` filter. Ordinary `input`/`inputs` parse one top-level value at +a time. Input source text remains buffered by the filesystem interface. +`--slurp` retains values or events and can hit the memory limit on otherwise +small JSON input. The limit counts real in-memory size, which is several times the JSON text: a 5.6 MB array of 100,000 small objects fits the default, much larger inputs diff --git a/crates/bashkit/src/builtins/curl.rs b/crates/bashkit/src/builtins/curl.rs index 55b0a2771..e63f2b114 100644 --- a/crates/bashkit/src/builtins/curl.rs +++ b/crates/bashkit/src/builtins/curl.rs @@ -950,7 +950,7 @@ async fn execute_curl_request( .await?; match result { - Ok(response) => { + Ok(mut response) => { if verbose { verbose_output.push_str(&format!("< HTTP/1.1 {}\r\n", response.status)); for (name, value) in &response.headers { @@ -1038,11 +1038,14 @@ async fn execute_curl_request( Some("deflate") => { decompress_deflate(&response.body, http_client.max_response_bytes())? } - _ => response.body.clone(), + _ => std::mem::take(&mut response.body), } } else { - response.body.clone() + std::mem::take(&mut response.body) }; + // The compressed input is no longer needed after decoding; + // uncompressed bodies have already moved out without copying. + response.body = Vec::new(); // Keep response bytes canonical for files, redirects, and // pipelines. Only text consumers may decode invalid UTF-8. @@ -1076,12 +1079,17 @@ async fn execute_curl_request( } // Append write-out format if specified - let mut final_output = verbose_output.into_bytes(); - final_output.extend_from_slice(&output); - if let Some(fmt) = write_out { - final_output.extend_from_slice( - format_write_out(fmt, &response, output.len()).as_bytes(), - ); + let write_out_text = + write_out.map(|fmt| format_write_out(fmt, &response, output.len())); + let mut final_output = if verbose_output.is_empty() { + output + } else { + let mut prefixed = verbose_output.into_bytes(); + prefixed.extend_from_slice(&output); + prefixed + }; + if let Some(text) = write_out_text { + final_output.extend_from_slice(text.as_bytes()); } return Ok(ExecResult::ok(final_output)); diff --git a/crates/bashkit/src/builtins/jq/convert.rs b/crates/bashkit/src/builtins/jq/convert.rs index 2a5bf221b..dba9ac219 100644 --- a/crates/bashkit/src/builtins/jq/convert.rs +++ b/crates/bashkit/src/builtins/jq/convert.rs @@ -203,6 +203,35 @@ pub(super) fn jq_to_val(v: &JqJson) -> Val { } } +/// Transfer a parsed input into the evaluator. Input trees are single-use; +/// moving their strings avoids retaining a second full decoded copy. +pub(super) fn jq_into_val(value: JqJson) -> Val { + match value { + JqJson::Null => Val::Null, + JqJson::Bool(b) => Val::from(b), + JqJson::Number(s) => { + if let Ok(i) = s.parse::() + && let Ok(i) = isize::try_from(i) + { + return Val::from(i); + } + if s.parse::().is_ok() { + Val::Num(super::jaq_json::Num::Dec(super::jaq_json::Rc::new(s))) + } else { + Val::from(0isize) + } + } + JqJson::String(s) => Val::from(s), + JqJson::Array(values) => values.into_iter().map(jq_into_val).collect(), + JqJson::Object(entries) => Val::obj( + entries + .into_iter() + .map(|(key, value)| (Val::from(key), jq_into_val(value))) + .collect(), + ), + } +} + /// Convert jaq Val back to JqJson for output formatting. Captures number /// representation via Val's Display (jaq preserves the original token). /// Convert a result for output. `None` when the value would render to more diff --git a/crates/bashkit/src/builtins/jq/input.rs b/crates/bashkit/src/builtins/jq/input.rs index 9f67a5db4..1403c3695 100644 --- a/crates/bashkit/src/builtins/jq/input.rs +++ b/crates/bashkit/src/builtins/jq/input.rs @@ -6,8 +6,15 @@ use std::borrow::Cow; +use super::{Context, Val}; use crate::limits::{ExecutionBudget, ExecutionBudgetLease}; +/// JSON has four whitespace bytes. ASCII whitespace also includes form-feed, +/// which must remain part of an invalid scalar rather than split it in two. +pub(super) fn is_json_whitespace(byte: u8) -> bool { + matches!(byte, b' ' | b'\t' | b'\n' | b'\r') +} + #[derive(Debug)] pub(super) struct NormalizedInput<'a> { text: Cow<'a, str>, @@ -32,6 +39,60 @@ impl From for NormalizeError { } } +impl From for NormalizeError { + fn from(error: crate::Error) -> Self { + Self::Resource(error) + } +} + +/// Cache the end of the last line inspected, so many values on one long line +/// never rescan its suffix quadratically. +#[derive(Default)] +pub(super) struct Lines { + counted: usize, + lines: usize, +} + +impl Lines { + pub(super) fn at(&mut self, text: &str, end: usize, ctx: &Context<'_>) -> crate::Result { + if end > self.counted { + let last = end.saturating_sub(1); + let mut eol = text.len(); + for (i, chunk) in text.as_bytes()[last..].chunks(1024).enumerate() { + if let Some(p) = chunk.iter().position(|&c| c == b'\n') { + ctx.consume_budget_work((p + 1) as u64)?; + eol = last + i * 1024 + p + 1; + break; + } + ctx.consume_budget_work(chunk.len() as u64)?; + } + for chunk in text.as_bytes()[self.counted..eol].chunks(1024) { + ctx.consume_budget_work(chunk.len() as u64)?; + self.lines += chunk.iter().filter(|&&c| c == b'\n').count(); + } + self.counted = eol; + } + Ok(self.lines) + } +} + +/// Only one input tree exists at a time. Conversion occurs under the jq meter, +/// then the temporary tree is dropped before the evaluator requests more input. +pub(super) fn values<'a, 'shell>( + text: &'a str, + ctx: &'a Context<'shell>, +) -> impl Iterator> + 'a { + let mut lines = Lines::default(); + checked_value_spans(text, |n| ctx.consume_budget_work(n)).map(move |span| { + let (start, end) = span?; + ctx.consume_budget_work(1)?; + let value = super::parse_jq_json_value(ctx, &text[start..end])? + .map_err(NormalizeError::InvalidJson)?; + let value = super::convert::jq_into_val(value); + Ok((value, lines.at(text, end, ctx)?)) + }) +} + /// THREAT[TM-DOS-100]: Normalize in one bounded pass. Work is charged before /// scanning, and live bytes are reserved before allocating or growing output. pub(super) fn normalize<'a>( @@ -112,87 +173,95 @@ pub(super) fn normalize<'a>( /// jq tokenizes: strings, bracketed values, and literal tokens that run to /// the next whitespace or structural character. The parser validates each /// span; this only finds boundaries. -pub(super) fn value_spans(text: &str) -> Vec<(usize, usize)> { +pub(super) fn value_spans(text: &str) -> impl Iterator + '_ { + checked_value_spans(text, |_| Ok(())).map(|span| span.expect("infallible span scan")) +} + +fn checked_value_spans<'a>( + text: &'a str, + mut checkpoint: impl FnMut(u64) -> crate::Result<()> + 'a, +) -> impl Iterator> + 'a { let b = text.as_bytes(); - let mut out = Vec::new(); let mut i = 0usize; - loop { - while i < b.len() && b[i].is_ascii_whitespace() { - i += 1; - } - if i >= b.len() { - break; + let mut done = false; + std::iter::from_fn(move || { + if done { + return None; } - let start = i; - let scalar = !matches!(b[i], b'[' | b'{' | b'"'); - let (mut depth, mut in_str, mut esc) = (0usize, false, false); - while i < b.len() { - let c = b[i]; - i += 1; - if in_str { - if esc { - esc = false; - } else if c == b'\\' { - esc = true; - } else if c == b'"' { - in_str = false; - if depth == 0 { - break; - } + let result = (|| -> crate::Result> { + while i < b.len() && is_json_whitespace(b[i]) { + i += 1; + if i.is_multiple_of(1024) { + checkpoint(1024)?; } - continue; } - if scalar { - if c.is_ascii_whitespace() - || matches!(c, b'[' | b'{' | b'"' | b']' | b'}' | b',' | b':') - { - i -= 1; - if i == start { - // A stray structural character: its own (invalid) span. - i += 1; + if i >= b.len() { + return Ok(None); + } + let start = i; + let scalar = !matches!(b[i], b'[' | b'{' | b'"'); + let (mut depth, mut in_str, mut esc) = (0usize, false, false); + while i < b.len() { + let c = b[i]; + i += 1; + if i.is_multiple_of(1024) { + checkpoint(1024)?; + } + if in_str { + if esc { + esc = false; + } else if c == b'\\' { + esc = true; + } else if c == b'"' { + in_str = false; + if depth == 0 { + break; + } } - break; + continue; } - continue; - } - match c { - b'"' => in_str = true, - b'[' | b'{' => depth += 1, - b']' | b'}' => { - depth = depth.saturating_sub(1); - if depth == 0 { + if scalar { + if is_json_whitespace(c) + || matches!(c, b'[' | b'{' | b'"' | b']' | b'}' | b',' | b':') + { + i -= 1; + if i == start { + // A stray structural character: its own (invalid) span. + i += 1; + if i.is_multiple_of(1024) { + checkpoint(1024)?; + } + } break; } + continue; + } + match c { + b'"' => in_str = true, + b'[' | b'{' => depth += 1, + b']' | b'}' => { + depth = depth.saturating_sub(1); + if depth == 0 { + break; + } + } + _ => {} } - _ => {} } - } - out.push((start, i)); - } - out -} - -/// Line number jq reports for each top-level value of `text`: jq reads -/// input a line at a time, so a value counts every newline up to the end -/// of the line it ends on. -pub(super) fn value_lines(text: &str) -> Vec { - let b = text.as_bytes(); - let (mut counted, mut lines) = (0usize, 0usize); - value_spans(text) - .into_iter() - .map(|(_, end)| { - let last = end.saturating_sub(1); - let eol = b[last..] - .iter() - .position(|&c| c == b'\n') - .map_or(b.len(), |p| last + p + 1); - if eol > counted { - lines += b[counted..eol].iter().filter(|&&c| c == b'\n').count(); - counted = eol; + Ok(Some((start, i))) + })(); + match result { + Ok(Some(span)) => Some(Ok(span)), + Ok(None) => { + done = true; + None } - lines - }) - .collect() + Err(error) => { + done = true; + Some(Err(error)) + } + } + }) } #[cfg(test)] @@ -264,22 +333,35 @@ mod tests { #[test] fn value_spans_split_like_jq() { let text = "1 \"a b\" [1, [2]] {\"k\": \"}\"}2[3]"; - let parts: Vec<&str> = super::value_spans(text) - .into_iter() - .map(|(a, b)| &text[a..b]) - .collect(); + let parts: Vec<&str> = super::value_spans(text).map(|(a, b)| &text[a..b]).collect(); assert_eq!( parts, ["1", "\"a b\"", "[1, [2]]", "{\"k\": \"}\"}", "2", "[3]"] ); let glued = "1\u{1}2"; - assert_eq!(super::value_spans(glued), [(0, glued.len())]); + assert_eq!( + super::value_spans(glued).collect::>(), + [(0, glued.len())] + ); } - #[test] - fn value_lines_count_lines_read() { - assert_eq!(super::value_lines("1\n2\n3"), [1, 2, 2]); - assert_eq!(super::value_lines("[\n1\n]\n2"), [3, 3]); - assert_eq!(super::value_lines("1 2"), [0, 0]); + #[tokio::test] + async fn value_lines_count_lines_read() { + for (text, expected) in [ + ("1\n2\n3", "1\n2\n2\n"), + ("[\n1\n]\n2", "3\n3\n"), + ("1 2", "0\n0\n"), + ] { + let mut bash = crate::Bash::builder().build(); + let result = bash + .exec_with_options( + "jq input_line_number", + crate::ExecOptions::new().stdin(text), + ) + .await + .unwrap(); + assert_eq!(result.exit_code, 0, "{}", result.stderr); + assert_eq!(result.stdout, expected); + } } } diff --git a/crates/bashkit/src/builtins/jq/mod.rs b/crates/bashkit/src/builtins/jq/mod.rs index b8b39c6a1..bc8c4e53c 100644 --- a/crates/bashkit/src/builtins/jq/mod.rs +++ b/crates/bashkit/src/builtins/jq/mod.rs @@ -139,14 +139,6 @@ impl<'a, V: jaq_core::ValT + 'static> HasInputs<'a, V> for InputDataRef<'a, V> { /// jq command - JSON processor pub struct Jq; -/// Bookkeeping for one filter run: the input value and the per-input -/// metadata (filename / line number) bound to compat globals. -struct FilterInput { - value: JqJson, - filename: Val, - lineno: usize, -} - #[async_trait] impl Builtin for Jq { async fn execute(&self, ctx: Context<'_>) -> Result { @@ -209,17 +201,18 @@ async fn run_jq(ctx: Context<'_>, parsed: JqArgs<'_>) -> Result { // turns the final exit status into 2. let mut stderr_out = String::new(); let mut input_failed = false; - let mut sources: Vec<(Option<&str>, String)> = Vec::new(); + let mut sources: Vec<(Option<&str>, std::borrow::Cow<'_, str>)> = Vec::new(); if parsed.file_args.is_empty() { - sources.push((None, ctx.stdin.map(|s| s.to_string()).unwrap_or_default())); + sources.push((None, ctx.stdin.map(|s| s.text_lossy()).unwrap_or_default())); } else { for file_arg in &parsed.file_args { let path = resolve_path(ctx.cwd, file_arg); match ctx.fs.read_file(&path).await { Ok(bytes) => { - let text = crate::StreamData::from(bytes).to_string(); + let text = String::from_utf8(bytes) + .unwrap_or_else(|e| String::from_utf8_lossy(e.as_bytes()).into_owned()); ctx.consume_budget_input(text.len())?; - sources.push((Some(*file_arg), text)); + sources.push((Some(*file_arg), text.into())); } Err(e) => { input_failed = true; @@ -292,61 +285,20 @@ async fn run_jq(ctx: Context<'_>, parsed: JqArgs<'_>) -> Result { filter }; - // Keep parsed input trees, not expanded events. Conversion and streaming - // happen inside the metered, unwind-protected synchronous evaluation. - let mut parse_error: Option = None; - let mut items: Vec = Vec::new(); + // Sources remain buffered by the builtin/VFS contract, but parsing and + // conversion are driven by input demand, never collected up front. + if parsed.seq && !parsed.raw_input { + for (_, text) in &mut sources { + if text.contains('\x1e') { + *text = text.replace('\x1e', " ").into(); + } + } + } + let parse_error = std::cell::RefCell::new(None); let name_val = |name: &Option<&str>| match name { Some(n) => Val::from((*n).to_string()), None => Val::Null, }; - if parsed.raw_input && parsed.slurp { - let text: String = sources.iter().map(|(_, t)| t.as_str()).collect(); - items.push(FilterInput { - value: JqJson::String(text), - filename: sources - .last() - .map(|(n, _)| name_val(n)) - .unwrap_or(Val::Null), - lineno: 0, - }); - } else if parsed.raw_input { - for (name, text) in &sources { - for (i, line) in text.lines().enumerate() { - items.push(FilterInput { - value: JqJson::String(line.to_string()), - filename: name_val(name), - lineno: i + 1, - }); - } - } - } else { - for (name, text) in &sources { - let seq_text; - let text = if parsed.seq { - seq_text = text.replace('\x1e', " "); - &seq_text - } else { - text - }; - let (vals, err) = parse_jq_json_stream_partial(&ctx, text)?; - let lines = input::value_lines(text); - for (i, value) in vals.into_iter().enumerate() { - items.push(FilterInput { - value, - filename: name_val(name), - lineno: lines.get(i).copied().unwrap_or(0), - }); - } - if let Some(e) = err { - parse_error = Some(e); - break; - } - } - if parsed.slurp && parse_error.is_some() { - items.clear(); - } - } let indent = parsed.indent; @@ -435,53 +387,107 @@ async fn run_jq(ctx: Context<'_>, parsed: JqArgs<'_>) -> Result { let env_val = jq_to_val(&env_obj); let args_val = jq_to_val(&args_obj); let pre_var_vals: Vec = all_var_bindings.iter().map(|(_, v)| jq_to_val(v)).collect(); - let tracker = current.clone(); - let values = items.iter().flat_map(|fi| { - let iter: Box> + '_> = - if parsed.stream && !parsed.raw_input { - Box::new(stream::StreamEvents::new(&fi.value, &ctx)) - } else { - Box::new(std::iter::once_with(|| Ok(jq_to_val(&fi.value)))) - }; - let tracker = tracker.clone(); - iter.inspect(move |_| { - *tracker.borrow_mut() = (fi.filename.clone(), fi.lineno); - }) - }); + let values: Box> + '_> = + if parsed.raw_input && parsed.slurp { + Box::new(std::iter::once_with(|| { + let size = sources.iter().map(|(_, t)| t.len()).sum(); + stream::check(size).map_err(input::NormalizeError::Resource)?; + let text: String = sources.iter().map(|(_, t)| t.as_ref()).collect(); + *current.borrow_mut() = ( + sources + .last() + .map(|(n, _)| name_val(n)) + .unwrap_or(Val::Null), + 0, + ); + Ok(Val::from(text)) + })) + } else { + Box::new(sources.iter().flat_map(|(name, text)| { + let filename = name_val(name); + let inputs: Box< + dyn Iterator< + Item = std::result::Result<(Val, usize), input::NormalizeError>, + > + '_, + > = if parsed.raw_input { + Box::new(text.lines().enumerate().map(|(i, line)| { + ctx.consume_budget_work(1 + line.len() as u64)?; + stream::check(line.len())?; + Ok((Val::from(line.to_owned()), i + 1)) + })) + } else if parsed.stream { + Box::new(stream::Parser::new(text, &ctx)) + } else { + Box::new(input::values(text, &ctx)) + }; + let current = ¤t; + inputs.map(move |value| { + value.map(|(value, line)| { + *current.borrow_mut() = (filename.clone(), line); + value + }) + }) + })) + }; let mut value_iter: Box> + '_> = Box::new( values - .map(|value| { - value.map_err(|error| { + .map_while(|value| match value { + Ok(value) => Some(Ok(value)), + Err(input::NormalizeError::InvalidJson(message)) => { + *parse_error.borrow_mut() = Some(message); + None + } + Err(input::NormalizeError::Resource(error)) => { let message = error.to_string(); *input_error.borrow_mut() = Some(error); - message - }) + Some(Err(message)) + } }) + .fuse() .chain(std::iter::from_fn(|| { stream_exhausted.set(true); None })), ); - if parsed.slurp && !parsed.raw_input && parse_error.is_none() { - let mut values = jaq_json::meter::Metered::>::default(); - for value in value_iter { - let value = match value { - Ok(value) => value, - Err(e) => { - return Ok(Some(ExecResult::err(format!("jq: input error: {e}\n"), 5))); + if parsed.slurp && !parsed.raw_input { + // Slurping itself is demand-driven: `-ns 42` must not parse an + // ignored malformed tail or allocate an unused input array. + let mut inputs = value_iter; + let mut done = false; + let input_current = ¤t; + let pending_error = &parse_error; + let resource_error = &input_error; + let input_sources = &sources; + value_iter = Box::new(std::iter::from_fn(move || { + if std::mem::replace(&mut done, true) { + return None; + } + let mut values = jaq_json::meter::Metered::>::default(); + for value in &mut inputs { + let value = match value { + Ok(value) => value, + Err(message) => return Some(Err(message)), + }; + if let Err(error) = stream::push_metered(&mut values, value) { + let message = error.to_string(); + *resource_error.borrow_mut() = Some(error); + return Some(Err(message)); } - }; - stream::push_metered(&mut values, value)?; - } - *current.borrow_mut() = ( - sources - .last() - .map(|(n, _)| name_val(n)) - .unwrap_or(Val::Null), - 0, - ); - value_iter = Box::new(std::iter::once(Ok(Val::Arr(jaq_json::Rc::new(values))))); + } + // Slurp runs its filter only after the entire stream parses. + if pending_error.borrow().is_some() { + return None; + } + *input_current.borrow_mut() = ( + input_sources + .last() + .map(|(n, _)| name_val(n)) + .unwrap_or(Val::Null), + 0, + ); + Some(Ok(Val::Arr(jaq_json::Rc::new(values)))) + })); } let shared_inputs = RcIter::new(value_iter); @@ -652,8 +658,9 @@ async fn run_jq(ctx: Context<'_>, parsed: JqArgs<'_>) -> Result { stderr_out.push_str(&messages::take()); let mut code = status.unwrap_or(if parsed.exit_status { 4 } else { 0 }); - if let Some(e) = - parse_error.filter(|_| halted.is_none() && (!null_input || stream_exhausted.get())) + if let Some(e) = parse_error + .into_inner() + .filter(|_| halted.is_none() && (!null_input || stream_exhausted.get())) { stderr_out.push_str(&e); stderr_out.push('\n'); @@ -673,12 +680,11 @@ async fn run_jq(ctx: Context<'_>, parsed: JqArgs<'_>) -> Result { }) } -/// Like [`parse_jq_json_stream`], but keeps the values before a syntax -/// error: jq processes them, then reports the error. -fn parse_jq_json_stream_partial( +/// Normalize and parse just the value requested by the shared input cursor. +fn parse_jq_json_value( ctx: &Context<'_>, input: &str, -) -> Result<(Vec, Option)> { +) -> Result> { let execution_budget = ctx .execution_budget() .map(|budget| { @@ -689,10 +695,15 @@ fn parse_jq_json_stream_partial( .transpose()?; let normalized = match input::normalize(execution_budget.as_ref(), input) { Ok(normalized) => normalized, - Err(input::NormalizeError::InvalidJson(message)) => return Ok((Vec::new(), Some(message))), + Err(input::NormalizeError::InvalidJson(message)) => return Ok(Err(message)), Err(input::NormalizeError::Resource(error)) => return Err(error), }; - Ok(convert::parse_json_stream_partial(normalized.as_str())) + Ok( + convert::parse_json_value(normalized.as_str()).map_err(|error| match error { + convert::JsonParseError::TooDeep(message) => message, + convert::JsonParseError::Invalid(message) => format!("jq: invalid JSON: {message}"), + }), + ) } fn parse_jq_json_stream( diff --git a/crates/bashkit/src/builtins/jq/stream.rs b/crates/bashkit/src/builtins/jq/stream.rs index 022c5429c..68eb48cb4 100644 --- a/crates/bashkit/src/builtins/jq/stream.rs +++ b/crates/bashkit/src/builtins/jq/stream.rs @@ -1,15 +1,15 @@ -//! `--stream` traverses the depth-bounded input tree incrementally. Ancestor -//! keys are shared jaq strings, never copied into a retained list of events. +//! `--stream` parses tokens into path events without building an input tree. +//! Ancestor keys are shared jaq strings, never copied into an event list. //! THREAT[TM-DOS-110]: cursor, path and event bodies are admitted by the jq //! meter before allocation; each traversal step checks shared work/deadline/ //! cancellation limits, including when the filter emits nothing. -use super::Context; -use super::convert::{JqJson, jq_to_val}; +use super::convert::{JqJson, MAX_JQ_JSON_DEPTH, jq_into_val}; use super::jaq_json::{Rc, Val, meter}; +use super::{Context, input}; use crate::error::{Error, Result}; -fn check(bytes: usize) -> Result<()> { +pub(super) fn check(bytes: usize) -> Result<()> { meter::check(bytes).map_err(|e| Error::Execution(e.to_string())) } @@ -32,106 +32,255 @@ fn array(values: impl ExactSizeIterator) -> Result { Ok(Val::Arr(Rc::new(meter::Metered::new(body)))) } -enum Children<'a> { - Array(std::iter::Enumerate>), - Object(std::slice::Iter<'a, (String, JqJson)>), +#[derive(Clone, Copy)] +enum Kind { + Array, + Object, } -impl<'a> Children<'a> { - fn next(&mut self) -> Result> { - match self { - Self::Array(iter) => Ok(iter.next().map(|(i, v)| (Val::from(i), v))), - Self::Object(iter) => iter - .next() - .map(|(k, v)| { - check(k.len())?; - Ok((Val::from(k.clone()), v)) - }) - .transpose(), - } - } +#[derive(Clone, Copy)] +enum State { + First, + Next, + After, } -struct Frame<'a> { - children: Children<'a>, +struct Frame { + kind: Kind, + state: State, path_len: usize, + index: usize, } -pub(super) struct StreamEvents<'a, 'shell> { - pending: Option<&'a JqJson>, - stack: meter::Metered>>, +/// Token-driven path events: neither a top-level tree nor an event list is +/// retained. Only the open containers, shared path keys and current leaf live +/// across `next` calls. Syntax, depth and resource checks happen on demand. +pub(super) struct Parser<'a, 'shell> { + text: &'a str, + offset: usize, + event_end: usize, + stack: meter::Metered>, path: meter::Metered>, + lines: input::Lines, ctx: &'a Context<'shell>, done: bool, } -impl<'a, 'shell> StreamEvents<'a, 'shell> { - pub(super) fn new(value: &'a JqJson, ctx: &'a Context<'shell>) -> Self { +type ReadResult = std::result::Result; + +impl<'a, 'shell> Parser<'a, 'shell> { + pub(super) fn new(text: &'a str, ctx: &'a Context<'shell>) -> Self { Self { - pending: Some(value), + text, + offset: 0, + event_end: 0, stack: meter::Metered::default(), path: meter::Metered::default(), + lines: input::Lines::default(), ctx, done: false, } } - fn next_event(&mut self) -> Result> { + fn invalid(&self, message: &str) -> input::NormalizeError { + input::NormalizeError::InvalidJson(format!("jq: invalid JSON: {message}")) + } + + fn peek(&self) -> Option { + self.text.as_bytes().get(self.offset).copied() + } + + fn advance(&mut self) -> ReadResult<()> { + self.offset += 1; + if self.offset.is_multiple_of(1024) { + self.ctx.consume_budget_work(1024)?; + meter::tick(); + } + Ok(()) + } + + fn whitespace(&mut self) -> ReadResult<()> { + while self.peek().is_some_and(input::is_json_whitespace) { + self.advance()?; + } + Ok(()) + } + + fn scalar(&mut self) -> ReadResult { + let start = self.offset; + if self.peek() == Some(b'"') { + self.advance()?; + let mut escaped = false; + loop { + let Some(byte) = self.peek() else { + return Err(self.invalid("unterminated string at end of input")); + }; + self.advance()?; + if escaped { + escaped = false; + } else if byte == b'\\' { + escaped = true; + } else if byte == b'"' { + break; + } + } + } else { + while self.peek().is_some_and(|b| { + !input::is_json_whitespace(b) + && !matches!(b, b'[' | b'{' | b'"' | b']' | b'}' | b',' | b':') + }) { + self.advance()?; + } + } + if self.offset == start { + return Err(self.invalid("expected a value")); + } + let token = &self.text[start..self.offset]; + // Admit the leaf/key before serde allocates its temporary decoded form. + check(token.len())?; + let value = super::parse_jq_json_value(self.ctx, token)? + .map_err(input::NormalizeError::InvalidJson)?; + Ok(jq_into_val(value)) + } + + fn next_event(&mut self) -> ReadResult> { loop { self.ctx.consume_budget_work(1)?; meter::tick(); - if let Some(value) = self.pending.take() { - let children = match value { - JqJson::Array(a) if !a.is_empty() => { - Some(Children::Array(a.iter().enumerate())) - } - JqJson::Object(o) if !o.is_empty() => Some(Children::Object(o.iter())), - _ => None, + self.whitespace()?; + if let Some(frame) = self.stack.last() { + let (kind, state, path_len, index) = + (frame.kind, frame.state, frame.path_len, frame.index); + let closing = match kind { + Kind::Array => b']', + Kind::Object => b'}', }; - if let Some(children) = children { + match state { + State::After => match self.peek() { + Some(b',') => { + self.advance()?; + self.stack + .last_mut() + .expect("container inspected above") + .state = State::Next; + continue; + } + Some(b) if b == closing => { + self.advance()?; + self.stack.pop(); + self.path.truncate(path_len + 1); + let path = array(self.path.iter().cloned())?; + self.event_end = self.offset; + return Ok(Some(array([path].into_iter())?)); + } + _ => return Err(self.invalid("expected a comma or container end")), + }, + State::First if self.peek() == Some(closing) => { + self.advance()?; + self.stack.pop(); + self.path.truncate(path_len); + let empty = match kind { + Kind::Array => JqJson::Array(Vec::new()), + Kind::Object => JqJson::Object(Vec::new()), + }; + let path = array(self.path.iter().cloned())?; + self.event_end = self.offset; + return Ok(Some(array([path, jq_into_val(empty)].into_iter())?)); + } + State::First | State::Next => { + self.path.truncate(path_len); + let key = match kind { + Kind::Array => Val::from(index), + Kind::Object => { + if self.peek() != Some(b'"') { + return Err(self.invalid("expected an object key")); + } + let key = self.scalar()?; + self.whitespace()?; + if self.peek() != Some(b':') { + return Err(self.invalid("expected a colon")); + } + self.advance()?; + self.whitespace()?; + key + } + }; + push_metered(&mut self.path, key)?; + let frame = self.stack.last_mut().expect("container inspected above"); + frame.state = State::After; + frame.index += 1; + } + } + } else { + self.path.clear(); + if self.peek().is_none() { + return Ok(None); + } + } + if self.stack.len() > MAX_JQ_JSON_DEPTH { + return Err(input::NormalizeError::InvalidJson(format!( + "jq: JSON nesting too deep ({} levels, max {MAX_JQ_JSON_DEPTH})", + self.stack.len() + ))); + } + match self.peek() { + Some(b'[' | b'{') => { + let kind = if self.peek() == Some(b'[') { + Kind::Array + } else { + Kind::Object + }; + self.advance()?; push_metered( &mut self.stack, Frame { - children, + kind, + state: State::First, path_len: self.path.len(), + index: 0, }, )?; - continue; } - if let JqJson::String(s) | JqJson::Number(s) = value { - check(s.len())?; + Some(_) => { + let leaf = self.scalar()?; + // jq commits a scalar inside a container only once its + // following separator is valid (`[1` emits no event). + if let Some(frame) = self.stack.last() { + let closing = match frame.kind { + Kind::Array => b']', + Kind::Object => b'}', + }; + self.whitespace()?; + if !self.peek().is_some_and(|b| b == b',' || b == closing) { + return Err(self.invalid("expected a comma or container end")); + } + } + let path = array(self.path.iter().cloned())?; + // A scalar was committed by looking at its separator; + // include that character in jq's line-read metadata. + self.event_end = self.offset + usize::from(!self.stack.is_empty()); + return Ok(Some(array([path, leaf].into_iter())?)); } - let leaf = jq_to_val(value); - let path = array(self.path.iter().cloned())?; - return array([path, leaf].into_iter()).map(Some); - } - let Some(frame) = self.stack.last_mut() else { - return Ok(None); - }; - if let Some((key, value)) = frame.children.next()? { - self.path.truncate(frame.path_len); - push_metered(&mut self.path, key)?; - self.pending = Some(value); - } else { - // A closing event keeps the last child's key, not its descendants. - self.path.truncate(frame.path_len + 1); - self.stack.pop(); - let path = array(self.path.iter().cloned())?; - return array([path].into_iter()).map(Some); + None => return Err(self.invalid("unexpected end of input")), } } } } -impl Iterator for StreamEvents<'_, '_> { - type Item = Result; - +impl Iterator for Parser<'_, '_> { + type Item = ReadResult<(Val, usize)>; fn next(&mut self) -> Option { if self.done { return None; } match self.next_event() { - Ok(Some(value)) => Some(Ok(value)), + Ok(Some(value)) => match self.lines.at(self.text, self.event_end, self.ctx) { + Ok(line) => Some(Ok((value, line))), + Err(error) => { + self.done = true; + Some(Err(error.into())) + } + }, Ok(None) => { self.done = true; None diff --git a/crates/bashkit/src/builtins/jq/tests.rs b/crates/bashkit/src/builtins/jq/tests.rs index 127edb92d..022d3d905 100644 --- a/crates/bashkit/src/builtins/jq/tests.rs +++ b/crates/bashkit/src/builtins/jq/tests.rs @@ -1604,6 +1604,49 @@ mod differential { use super::*; + #[tokio::test] + async fn diff_stream_token_events_and_partial_errors() { + for text in [ + r#"{"a":[1,{"b":null}],"c":"d"}"#, + r#"[{},[],[[]],{"a":{}},true,false,null,-1.25,"a\\\"b"]"#, + r#"{"a":1,"a":2,"\u00e9":["\ud83d\ude00"]}"#, + "1 [] {} [1,2] {\"a\":3}\n", + "[1,]", + "[1", + "{\"a\":1,}", + "{\"a\" 1}", + "[}", + "[1] junk", + "1\u{1}2", + "[1\u{c},2]", + "\u{c}1", + "\"unterminated", + ] { + assert_matches(&["-c", "--stream", "."], text).await; + } + for text in [ + "[\n1,\n{\"x\":2},\n[]\n]\n", + "{\"x\":1,\n\"y\":[\n2\n]}\n", + "1\n2\n3", + ] { + assert_matches(&["-c", "--stream", "[input_line_number,.]"], text).await; + } + } + + #[tokio::test] + async fn diff_scalar_controls_are_not_json_whitespace() { + // jq 1.7 may truncate stdin at NUL. The non-oracle regression below + // still requires rejecting NUL under Bashkit's strict-boundary policy. + for byte in 1u8..32 { + if [9, 10, 13].contains(&byte) { + continue; + } + let input = format!("1{}2", char::from(byte)); + assert_matches(&["-c", "."], &input).await; + assert_matches(&["-c", "--stream", "."], &input).await; + } + } + fn real_jq_available() -> bool { real_jq_version().is_some() } @@ -2475,6 +2518,58 @@ async fn stream_flag_feeds_path_events() { assert_eq!(out, "{\"a\":[1,2]}\n"); } +#[tokio::test] +async fn lazy_input_stops_before_malformed_tail_and_slurp_rejects_it() { + for flags in [vec!["-nc", "input"], vec!["-nc", "--stream", "input"]] { + let result = run_jq_result_with_args(&flags, "1 \"unterminated") + .await + .unwrap(); + assert_eq!(result.exit_code, 0, "{}", result.stderr); + assert!(result.stderr.is_empty()); + assert_eq!( + result.stdout, + if flags.contains(&"--stream") { + "[[],1]\n" + } else { + "1\n" + } + ); + } + for flags in [vec!["-sc", "."], vec!["-sc", "--stream", "."]] { + let result = run_jq_result_with_args(&flags, "1 [2,").await.unwrap(); + assert_eq!(result.exit_code, 5); + assert_eq!(result.stdout, ""); + assert!(result.stderr.contains("invalid JSON"), "{}", result.stderr); + } + for flags in [vec!["-nsc", "42"], vec!["-nsc", "--stream", "42"]] { + let result = run_jq_result_with_args(&flags, "1 [2,").await.unwrap(); + assert_eq!(result.exit_code, 0, "{}", result.stderr); + assert!(result.stderr.is_empty()); + assert_eq!(result.stdout, "42\n"); + } +} + +#[tokio::test] +async fn stream_parser_rejects_depth_and_retains_control_normalization() { + let deep = format!("{}0{}", "[".repeat(102), "]".repeat(102)); + let result = run_jq_result_with_args(&["--stream", "empty"], &deep) + .await + .unwrap(); + assert_eq!(result.exit_code, 5); + assert!( + result.stderr.contains("JSON nesting too deep"), + "{}", + result.stderr + ); + let out = run_jq_with_args(&["--stream", "-c", "."], "{\"a\n\":[\"b\t\"]}") + .await + .unwrap(); + assert_eq!( + out, + "[[\"a\\n\",0],\"b\\t\"]\n[[\"a\\n\",0]]\n[[\"a\\n\"]]\n" + ); +} + #[tokio::test] async fn stream_slurp_and_metadata_preserve_event_order() { let result = run_jq_with_files( @@ -2511,6 +2606,46 @@ async fn seq_flag_uses_record_separators() { assert_eq!(out, "\x1e[1]\n\x1e2\n"); } +#[tokio::test] +async fn raw_sequence_input_preserves_record_separator_characters() { + let text = "\x1eone\n\x1etwo\n"; + for (flags, expected) in [ + ( + vec!["-Rc", "--seq", "."], + "\x1e\"\\u001eone\"\n\x1e\"\\u001etwo\"\n", + ), + ( + vec!["-Rsc", "--seq", "."], + "\x1e\"\\u001eone\\n\\u001etwo\\n\"\n", + ), + ] { + let result = run_jq_result_with_args(&flags, text).await.unwrap(); + assert_eq!(result.exit_code, 0, "{}", result.stderr); + assert!(result.stderr.is_empty()); + assert_eq!(result.stdout, expected); + } +} + +#[tokio::test] +async fn scalar_control_characters_are_rejected_before_output() { + for byte in 0u8..32 { + if [9, 10, 13].contains(&byte) { + continue; + } + let input = format!("1{}2", char::from(byte)); + for flags in [vec!["-c", "."], vec!["-c", "--stream", "."]] { + let result = run_jq_result_with_args(&flags, &input).await.unwrap(); + assert_eq!(result.exit_code, 5, "control byte {byte}"); + assert!( + result.stdout.is_empty(), + "control byte {byte}: {}", + result.stdout + ); + assert!(result.stderr.contains("invalid JSON"), "{}", result.stderr); + } + } +} + #[tokio::test] async fn destructuring_alternatives_follow_jq() { let out = run_jq_with_args( diff --git a/crates/bashkit/src/builtins/wc.rs b/crates/bashkit/src/builtins/wc.rs index 7801558f1..80ef1089a 100644 --- a/crates/bashkit/src/builtins/wc.rs +++ b/crates/bashkit/src/builtins/wc.rs @@ -2,7 +2,7 @@ use async_trait::async_trait; -use super::{Builtin, Context, read_stream_file}; +use super::{Builtin, Context}; use crate::error::Result; use crate::fs::vfs_join; use crate::interpreter::ExecResult; @@ -132,7 +132,7 @@ impl Builtin for Wc { if files.is_empty() { // Read from stdin if let Some(stdin) = ctx.stdin { - let counts = count_data(stdin.as_bytes()); + let counts = count_data(stdin.as_bytes(), &flags); // Real bash: no padding for single-value stdin, padded for multiple values let width = if flags.active_count() > 1 { 7 } else { 1 }; output.push_str(&format_counts(&counts, &flags, None, width)); @@ -152,11 +152,19 @@ impl Builtin for Wc { .stat(&path) .await .is_ok_and(|m| m.file_type.is_file()); - match read_stream_file(&*ctx.fs, &path, "wc").await { - Ok(data) => { - counted.push((count_data(data.as_bytes()), regular && *file != "-")) + // Counting bytes/lines needs no decoded StreamData cache. + match ctx.fs.read_file(&path).await { + Ok(data) => counted.push((count_data(&data, &flags), regular && *file != "-")), + Err(e) => { + return Ok(ExecResult::err( + format!( + "wc: {}: {}\n", + path.display(), + crate::error::io_error_reason(&e) + ), + 1, + )); } - Err(e) => return Ok(*e), } } let width = number_width(&counted, flags.active_count()); @@ -205,16 +213,38 @@ struct TextCounts { /// Count stream data. Invalid UTF-8 is one character per byte, matching the /// byte-oriented C locale instead of inventing Unicode replacement characters. -fn count_data(bytes: &[u8]) -> TextCounts { - let text = String::from_utf8_lossy(bytes); +fn count_data(bytes: &[u8], flags: &WcFlags) -> TextCounts { + // Decode only for counts that require text. In particular, `-c` is an + // O(1) length query over the borrowed bytes, even for invalid UTF-8. + let text = if flags.words || flags.max_line_length { + String::from_utf8_lossy(bytes) + } else { + std::borrow::Cow::Borrowed("") + }; // wc -l counts newline characters, not logical lines - let lines = bytes.iter().filter(|&&byte| byte == b'\n').count(); - let words = text.split_whitespace().count(); + let lines = if flags.lines { + bytes.iter().filter(|&&byte| byte == b'\n').count() + } else { + 0 + }; + let words = if flags.words { + text.split_whitespace().count() + } else { + 0 + }; let byte_count = bytes.len(); - let chars = std::str::from_utf8(bytes) - .map(|valid| valid.chars().count()) - .unwrap_or(byte_count); - let max_line_length = text.lines().map(|l| l.chars().count()).max().unwrap_or(0); + let chars = if flags.chars { + std::str::from_utf8(bytes) + .map(|valid| valid.chars().count()) + .unwrap_or(byte_count) + } else { + 0 + }; + let max_line_length = if flags.max_line_length { + text.lines().map(|l| l.chars().count()).max().unwrap_or(0) + } else { + 0 + }; TextCounts { lines, words, diff --git a/crates/bashkit/src/network/client.rs b/crates/bashkit/src/network/client.rs index 1866e0ae1..4dd6b0065 100644 --- a/crates/bashkit/src/network/client.rs +++ b/crates/bashkit/src/network/client.rs @@ -498,7 +498,16 @@ impl HttpClient { async fn read_body_with_limit(&self, response: reqwest::Response) -> Result> { use futures_util::StreamExt; - let mut body = Vec::new(); + // The caller has already rejected Content-Length above the response + // cap. Reserve a bounded prefix to reduce growth and spare capacity. + // A large advertised length alone must not force a large allocation. + let capacity = response + .content_length() + .and_then(|n| usize::try_from(n).ok()) + .filter(|&n| n <= self.max_response_bytes) + .unwrap_or(0) + .min(1 << 20); + let mut body = Vec::with_capacity(capacity); let mut stream = response.bytes_stream(); while let Some(chunk_result) = stream.next().await { diff --git a/crates/bashkit/tests/large_file_stress_tests.rs b/crates/bashkit/tests/large_file_stress_tests.rs new file mode 100644 index 000000000..967a2304a --- /dev/null +++ b/crates/bashkit/tests/large_file_stress_tests.rs @@ -0,0 +1,477 @@ +//! Large-file integrity and resource stress tests. +//! +//! Decisions: separate binary for process-wide allocation measurement; +//! current-thread tests share a serial lock. Fixtures are created before measuring, +//! so peaks report incremental command heap, including output retained in VFS. +//! A deterministic transport exercises the HTTP host boundary; a loopback HTTP +//! server also exercises reqwest with content-length and chunked bodies, without +//! internet variability. This does not benchmark external networks or TLS. +//! Default 1 MiB is CI-sized. BASHKIT_STRESS_MIB=64 scales the same assertions. +//! Timing is diagnostic only; heap has a generous linear regression ceiling. + +#![cfg(all(feature = "http_client", feature = "jq"))] + +use async_trait::async_trait; +use bashkit::{ + Bash, BashBuilder, ExecutionLimits, FsLimits, HttpLimits, HttpResponse, HttpTransport, + HttpTransportError, HttpTransportRequest, InMemoryFs, NetworkAllowlist, +}; +use sha2::{Digest, Sha256}; +use std::alloc::{GlobalAlloc, Layout, System}; +use std::path::Path; +use std::sync::Arc; +use std::sync::atomic::{AtomicUsize, Ordering}; +use std::time::{Duration, Instant}; +use tokio::io::{AsyncReadExt, AsyncWriteExt}; + +struct Counting; +static LIVE: AtomicUsize = AtomicUsize::new(0); +static PEAK: AtomicUsize = AtomicUsize::new(0); +static SERIAL: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(()); + +unsafe impl GlobalAlloc for Counting { + unsafe fn alloc(&self, layout: Layout) -> *mut u8 { + let ptr = unsafe { System.alloc(layout) }; + if !ptr.is_null() { + let live = LIVE.fetch_add(layout.size(), Ordering::Relaxed) + layout.size(); + PEAK.fetch_max(live, Ordering::Relaxed); + } + ptr + } + + unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { + LIVE.fetch_sub(layout.size(), Ordering::Relaxed); + unsafe { System.dealloc(ptr, layout) }; + } + + // Count transient realloc overlap conservatively, even if the system + // allocator could have grown in place. + unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, size: usize) -> *mut u8 { + let new = unsafe { System.realloc(ptr, layout, size) }; + if !new.is_null() { + let live = LIVE.fetch_add(size, Ordering::Relaxed) + size; + PEAK.fetch_max(live, Ordering::Relaxed); + LIVE.fetch_sub(layout.size(), Ordering::Relaxed); + } + new + } +} + +#[global_allocator] +static ALLOCATOR: Counting = Counting; + +const URL: &str = "http://93.184.216.34/fixture"; +const ROW: &[u8] = b"{\"n\":1,\"s\":\"abcdefghijklmnopqrstuvwxyz0123456789\"}\n"; + +struct FixtureTransport(Arc>); + +#[async_trait] +impl HttpTransport for FixtureTransport { + async fn execute(&self, _: HttpTransportRequest) -> Result { + // Deliberately ignore the advertised limit to exercise the host-side + // backstop as well as successful transfers. + Ok(HttpResponse { + status: 200, + headers: vec![], + body: self.0.as_ref().clone(), + }) + } +} + +fn builder(bytes: usize) -> BashBuilder { + Bash::builder() + .fs(Arc::new(InMemoryFs::with_limits(FsLimits { + max_file_size: (bytes * 4) as u64, + max_total_bytes: (bytes * 16) as u64, + ..Default::default() + }))) + .limits( + ExecutionLimits::new() + .timeout(Duration::from_secs(120)) + .max_work_units((bytes as u64) * 256) + .max_aggregate_input_bytes((bytes as u64) * 64) + .max_live_intermediate_bytes((bytes as u64) * 64), + ) + .http_limits(HttpLimits::default().max_response_bytes(bytes)) +} + +fn shell(bytes: usize, body: Arc>) -> Bash { + builder(bytes) + .network(NetworkAllowlist::allow_all()) + .http_transport(Arc::new(FixtureTransport(body))) + .build() +} + +async fn serve(mut socket: tokio::net::TcpStream, body: &[u8]) -> std::io::Result<()> { + let mut request = Vec::new(); + let mut buf = [0; 2048]; + while !request.windows(4).any(|w| w == b"\r\n\r\n") { + let n = socket.read(&mut buf).await?; + if n == 0 || request.len() + n > 16_384 { + return Ok(()); + } + request.extend_from_slice(&buf[..n]); + } + let chunked = request.starts_with(b"GET /chunked "); + let framing = if chunked { + "Transfer-Encoding: chunked".into() + } else { + format!("Content-Length: {}", body.len()) + }; + socket + .write_all(format!("HTTP/1.1 200 OK\r\n{framing}\r\nConnection: close\r\n\r\n").as_bytes()) + .await?; + if chunked { + for chunk in body.chunks(64 << 10) { + socket + .write_all(format!("{:x}\r\n", chunk.len()).as_bytes()) + .await?; + socket.write_all(chunk).await?; + socket.write_all(b"\r\n").await?; + } + socket.write_all(b"0\r\n\r\n").await?; + } else { + socket.write_all(body).await?; + } + socket.shutdown().await +} + +async fn measure(bash: &mut Bash, script: &str, expected: &str, bytes: usize) { + // Warm caches outside the measured interval. + assert_eq!(bash.exec("true").await.unwrap().exit_code, 0); + let baseline = LIVE.load(Ordering::Relaxed); + PEAK.store(baseline, Ordering::Relaxed); + let start = Instant::now(); + let result = bash.exec(script).await.expect(script); + let elapsed = start.elapsed(); + let peak = PEAK.load(Ordering::Relaxed).saturating_sub(baseline); + eprintln!( + "{script}\tinput={bytes}\tpeak={peak}\tms={:.2}\texit={}", + elapsed.as_secs_f64() * 1000.0, + result.exit_code + ); + assert_eq!(result.exit_code, 0, "{script}: {}", result.stderr); + assert_eq!(result.stdout.trim(), expected, "{script}"); + assert!(result.stderr.is_empty(), "{script}: {}", result.stderr); + assert!(peak < bytes * 32 + (8 << 20), "{script}: peak={peak}"); + // Each command owns its derived files; discard between measurements. + let cleanup = bash + .exec("rm -f /out /encoded /decoded /packed.gz") + .await + .unwrap(); + assert_eq!(cleanup.exit_code, 0, "{}", cleanup.stderr); +} + +#[tokio::test(flavor = "current_thread")] +async fn large_files_preserve_bytes_and_finish_with_linear_heap() { + let _serial = SERIAL.lock().await; + let mib = std::env::var("BASHKIT_STRESS_MIB") + .map(|s| { + s.parse::() + .expect("BASHKIT_STRESS_MIB must be an integer") + }) + .unwrap_or(1); + assert!((1..=256).contains(&mib), "scale must be 1..=256 MiB"); + let bytes = mib * (1 << 20); + // Incompressible deterministic bytes exercise full-size compression paths + // as well as invalid UTF-8 and NUL handling. + let mut state = 0x2545_f491_4f6c_dd1d_u64; + let binary = Arc::new( + (0..bytes) + .map(|_| { + state ^= state << 13; + state ^= state >> 7; + state ^= state << 17; + (state >> 24) as u8 + }) + .collect::>(), + ); + let digest: String = Sha256::digest(binary.as_slice()) + .iter() + .map(|byte| format!("{byte:02x}")) + .collect(); + let mut bash = shell(bytes, binary.clone()); + bash.fs() + .write_file(Path::new("/binary"), &binary) + .await + .unwrap(); + let rows = bytes / ROW.len(); + let json = ROW.repeat(rows); + bash.fs() + .write_file(Path::new("/data.jsonl"), &json) + .await + .unwrap(); + drop(json); + let mut string = vec![b'x'; bytes]; + string[0] = b'"'; + string[bytes - 1] = b'"'; + bash.fs() + .write_file(Path::new("/string.json"), &string) + .await + .unwrap(); + drop(string); + + for command in [ + format!("curl -s -o /out {URL}"), + format!("curl -s {URL} > /out"), + format!("wget -q -O /out {URL}"), + format!("wget -q -O - {URL} > /out"), + "cp /binary /out".into(), + ] { + measure( + &mut bash, + &format!("{command} && sha256sum /out"), + &format!("{digest} /out"), + bytes, + ) + .await; + } + for command in [ + format!("curl -s {URL} | sha256sum"), + format!("wget -q -O - {URL} | sha256sum"), + "cat /binary | sha256sum".into(), + ] { + measure(&mut bash, &command, &format!("{digest} -"), bytes).await; + } + for command in [ + "base64 /binary > /encoded && base64 -d /encoded > /decoded && sha256sum /decoded", + "gzip -c /binary > /packed.gz && gzip -dc /packed.gz > /decoded && sha256sum /decoded", + ] { + measure(&mut bash, command, &format!("{digest} /decoded"), bytes).await; + } + for (command, expected) in [ + ("wc -c < /binary", bytes.to_string()), + ("wc -l < /data.jsonl", rows.to_string()), + ("grep -c abcdef /data.jsonl", rows.to_string()), + ("rg -c abcdef /data.jsonl", rows.to_string()), + ("sed -n '$=' /data.jsonl", rows.to_string()), + ("awk 'END { print NR }' /data.jsonl", rows.to_string()), + ("cut -d: -f1 /data.jsonl | wc -l", rows.to_string()), + ( + "head -n 1 /data.jsonl", + String::from_utf8_lossy(ROW).trim().into(), + ), + ( + "tail -n 1 /data.jsonl", + String::from_utf8_lossy(ROW).trim().into(), + ), + ("sort /data.jsonl | uniq | wc -l", "1".into()), + ( + "jq -n 'reduce inputs as $r (0; . + $r.n)' /data.jsonl", + rows.to_string(), + ), + ("jq -s 'length' /data.jsonl", rows.to_string()), + ("jq 'length' /string.json", (bytes - 2).to_string()), + ( + "jq --stream -n 'reduce inputs as $e (0; if ($e|length)==2 and $e[0]==[\"n\"] then .+$e[1] else . end)' /data.jsonl", + rows.to_string(), + ), + ] { + measure(&mut bash, command, &expected, bytes).await; + } + + let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap(); + let base_url = format!("http://{}", listener.local_addr().unwrap()); + let served_body = binary.clone(); + let server = tokio::spawn(async move { + loop { + let (socket, _) = listener.accept().await.unwrap(); + // A capped client closes early; a broken pipe is expected there. + let _ = serve(socket, &served_body).await; + } + }); + let network = NetworkAllowlist::new() + .block_private_ips(false) + .allow(&base_url); + let mut native = builder(bytes).network(network.clone()).build(); + for path in ["length", "chunked"] { + for tool in ["curl -s -o", "wget -q -O"] { + measure( + &mut native, + &format!("{tool} /out {base_url}/{path} && sha256sum /out"), + &format!("{digest} /out"), + bytes, + ) + .await; + } + } + let mut native_limited = builder(bytes - 1).network(network).build(); + for path in ["length", "chunked"] { + for tool in ["curl -s -o", "wget -q -O"] { + native_limited + .fs() + .write_file(Path::new("/out"), b"sentinel") + .await + .unwrap(); + let result = native_limited + .exec(&format!("{tool} /out {base_url}/{path}")) + .await + .unwrap(); + assert_ne!( + result.exit_code, 0, + "native {tool} {path} must reject oversized response" + ); + assert!(result.stderr.contains("too large"), "{}", result.stderr); + assert_eq!( + native_limited + .fs() + .read_file(Path::new("/out")) + .await + .unwrap(), + b"sentinel" + ); + assert_eq!( + native_limited.exec("echo alive").await.unwrap().stdout, + "alive\n" + ); + } + } + server.abort(); + // Release the server's fixture before this runtime unlocks the allocator + // measurement guard; a later test must not inherit its deferred cleanup. + let _ = server.await; + + // One byte over the HTTP cap: no output-file replacement, no poisoned shell. + let mut limited = shell(bytes - 1, binary); + limited + .fs() + .write_file(Path::new("/out"), b"sentinel") + .await + .unwrap(); + for (command, code) in [ + (format!("curl -s -o /out {URL}"), 63), + (format!("wget -q -O /out {URL}"), 1), + ] { + let result = limited.exec(&command).await.unwrap(); + assert_eq!(result.exit_code, code, "{command}: {}", result.stderr); + assert!(result.stderr.contains("too large"), "{}", result.stderr); + eprintln!("HTTP cap rejection: {command}: {}", result.stderr.trim()); + assert_eq!( + limited.fs().read_file(Path::new("/out")).await.unwrap(), + b"sentinel" + ); + assert_eq!(limited.exec("echo alive").await.unwrap().stdout, "alive\n"); + } + + // A small live-value budget must reject jq slurping without poisoning the + // session. + let mut bounded = Bash::builder() + .limits( + ExecutionLimits::new() + .max_live_intermediate_bytes(256 << 10) + .max_work_units((bytes as u64) * 256) + .max_aggregate_input_bytes((bytes as u64) * 64), + ) + .build(); + // Stay under the default VFS single-file cap at every scale. + let bounded_rows = (1 << 20) / ROW.len(); + bounded + .fs() + .write_file(Path::new("/data"), &ROW.repeat(bounded_rows)) + .await + .unwrap(); + let rejected = bounded.exec("jq -s length /data").await.unwrap(); + assert_ne!(rejected.exit_code, 0, "slurping must obey the live budget"); + assert!(rejected.stderr.contains("limit"), "{}", rejected.stderr); + eprintln!("jq live-budget rejection: {}", rejected.stderr.trim()); + let recovered = bounded.exec("echo alive").await.unwrap(); + assert_eq!(recovered.stdout, "alive\n"); +} + +async fn regression(script: &str, data: Vec, expected: &str, factor: usize) { + let bytes = data.len(); + let mut bash = shell(bytes, Arc::new(data.clone())); + bash.fs() + .write_file(Path::new("/data"), &data) + .await + .unwrap(); + drop(data); + bash.exec("true").await.unwrap(); + let baseline = LIVE.load(Ordering::Relaxed); + PEAK.store(baseline, Ordering::Relaxed); + let result = bash.exec(script).await.unwrap(); + let peak = PEAK.load(Ordering::Relaxed).saturating_sub(baseline); + assert_eq!(result.exit_code, 0, "{}", result.stderr); + assert_eq!(result.stdout.trim(), expected); + assert!(result.stderr.is_empty(), "{}", result.stderr); + eprintln!("{script}: peak={peak} bytes, input={bytes}"); + assert!( + peak < bytes * factor + (256 << 10), + "{script}: peak={peak}, input={bytes}" + ); +} + +#[tokio::test(flavor = "current_thread")] +async fn memory_regression_wc_bytes_does_not_decode_binary() { + let _serial = SERIAL.lock().await; + regression("wc -c /data", vec![0xff; 1 << 20], "1048576 /data", 1).await; +} + +#[tokio::test(flavor = "current_thread")] +async fn memory_regression_jq_inputs_releases_each_tree() { + let _serial = SERIAL.lock().await; + let rows = (1 << 20) / ROW.len(); + regression( + "jq -n 'reduce inputs as $r (0; . + $r.n)' /data", + ROW.repeat(rows), + &rows.to_string(), + 2, + ) + .await; +} + +#[tokio::test(flavor = "current_thread")] +async fn memory_regression_jq_stream_does_not_build_a_large_array() { + let _serial = SERIAL.lock().await; + let rows = 1 << 18; + let data = format!("[{}0]", "0,".repeat(rows)); + regression( + "jq --stream -n 'reduce inputs as $e (0; if ($e|length)==2 then .+1 else . end)' /data", + data.into_bytes(), + &(rows + 1).to_string(), + 2, + ) + .await; +} + +#[tokio::test(flavor = "current_thread")] +async fn memory_regression_curl_file_does_not_clone_the_body() { + let _serial = SERIAL.lock().await; + regression( + &format!("curl -s -o /out -w '%{{http_code}}:%{{size_download}}:%{{content_type}}' {URL}"), + vec![0xff; 1 << 20], + "200:1048576:", + 2, + ) + .await; +} + +#[tokio::test(flavor = "current_thread")] +async fn memory_regression_wget_reserves_known_response_length() { + let _serial = SERIAL.lock().await; + let bytes = 1 << 20; + let body = Arc::new(vec![0xff; bytes]); + let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap(); + let url = format!("http://{}", listener.local_addr().unwrap()); + let served = body.clone(); + let server = tokio::spawn(async move { + let (socket, _) = listener.accept().await.unwrap(); + serve(socket, &served).await.unwrap(); + }); + let mut bash = builder(bytes) + .network(NetworkAllowlist::new().block_private_ips(false).allow(&url)) + .build(); + bash.exec("true").await.unwrap(); + let baseline = LIVE.load(Ordering::Relaxed); + PEAK.store(baseline, Ordering::Relaxed); + let result = bash + .exec(&format!("wget -q -O /out {url}/length")) + .await + .unwrap(); + let peak = PEAK.load(Ordering::Relaxed).saturating_sub(baseline); + assert_eq!(result.exit_code, 0, "{}", result.stderr); + assert_eq!(bash.fs().read_file(Path::new("/out")).await.unwrap(), *body); + server.await.unwrap(); + eprintln!("native wget: peak={peak}, input={bytes}"); + assert!(peak < bytes * 2 + (256 << 10), "peak={peak}, input={bytes}"); +} diff --git a/justfile b/justfile index d4a8685ce..b72017ce7 100644 --- a/justfile +++ b/justfile @@ -290,6 +290,10 @@ bench-parallel: stress files="2000000": BASHKIT_STRESS_FILES={{files}} cargo test --release -p bashkit --test large_tree_stress_tests -- --nocapture +# Large binary/JSONL files: integrity, heap growth, and resource-limit rejection +stress-files mib="64": + BASHKIT_STRESS_MIB={{mib}} cargo test --locked --release -p bashkit --test large_file_stress_tests --features http_client,jq -- --nocapture + # Run Criterion sqlite builtin benchmark and save results bench-sqlite: ./scripts/bench-sqlite.sh diff --git a/knowledge/foundations/builtins.md b/knowledge/foundations/builtins.md index c51dd390e..c6eaaa501 100644 --- a/knowledge/foundations/builtins.md +++ b/knowledge/foundations/builtins.md @@ -34,6 +34,18 @@ All external-style builtins support `--help` and `--version` flags via the flags `-h`/`-V` have different meanings in many tools). Tools where `-h`/`-V` genuinely mean help/version handle them directly in `execute()`. +### Large-file counting + +`wc` counts only the requested statistics. Byte counts use the borrowed buffer +length and newline counts scan raw bytes; neither decodes text. File operands +read bytes directly, bypassing `StreamData`'s cached lossy text. Character-only +counts validate UTF-8 without allocating; words and maximum line length retain +their existing text semantics. Bytes remain available for GNU column widths +even when `-c` is not selected. Allocation regressions in +`large_file_stress_tests` cover invalid UTF-8, alongside the jq and HTTP paths; +see [Vendored jaq-json](../runtimes/jaq-json-vendor.md) and +[HTTP Transport](../security/http-transport.md). + ### GNU Option Parsing Hand-written coreutils-style builtins parse options with diff --git a/knowledge/foundations/jq.md b/knowledge/foundations/jq.md index d68c0bc90..e1027573f 100644 --- a/knowledge/foundations/jq.md +++ b/knowledge/foundations/jq.md @@ -18,9 +18,9 @@ Implemented. The `jq` builtin accepts literal U+0000 through U+001F controls inside JSON strings. A jq-only input-boundary pass rewrites each such byte to its `\u00XX` -form before the strict serde stream parser sees it. The pass tracks JSON string +form before strict serde validation of the requested value or token. The pass tracks JSON string and escape state, preserves existing escapes and structural whitespace, and -handles NDJSON and concatenated JSON values without splitting the stream. +handles NDJSON and concatenated JSON values without line-based splitting. This is intentionally not a general JSON policy. The `json` builtin, `serde_json` defaults, tool request/response contracts, `--argjson`, and @@ -31,6 +31,10 @@ do not normalize their bytes. Main jq input from stdin or files and Malformed quoting is rejected by the boundary with a stable jq-shaped error. Controls outside strings remain untouched, so only JSON whitespace is accepted there by the strict parser. +The ordinary value splitter and streaming token reader share that four-byte +whitespace definition. Other controls, including form-feed, stay in an invalid +scalar token so they cannot split a bad number into multiple valid inputs or +produce partial scalar output before rejection. ## Object key order @@ -45,10 +49,12 @@ value, matching jq. This covers main input, `--slurpfile`, `--argjson`, `--jsonargs` and `$ARGS`. `$ENV`/`env` stay sorted by name for determinism. The nesting cap (TM-DOS-027) is enforced while reading; a depth violation is reported verbatim, not as a generic parse error. +`--stream` emits keys and duplicate-key events in encounter order directly from +tokens, without constructing an object tree. ## Resource accounting -Normalization is a bounded single pass. It charges input length to the shared +Normalization is a bounded single pass per requested value/token. It charges input length to the shared request work budget before scanning. Inputs without affected controls remain borrowed and allocate nothing. On the first rewrite it reserves the exact current normalized size from the live-intermediate budget before allocation; diff --git a/knowledge/operations/testing.md b/knowledge/operations/testing.md index 7b0c63413..7aa43476a 100644 --- a/knowledge/operations/testing.md +++ b/knowledge/operations/testing.md @@ -180,6 +180,28 @@ The bounded production request uses a 1 KiB header and 256 empty lines. It also checks 256 empty file operands with a 4 KiB date format: no pages means no retained per-file date strings. +`large_file_stress_tests.rs` uses its own counting allocator and serialized +current-thread tests. `just stress-files 64` exercises 64 MiB binary and JSONL +fixtures through curl/wget, redirection/pipelines, jq reduction/slurp/stream, +giant JSON strings, cp, cat, checksums, base64, gzip, wc, grep, rg, sed, awk, +cut, head, tail, sort, and uniq. +The ordinary test uses 1 MiB; `BASHKIT_STRESS_MIB` accepts 1..=256. +Fixtures are allocated before measurement; the reported peak is incremental +command heap including retained VFS output, with conservative realloc overlap. +SHA-256 and exact counts verify results; a generous linear heap ceiling catches +gross allocation regressions, while timings are diagnostic. HTTP uses a custom +transport plus a loopback server with content-length and chunked framing, +covering reqwest as well as the host boundary without external networks or TLS. +Successful stress cases explicitly raise VFS, HTTP, work, input, and live-value +limits. Separate boundary cases reject oversized HTTP bodies while preserving +existing output files, and reject jq slurping under a small live-value budget; +both verify subsequent session use. +Five allocation regressions additionally enforce tight bounds for raw `wc -c` +file reads, jq JSONL input reduction, token-driven streaming of a large single +array, curl's body move with write-out metadata, and native wget downloads with +a known response length. They run at a fixed small scale independently of the +stress setting; a process-wide async mutex excludes concurrent measurements. + Filtering still works as usual: `cargo test --test integration -- foo` matches `integration::*::foo*` test paths. diff --git a/knowledge/runtimes/jaq-json-vendor.md b/knowledge/runtimes/jaq-json-vendor.md index b07fb56b3..2196bb3e1 100644 --- a/knowledge/runtimes/jaq-json-vendor.md +++ b/knowledge/runtimes/jaq-json-vendor.md @@ -101,12 +101,27 @@ same rewrite applies to every release: - Growth operations check the meter *before* allocating and fail with the jq error `value size limit (N bytes) exceeded` (exit 5). The limit is `ExecutionLimits::max_live_intermediate_bytes` (default 32 MB). -- `--stream` traverses the depth-bounded parsed tree incrementally inside - the metered evaluation. Ancestor keys are shared `Val` strings; cursor, - path, event arrays and `--slurp` retention are charged before capacity - growth. Each traversal step consumes shared execution work, checking - cancellation and deadlines even for `empty`. Parsed input trees remain - subject to the existing input and JSON-depth restrictions. +- Ordinary inputs parse one top-level value on demand and drop its temporary + tree after conversion. `input`/`inputs` and the outer loop share that cursor; + an unread malformed tail is not parsed. `--slurp` retains converted values, + but never a second collection of all parsed trees. Raw input lines are lazy + too; `--seq` normalizes separators only for JSON input and preserves them + in raw modes. Span scanning and line-number bookkeeping poll shared work/cancellation + in bounded chunks, without per-value offset tables. +- `--stream` tokenizes the source directly into path events inside the metered + evaluation. It never builds a top-level JSON tree or event list. Ancestor + keys are shared `Val` strings; container cursors, path and event arrays are + admitted before growth. Tokens retain normalization and depth validation; + scanners and traversal check shared work/cancellation/deadlines even for + `empty`. A container's scalar is emitted only after its separator validates, + matching jq's partial output on syntax errors. `--slurp` runs its filter only + after all input parses successfully, and retains events against the meter. + + VFS input sources remain buffered; incremental parsing does not imply + streaming filesystem reads. UTF-8 files transfer their buffers into source + text without a second byte/text cache. `just stress-files 64` measures these + paths; allocation regressions also cover a large single JSON array, JSONL, + and giant strings using explicitly raised execution/VFS/HTTP limits. - The meter is sticky: once tripped, `try ... catch` cannot keep a loop going. - Where there is no error channel (infallible `FromIterator`, `From`) and for loops that never emit a value (`until(false; .)`), the run is diff --git a/knowledge/security/http-transport.md b/knowledge/security/http-transport.md index 106de534a..1cd2a0aa4 100644 --- a/knowledge/security/http-transport.md +++ b/knowledge/security/http-transport.md @@ -54,6 +54,19 @@ output bytes rather than a replacement-expanded text representation. pipelines, compressed responses, gzip extraction, byte counts, and HTTP error handling without live network dependencies. +Uncompressed curl responses move their body buffer into output rather than +cloning it; the usual stdout path reuses it too. Compressed input is released +after decoding, before the VFS write. Write-out status/header metadata remains +available after moving the body. Native response collection reserves a prefix +of a known, already size-checked body length (at most 1 MiB), reducing growth +and spare capacity in curl/wget file downloads without letting an advertised +large length force an equally large allocation. Unknown-length/chunked bodies still +check the cap before appending every chunk. Downloads and VFS writes remain +buffered; the filesystem's borrowed write interface still copies into storage. +`large_file_stress_tests` measures both custom and native transports and checks +binary integrity, allocation bounds, exact-cap success and over-cap preservation +of existing files. + ``` 1. Allowlist check ← security gate 2. Private IP / SSRF check ← SSRF protection, produces pinned_addrs diff --git a/site/src/data/performance-timeline.json b/site/src/data/performance-timeline.json index ec3d0e1f4..dc4078033 100644 --- a/site/src/data/performance-timeline.json +++ b/site/src/data/performance-timeline.json @@ -1,5 +1,5 @@ { - "generatedAt": "2026-11-22T02:07:33.000Z", + "generatedAt": "2026-11-22T02:53:21.000Z", "sources": { "bench": "crates/bashkit-bench/results/*.json", "criterion": "crates/bashkit/benches/results/*.md", @@ -8,21 +8,21 @@ "oilsSpec": "scripts/oils-spec/results/oils-spec-*.json" }, "summary": { - "benchRuns": 13, - "criterionRuns": 22, + "benchRuns": 14, + "criterionRuns": 25, "evalRuns": 58, "latestBench": { - "id": "bench-79f1c12bcc44-linux-x86_64-1792175675", + "id": "bench-a9d59d0fdfe3-linux-x86_64-1795316001", "kind": "bashkit-bench", - "label": "79f1c12bcc44-linux-x86_64", - "date": "2026-10-16", - "timestamp": "2026-10-16T18:34:35.000Z", - "source": "crates/bashkit-bench/results/bench-79f1c12bcc44-linux-x86_64-1792175675.json", - "reportSource": "crates/bashkit-bench/results/bench-79f1c12bcc44-linux-x86_64-1792175675.md", + "label": "a9d59d0fdfe3-linux-x86_64", + "date": "2026-11-22", + "timestamp": "2026-11-22T02:53:21.000Z", + "source": "crates/bashkit-bench/results/bench-a9d59d0fdfe3-linux-x86_64-1795316001.json", + "reportSource": "crates/bashkit-bench/results/bench-a9d59d0fdfe3-linux-x86_64-1795316001.md", "cases": 96, - "speedup": 11.6, - "bashkitMs": 53.12, - "bashMs": 617.31, + "speedup": 13.9, + "bashkitMs": 72.02, + "bashMs": 997.87, "errorRate": 0, "matchRate": 100, "categories": [ @@ -30,97 +30,97 @@ "category": "startup", "description": "Small commands where interpreter startup dominates runtime.", "cases": 4, - "bashkitMedianMs": 0.054, - "bashMedianMs": 1.209, - "speedup": 22.7 + "bashkitMedianMs": 0.081, + "bashMedianMs": 1.739, + "speedup": 21.5 }, { "category": "strings", "description": "String expansion, pattern handling, and text manipulation.", "cases": 8, - "bashkitMedianMs": 0.065, - "bashMedianMs": 1.251, - "speedup": 19.4 - }, - { - "category": "variables", - "description": "Variable assignment, lookup, expansion, and environment handling.", - "cases": 8, - "bashkitMedianMs": 0.067, - "bashMedianMs": 1.183, - "speedup": 18.5 + "bashkitMedianMs": 0.089, + "bashMedianMs": 1.707, + "speedup": 19.2 }, { "category": "arithmetic", "description": "Integer math, substitutions, and expression-heavy shell snippets.", "cases": 6, - "bashkitMedianMs": 0.068, - "bashMedianMs": 1.239, - "speedup": 19.3 + "bashkitMedianMs": 0.102, + "bashMedianMs": 1.756, + "speedup": 17 }, { - "category": "arrays", - "description": "Indexed array reads, writes, expansion, and iteration.", + "category": "pipes", + "description": "Pipeline construction, streaming, and command chaining.", "cases": 6, - "bashkitMedianMs": 0.074, - "bashMedianMs": 1.173, - "speedup": 16 + "bashkitMedianMs": 0.104, + "bashMedianMs": 3.206, + "speedup": 26.4 }, { - "category": "subshell", - "description": "Command substitution and nested shell execution paths.", - "cases": 6, - "bashkitMedianMs": 0.092, - "bashMedianMs": 2.054, - "speedup": 20.8 + "category": "variables", + "description": "Variable assignment, lookup, expansion, and environment handling.", + "cases": 8, + "bashkitMedianMs": 0.112, + "bashMedianMs": 1.758, + "speedup": 15.7 }, { - "category": "pipes", - "description": "Pipeline construction, streaming, and command chaining.", + "category": "arrays", + "description": "Indexed array reads, writes, expansion, and iteration.", "cases": 6, - "bashkitMedianMs": 0.094, - "bashMedianMs": 2.1, - "speedup": 23.3 + "bashkitMedianMs": 0.119, + "bashMedianMs": 1.728, + "speedup": 14.9 }, { "category": "control", "description": "Conditionals, loops, case statements, and branching scripts.", "cases": 9, - "bashkitMedianMs": 0.096, - "bashMedianMs": 1.217, - "speedup": 14.3 - }, - { - "category": "tools", - "description": "Builtin and external-tool style command workloads.", - "cases": 21, - "bashkitMedianMs": 0.099, - "bashMedianMs": 2.607, - "speedup": 25.8 + "bashkitMedianMs": 0.121, + "bashMedianMs": 1.783, + "speedup": 13.7 }, { "category": "io", "description": "File reads, writes, redirects, and filesystem-facing commands.", "cases": 6, - "bashkitMedianMs": 0.099, - "bashMedianMs": 1.934, - "speedup": 18.7 + "bashkitMedianMs": 0.148, + "bashMedianMs": 2.731, + "speedup": 19.2 + }, + { + "category": "subshell", + "description": "Command substitution and nested shell execution paths.", + "cases": 6, + "bashkitMedianMs": 0.151, + "bashMedianMs": 3.073, + "speedup": 20.4 + }, + { + "category": "tools", + "description": "Builtin and external-tool style command workloads.", + "cases": 21, + "bashkitMedianMs": 0.156, + "bashMedianMs": 4.019, + "speedup": 25.4 }, { "category": "complex", "description": "Mixed shell workflows that combine multiple language features.", "cases": 7, - "bashkitMedianMs": 0.157, - "bashMedianMs": 2.607, - "speedup": 11.2 + "bashkitMedianMs": 0.206, + "bashMedianMs": 3.369, + "speedup": 14.7 }, { "category": "large", "description": "Bigger scripts and higher-volume data paths.", "cases": 9, - "bashkitMedianMs": 1.767, - "bashMedianMs": 2.215, - "speedup": 3.3 + "bashkitMedianMs": 2.193, + "bashMedianMs": 3.121, + "speedup": 3.5 } ] }, @@ -500,24 +500,27 @@ ] }, "bestCriterionImprovement": { - "id": "criterion-hotpath-perf-linux-x86_64-1779744742", + "id": "criterion-jq-cloud-linux-x86_64-1795241820", "kind": "criterion", - "family": "hotpath", - "label": "Hot-path Performance: Before / After", - "date": "2026-05-25", - "timestamp": "2026-05-25T21:32:22.000Z", - "source": "crates/bashkit/benches/results/criterion-hotpath-perf-linux-x86_64-1779744742.md", - "reportSource": "crates/bashkit/benches/results/criterion-hotpath-perf-linux-x86_64-1779744742.md", - "cases": 23, - "medianUs": null, - "p95Us": null, - "medianChangePct": -36.6, - "meanChangePct": -39.7, - "bestChangePct": -64.9, - "fastestCase": null, + "family": "jq", + "label": "Criterion jq Builtin Benchmark", + "date": "2026-11-21", + "timestamp": "2026-11-21T06:17:00.000Z", + "source": "crates/bashkit/benches/results/criterion-jq-cloud-linux-x86_64-1795241820.md", + "reportSource": "crates/bashkit/benches/results/criterion-jq-cloud-linux-x86_64-1795241820.md", + "cases": 4, + "medianUs": 7882.5, + "p95Us": 43362.55, + "medianChangePct": -23.2, + "meanChangePct": -36.3, + "bestChangePct": -95.4, + "fastestCase": { + "name": "`jq/single_lookup`", + "us": 802 + }, "bestImprovement": { - "name": "startup/empty", - "changePct": -64.9 + "name": "`jq/repeated_filter`", + "changePct": -95.4 } } }, @@ -1942,6 +1945,119 @@ "speedup": 3.3 } ] + }, + { + "id": "bench-a9d59d0fdfe3-linux-x86_64-1795316001", + "kind": "bashkit-bench", + "label": "a9d59d0fdfe3-linux-x86_64", + "date": "2026-11-22", + "timestamp": "2026-11-22T02:53:21.000Z", + "source": "crates/bashkit-bench/results/bench-a9d59d0fdfe3-linux-x86_64-1795316001.json", + "reportSource": "crates/bashkit-bench/results/bench-a9d59d0fdfe3-linux-x86_64-1795316001.md", + "cases": 96, + "speedup": 13.9, + "bashkitMs": 72.02, + "bashMs": 997.87, + "errorRate": 0, + "matchRate": 100, + "categories": [ + { + "category": "startup", + "description": "Small commands where interpreter startup dominates runtime.", + "cases": 4, + "bashkitMedianMs": 0.081, + "bashMedianMs": 1.739, + "speedup": 21.5 + }, + { + "category": "strings", + "description": "String expansion, pattern handling, and text manipulation.", + "cases": 8, + "bashkitMedianMs": 0.089, + "bashMedianMs": 1.707, + "speedup": 19.2 + }, + { + "category": "arithmetic", + "description": "Integer math, substitutions, and expression-heavy shell snippets.", + "cases": 6, + "bashkitMedianMs": 0.102, + "bashMedianMs": 1.756, + "speedup": 17 + }, + { + "category": "pipes", + "description": "Pipeline construction, streaming, and command chaining.", + "cases": 6, + "bashkitMedianMs": 0.104, + "bashMedianMs": 3.206, + "speedup": 26.4 + }, + { + "category": "variables", + "description": "Variable assignment, lookup, expansion, and environment handling.", + "cases": 8, + "bashkitMedianMs": 0.112, + "bashMedianMs": 1.758, + "speedup": 15.7 + }, + { + "category": "arrays", + "description": "Indexed array reads, writes, expansion, and iteration.", + "cases": 6, + "bashkitMedianMs": 0.119, + "bashMedianMs": 1.728, + "speedup": 14.9 + }, + { + "category": "control", + "description": "Conditionals, loops, case statements, and branching scripts.", + "cases": 9, + "bashkitMedianMs": 0.121, + "bashMedianMs": 1.783, + "speedup": 13.7 + }, + { + "category": "io", + "description": "File reads, writes, redirects, and filesystem-facing commands.", + "cases": 6, + "bashkitMedianMs": 0.148, + "bashMedianMs": 2.731, + "speedup": 19.2 + }, + { + "category": "subshell", + "description": "Command substitution and nested shell execution paths.", + "cases": 6, + "bashkitMedianMs": 0.151, + "bashMedianMs": 3.073, + "speedup": 20.4 + }, + { + "category": "tools", + "description": "Builtin and external-tool style command workloads.", + "cases": 21, + "bashkitMedianMs": 0.156, + "bashMedianMs": 4.019, + "speedup": 25.4 + }, + { + "category": "complex", + "description": "Mixed shell workflows that combine multiple language features.", + "cases": 7, + "bashkitMedianMs": 0.206, + "bashMedianMs": 3.369, + "speedup": 14.7 + }, + { + "category": "large", + "description": "Bigger scripts and higher-volume data paths.", + "cases": 9, + "bashkitMedianMs": 2.193, + "bashMedianMs": 3.121, + "speedup": 3.5 + } + ] } ], "criterionRuns": [ @@ -2383,6 +2499,54 @@ "fastestCase": null, "bestImprovement": null }, + { + "id": "criterion-jq-cloud-linux-x86_64-1795241820", + "kind": "criterion", + "family": "jq", + "label": "Criterion jq Builtin Benchmark", + "date": "2026-11-21", + "timestamp": "2026-11-21T06:17:00.000Z", + "source": "crates/bashkit/benches/results/criterion-jq-cloud-linux-x86_64-1795241820.md", + "reportSource": "crates/bashkit/benches/results/criterion-jq-cloud-linux-x86_64-1795241820.md", + "cases": 4, + "medianUs": 7882.5, + "p95Us": 43362.55, + "medianChangePct": -23.2, + "meanChangePct": -36.3, + "bestChangePct": -95.4, + "fastestCase": { + "name": "`jq/single_lookup`", + "us": 802 + }, + "bestImprovement": { + "name": "`jq/repeated_filter`", + "changePct": -95.4 + } + }, + { + "id": "criterion-jq-lru-cloud-linux-x86_64-1795243168", + "kind": "criterion", + "family": "jq", + "label": "Criterion jq LRU and Filter Compilation Benchmark", + "date": "2026-11-21", + "timestamp": "2026-11-21T06:39:28.000Z", + "source": "crates/bashkit/benches/results/criterion-jq-lru-cloud-linux-x86_64-1795243168.md", + "reportSource": "crates/bashkit/benches/results/criterion-jq-lru-cloud-linux-x86_64-1795243168.md", + "cases": 6, + "medianUs": 8795.5, + "p95Us": 32880.75, + "medianChangePct": -28.2, + "meanChangePct": -38.8, + "bestChangePct": -91.8, + "fastestCase": { + "name": "`jq/single_lookup`", + "us": 618 + }, + "bestImprovement": { + "name": "`jq/interleaved_filters`", + "changePct": -91.8 + } + }, { "id": "criterion-parallel-shell-compat-macos-arm64-1795313253", "kind": "criterion", @@ -2406,6 +2570,27 @@ "name": "single_file_write_read", "changePct": 0.6 } + }, + { + "id": "criterion-parallel-a9d59d0fdfe3-linux-x86_64-1795314525", + "kind": "criterion", + "family": "parallel", + "label": "Criterion Parallel Execution Benchmark", + "date": "2026-11-22", + "timestamp": "2026-11-22T02:28:45.000Z", + "source": "crates/bashkit/benches/results/criterion-parallel-a9d59d0fdfe3-linux-x86_64-1795314525.md", + "reportSource": "crates/bashkit/benches/results/criterion-parallel-a9d59d0fdfe3-linux-x86_64-1795314525.md", + "cases": 33, + "medianUs": 8258.5, + "p95Us": 214492, + "medianChangePct": null, + "meanChangePct": null, + "bestChangePct": null, + "fastestCase": { + "name": "single_bash_new", + "us": 61.92 + }, + "bestImprovement": null } ], "evalRuns": [ @@ -10168,6 +10353,24 @@ "metric": 81.8, "source": "crates/bashkit-eval/results/mira/20261120T203329Z-1c3d/report.json" }, + { + "date": "2026-11-21", + "timestamp": "2026-11-21T06:17:00.000Z", + "kind": "Criterion", + "title": "jq", + "detail": "95.4% faster in `jq/repeated_filter`", + "metric": -23.2, + "source": "crates/bashkit/benches/results/criterion-jq-cloud-linux-x86_64-1795241820.md" + }, + { + "date": "2026-11-21", + "timestamp": "2026-11-21T06:39:28.000Z", + "kind": "Criterion", + "title": "jq", + "detail": "91.8% faster in `jq/interleaved_filters`", + "metric": -28.2, + "source": "crates/bashkit/benches/results/criterion-jq-lru-cloud-linux-x86_64-1795243168.md" + }, { "date": "2026-11-22", "timestamp": "2026-11-22T02:07:33.000Z", @@ -10176,6 +10379,24 @@ "detail": "0.6% faster in single_file_write_read", "metric": 0.6, "source": "crates/bashkit/benches/results/criterion-parallel-shell-compat-macos-arm64-1795313253.md" + }, + { + "date": "2026-11-22", + "timestamp": "2026-11-22T02:28:45.000Z", + "kind": "Criterion", + "title": "parallel", + "detail": "single_bash_new at 61.92 us median", + "metric": 8258.5, + "source": "crates/bashkit/benches/results/criterion-parallel-a9d59d0fdfe3-linux-x86_64-1795314525.md" + }, + { + "date": "2026-11-22", + "timestamp": "2026-11-22T02:53:21.000Z", + "kind": "Benchmark", + "title": "13.9x faster than bash", + "detail": "96 parity/perf cases on a9d59d0fdfe3-linux-x86_64; output match 100%.", + "metric": 13.9, + "source": "crates/bashkit-bench/results/bench-a9d59d0fdfe3-linux-x86_64-1795316001.json" } ] }