wardite 0.9.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +191 -0
- data/Makefile +14 -0
- data/README.md +80 -1
- data/Rakefile +5 -0
- data/benchmark/README.md +500 -0
- data/benchmark/build_call_profile.rb +42 -0
- data/benchmark/call_cost_worker.rb +27 -0
- data/benchmark/compare.rb +93 -0
- data/benchmark/compare_call_types.rb +212 -0
- data/benchmark/compare_dispatch.rb +123 -0
- data/benchmark/compare_engines.rb +119 -0
- data/benchmark/compare_optimizations.rb +139 -0
- data/benchmark/engine_phases.rb +30 -0
- data/benchmark/figures/README.md +35 -0
- data/benchmark/figures/plot_spinel_comparison.py +137 -0
- data/benchmark/figures/spinel_new_vm_candlestick.png +0 -0
- data/benchmark/figures/spinel_new_vm_candlestick.svg +7615 -0
- data/benchmark/figures/spinel_new_vm_summary.csv +9 -0
- data/benchmark/figures/spinel_new_vm_summary.json +82 -0
- data/benchmark/float_m5.wat +42 -0
- data/benchmark/i32_call_arities.wat +89 -0
- data/benchmark/i32_calls.wat +174 -0
- data/benchmark/i32_memory.wat +58 -0
- data/benchmark/i32_mix.wat +80 -0
- data/benchmark/i64_m4.wat +55 -0
- data/benchmark/investigate_calls.rb +231 -0
- data/benchmark/investigate_generated_guards.rb +218 -0
- data/benchmark/m3_call_worker.rb +38 -0
- data/benchmark/measure_m1.rb +51 -0
- data/benchmark/measure_m2.rb +55 -0
- data/benchmark/measure_m3_calls.rb +89 -0
- data/benchmark/measure_m4.rb +134 -0
- data/benchmark/measure_m5_boundary.rb +41 -0
- data/benchmark/measure_wasi_write.rb +75 -0
- data/benchmark/optimization_worker.rb +23 -0
- data/benchmark/results/call_arities_exploratory_2026-11-04.json +4320 -0
- data/benchmark/results/call_arities_spinel_2026-11-04.json +1200 -0
- data/benchmark/results/call_cost_spinel_2026-11-04.json +2392 -0
- data/benchmark/results/call_protocol_exploratory_2026-11-04.json +3947 -0
- data/benchmark/results/call_protocol_profile_2026-11-04.json +383 -0
- data/benchmark/results/call_protocol_ruby_2026-11-04.json +1213 -0
- data/benchmark/results/call_protocol_spinel_2026-11-04.json +913 -0
- data/benchmark/results/call_types_ruby_2026-11-04.json +1212 -0
- data/benchmark/results/call_types_spinel_2026-11-04.json +923 -0
- data/benchmark/results/efflorescence-m1-cruby.json +799 -0
- data/benchmark/results/efflorescence-m1-spinel.json +799 -0
- data/benchmark/results/efflorescence-m2-bulk-loop.json +820 -0
- data/benchmark/results/efflorescence-m2-i32-cruby.json +799 -0
- data/benchmark/results/efflorescence-m2-i32-spinel.json +799 -0
- data/benchmark/results/efflorescence-m2-memory.json +408 -0
- data/benchmark/results/generated_guards_exploratory_2026-11-04.json +1225 -0
- data/benchmark/results/generated_guards_profile_2026-11-04.json +592 -0
- data/benchmark/results/generated_guards_spinel_2026-11-04.json +1650 -0
- data/benchmark/results/generated_guards_validation_2026-11-04.json +256 -0
- data/benchmark/results/inlining_engines_2026-11-04.json +241 -0
- data/benchmark/results/inlining_ruby_2026-11-04.json +1213 -0
- data/benchmark/results/inlining_spinel_2026-11-04.json +893 -0
- data/benchmark/results/operand_decode_exploratory_2026-11-04.json +1319 -0
- data/benchmark/results/operand_decode_ruby_2026-11-04.json +1213 -0
- data/benchmark/results/operand_decode_spinel_2026-11-04.json +924 -0
- data/benchmark/results/selective_reset_spinel_2026-11-04.json +454 -0
- data/benchmark/results/selective_reset_spinel_2026-11-04_exploratory.json +2679 -0
- data/benchmark/results/spinel_fetch_root_patch_2026-11-04.json +4523 -0
- data/benchmark/results/while_final_compiler_comparison_2026-11-04.json +324 -0
- data/benchmark/results/while_patched_external_2026-11-04.json +220 -0
- data/benchmark/results/while_user_unpatched_2026-11-04.json +230 -0
- data/benchmark/summarize_call_profile.py +54 -0
- data/benchmark/validate_m1_eh.rb +34 -0
- data/benchmark/validate_m2.rb +119 -0
- data/benchmark/validate_m3.rb +44 -0
- data/benchmark/validate_m4.rb +95 -0
- data/benchmark/validate_m5.rb +108 -0
- data/docs/adr/0001-efflorescence-m1-control-and-eh.md +319 -0
- data/docs/adr/0002-efflorescence-m2-memory-and-globals.md +185 -0
- data/docs/adr/0003-efflorescence-m3-host-and-indirect-calls.md +228 -0
- data/docs/adr/0004-efflorescence-m4-i64.md +202 -0
- data/docs/adr/0005-efflorescence-m5-floating-point.md +127 -0
- data/docs/adr/0006-efflorescence-m6-coverage-parity.md +101 -0
- data/docs/efflorescence-call-arities.md +115 -0
- data/docs/efflorescence-call-investigation.md +155 -0
- data/docs/efflorescence-call-transfer.md +128 -0
- data/docs/efflorescence-call-types.md +102 -0
- data/docs/efflorescence-coverage-ja.md +351 -0
- data/docs/efflorescence-generated-c-guards.md +405 -0
- data/docs/efflorescence-inlining.md +165 -0
- data/docs/efflorescence-ja.md +155 -0
- data/docs/efflorescence-m1.md +160 -0
- data/docs/efflorescence-m2.md +233 -0
- data/docs/efflorescence-m3.md +131 -0
- data/docs/efflorescence-m4.md +88 -0
- data/docs/efflorescence-m5.md +82 -0
- data/docs/efflorescence-m6.md +95 -0
- data/docs/efflorescence-operand-decoding.md +105 -0
- data/docs/efflorescence-phase2-ja.md +225 -0
- data/docs/efflorescence-phase2.md +240 -0
- data/docs/efflorescence-register-initialization.md +75 -0
- data/docs/efflorescence.md +144 -0
- data/docs/spinel-string-aset-inplace-proposal.md +200 -0
- data/lib/wardite/alu_f32.generated.rb +1 -0
- data/lib/wardite/alu_f64.generated.rb +1 -0
- data/lib/wardite/alu_i32.generated.rb +14 -9
- data/lib/wardite/alu_i64.generated.rb +18 -20
- data/lib/wardite/cli/cli.rb +61 -28
- data/lib/wardite/const.rb +1 -0
- data/lib/wardite/efflorescence/float_arithmetic.rb +216 -0
- data/lib/wardite/efflorescence/i64_arithmetic.rb +257 -0
- data/lib/wardite/efflorescence/inspection.rb +165 -0
- data/lib/wardite/efflorescence/ir.rb +1151 -0
- data/lib/wardite/efflorescence/optimizer.rb +580 -0
- data/lib/wardite/efflorescence/register_validation.rb +290 -0
- data/lib/wardite/efflorescence/store_access.rb +271 -0
- data/lib/wardite/efflorescence/translator.rb +859 -0
- data/lib/wardite/efflorescence/vm.rb +1006 -0
- data/lib/wardite/efflorescence/wasi.rb +108 -0
- data/lib/wardite/efflorescence.rb +11 -0
- data/lib/wardite/errors.rb +20 -0
- data/lib/wardite/float_bits.rb +46 -0
- data/lib/wardite/instruction.rb +35 -4
- data/lib/wardite/leb128.rb +33 -12
- data/lib/wardite/load.rb +203 -138
- data/lib/wardite/value.rb +169 -175
- data/lib/wardite/version.rb +1 -1
- data/lib/wardite/wasi/consts.rb +1 -0
- data/lib/wardite/wasm_module.rb +6 -3
- data/lib/wardite.rb +184 -70
- data/rbs_collection.lock.yaml +36 -96
- data/scripts/gen_alu.rb +66 -10
- data/sig/generated/wardite/cli/cli.rbs +8 -6
- data/sig/generated/wardite/const.rbs +2 -0
- data/sig/generated/wardite/efflorescence/float_arithmetic.rbs +65 -0
- data/sig/generated/wardite/efflorescence/i64_arithmetic.rbs +99 -0
- data/sig/generated/wardite/efflorescence/inspection.rbs +64 -0
- data/sig/generated/wardite/efflorescence/ir.rbs +881 -0
- data/sig/generated/wardite/efflorescence/optimizer.rbs +189 -0
- data/sig/generated/wardite/efflorescence/register_validation.rbs +76 -0
- data/sig/generated/wardite/efflorescence/store_access.rbs +134 -0
- data/sig/generated/wardite/efflorescence/translator.rbs +214 -0
- data/sig/generated/wardite/efflorescence/vm.rbs +179 -0
- data/sig/generated/wardite/efflorescence/wasi.rbs +47 -0
- data/sig/generated/wardite/errors.rbs +12 -0
- data/sig/generated/wardite/float_bits.rbs +30 -0
- data/sig/generated/wardite/instruction.rbs +22 -1
- data/sig/generated/wardite/leb128.rbs +3 -1
- data/sig/generated/wardite/load.rbs +29 -4
- data/sig/generated/wardite/value.rbs +70 -11
- data/sig/generated/wardite/wasi/consts.rbs +2 -0
- data/sig/generated/wardite.rbs +49 -12
- data/sig/vernier.rbs +2 -2
- data/spinel/README.md +30 -0
- data/spinel/bin/wardite.rb +6 -0
- data/spinel/spin.toml +7 -0
- metadata +126 -3
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"""Render supplied Hyperfine summary statistics as a candlestick-style chart.
|
|
2
|
+
|
|
3
|
+
The body is mean +/- sample standard deviation, not OHLC or quartiles.
|
|
4
|
+
The observed min/max are shown independently and are never clipped to the body.
|
|
5
|
+
"""
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
import csv
|
|
8
|
+
import json
|
|
9
|
+
import math
|
|
10
|
+
import os
|
|
11
|
+
|
|
12
|
+
os.environ.setdefault('MPLCONFIGDIR', '/private/tmp/wardite-matplotlib-config')
|
|
13
|
+
import matplotlib
|
|
14
|
+
matplotlib.use('Agg')
|
|
15
|
+
import matplotlib.pyplot as plt
|
|
16
|
+
from matplotlib import font_manager
|
|
17
|
+
from matplotlib.lines import Line2D
|
|
18
|
+
from matplotlib.patches import Patch, Rectangle
|
|
19
|
+
|
|
20
|
+
OUT = Path(__file__).resolve().parent
|
|
21
|
+
FONT = '/System/Library/Fonts/ヒラギノ角ゴシック W3.ttc'
|
|
22
|
+
font_manager.fontManager.addfont(FONT)
|
|
23
|
+
FONT_NAME = font_manager.FontProperties(fname=FONT).get_name()
|
|
24
|
+
plt.rcParams.update({
|
|
25
|
+
'font.family': FONT_NAME,
|
|
26
|
+
'axes.unicode_minus': False,
|
|
27
|
+
'font.size': 11,
|
|
28
|
+
'svg.fonttype': 'path',
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
ENGINES = [
|
|
32
|
+
('Efflorescence / Spinel', 'Efflorescence\nSpinel(パッチあり)', '#2563EB'),
|
|
33
|
+
('iwasm (WAMR interpreter)', 'iwasm\nWAMR interpreter', '#0D9488'),
|
|
34
|
+
('Wasmtime (Pulley)', 'Wasmtime\nPulley', '#D68A0B'),
|
|
35
|
+
('Wasmtime', 'Wasmtime', '#7C3AED'),
|
|
36
|
+
]
|
|
37
|
+
# mean, standard deviation, minimum, maximum, runs; all times in milliseconds.
|
|
38
|
+
VALUES = {
|
|
39
|
+
'inline_mix': [
|
|
40
|
+
(6.6, 0.2, 6.3, 6.9, 5),
|
|
41
|
+
(4.8, 0.2, 4.6, 5.0, 5),
|
|
42
|
+
(8.4, 0.2, 8.1, 8.6, 5),
|
|
43
|
+
(6.8, 0.5, 6.1, 7.4, 5),
|
|
44
|
+
],
|
|
45
|
+
'call_mix': [
|
|
46
|
+
(6.6, 0.3, 6.2, 7.0, 5),
|
|
47
|
+
(5.7, 0.3, 5.4, 6.0, 5),
|
|
48
|
+
(10.1, 0.2, 9.9, 10.3, 5),
|
|
49
|
+
(6.9, 0.6, 6.2, 7.5, 5),
|
|
50
|
+
],
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
rows = []
|
|
54
|
+
for export, values in VALUES.items():
|
|
55
|
+
assert len(values) == len(ENGINES)
|
|
56
|
+
for (engine, _, _), (mean, sd, minimum, maximum, runs) in zip(ENGINES, values):
|
|
57
|
+
assert minimum <= mean <= maximum
|
|
58
|
+
assert sd >= 0 and runs == 5
|
|
59
|
+
rows.append(dict(export=export, engine=engine, mean_ms=mean, sd_ms=sd,
|
|
60
|
+
min_ms=minimum, max_ms=maximum, runs=runs))
|
|
61
|
+
(OUT / 'spinel_new_vm_summary.json').write_text(json.dumps({
|
|
62
|
+
'source': 'User-provided final Hyperfine summary',
|
|
63
|
+
'summary_precision_ms': 0.1,
|
|
64
|
+
'configuration': 'Efflorescence while dispatch; Spinel fetch-root-elision patch (6f1a2c259)',
|
|
65
|
+
'timing': 'Whole CLI process wall time; Wasmtime compilation included and compiled-module cache disabled',
|
|
66
|
+
'body': 'mean +/- standard deviation',
|
|
67
|
+
'whiskers': 'observed minimum and maximum',
|
|
68
|
+
'data': rows,
|
|
69
|
+
}, ensure_ascii=False, indent=2) + '\n')
|
|
70
|
+
with (OUT / 'spinel_new_vm_summary.csv').open('w', newline='') as handle:
|
|
71
|
+
writer = csv.DictWriter(handle, fieldnames=list(rows[0]), lineterminator="\n")
|
|
72
|
+
writer.writeheader()
|
|
73
|
+
writer.writerows(rows)
|
|
74
|
+
|
|
75
|
+
fig, axes = plt.subplots(1, 2, figsize=(15.6, 7.7), sharey=True)
|
|
76
|
+
fig.patch.set_facecolor('#F5F7FB')
|
|
77
|
+
fig.subplots_adjust(left=0.075, right=0.975, bottom=0.29, top=0.79, wspace=0.12)
|
|
78
|
+
fig.text(0.075, 0.944, 'Wasmランタイムの起動込み実行時間', fontsize=23, weight='bold', color='#17273D')
|
|
79
|
+
fig.text(0.075, 0.894, '最終計測 · 各5回 · 小さいほど高速', fontsize=11.5, color='#5C6B80')
|
|
80
|
+
|
|
81
|
+
# Leave room for every observed maximum, statistical body and numeric label.
|
|
82
|
+
peak = max(max(mean + sd, maximum)
|
|
83
|
+
for values in VALUES.values() for mean, sd, _, maximum, _ in values)
|
|
84
|
+
y_limit = math.ceil((peak + 1.0) / 2) * 2
|
|
85
|
+
|
|
86
|
+
for ax, (export, values) in zip(axes, VALUES.items()):
|
|
87
|
+
ax.set_facecolor('white')
|
|
88
|
+
ax.set_title(export, loc='left', pad=18, fontsize=17, weight='bold', color='#17273D')
|
|
89
|
+
ax.set_ylim(0, y_limit)
|
|
90
|
+
ax.set_xlim(-0.55, 3.55)
|
|
91
|
+
ax.set_yticks(range(0, y_limit + 1, 2))
|
|
92
|
+
ax.set_axisbelow(True)
|
|
93
|
+
ax.grid(axis='y', color='#DFE5EE', linewidth=0.8)
|
|
94
|
+
for spine in ('top', 'right'):
|
|
95
|
+
ax.spines[spine].set_visible(False)
|
|
96
|
+
for spine in ('left', 'bottom'):
|
|
97
|
+
ax.spines[spine].set_color('#C6D0DD')
|
|
98
|
+
ax.tick_params(axis='both', length=0, pad=10, labelcolor='#43536A')
|
|
99
|
+
ax.set_xticks(range(4), [label for _, label, _ in ENGINES], fontsize=11)
|
|
100
|
+
for x, ((_, _, color), (mean, sd, minimum, maximum, _)) in enumerate(zip(ENGINES, values)):
|
|
101
|
+
# Draw the statistical interval first, then the observed range over it.
|
|
102
|
+
ax.add_patch(Rectangle((x - 0.18, mean - sd), 0.36, 2 * sd,
|
|
103
|
+
facecolor=color, edgecolor=color, alpha=0.24,
|
|
104
|
+
linewidth=1.6, zorder=3))
|
|
105
|
+
ax.vlines(x, minimum, maximum, color='#283950', linewidth=1.7, zorder=4)
|
|
106
|
+
ax.hlines([minimum, maximum], x - 0.10, x + 0.10,
|
|
107
|
+
color='#283950', linewidth=1.7, zorder=5)
|
|
108
|
+
ax.hlines(mean, x - 0.24, x + 0.24, color=color, linewidth=2.8, zorder=6)
|
|
109
|
+
label_y = max(mean + sd, maximum) + 0.35
|
|
110
|
+
ax.text(x, label_y, f'{mean:.1f} ± {sd:.1f} ms', ha='center', va='bottom',
|
|
111
|
+
fontsize=12.0, weight='bold', color=color)
|
|
112
|
+
for label, (_, _, color) in zip(ax.get_xticklabels(), ENGINES):
|
|
113
|
+
label.set_color(color)
|
|
114
|
+
axes[0].set_ylabel('時間 (ms)', fontsize=12, labelpad=14, color='#43536A')
|
|
115
|
+
|
|
116
|
+
legend = [
|
|
117
|
+
Patch(facecolor='#C9D7EC', edgecolor='#7187A6', label='胴体:平均 ± σ'),
|
|
118
|
+
Line2D([0], [0], color='#2563EB', linewidth=2.8, label='中央線:平均'),
|
|
119
|
+
Line2D([0], [0], color='#283950', marker='|', markersize=10, linewidth=1.5,
|
|
120
|
+
label='ヒゲ:最小〜最大'),
|
|
121
|
+
]
|
|
122
|
+
fig.legend(handles=legend, loc='upper right', bbox_to_anchor=(0.983, 0.925),
|
|
123
|
+
ncol=3, frameon=False, fontsize=10.5, handlelength=1.8, columnspacing=1.8)
|
|
124
|
+
fig.text(0.075, 0.16, 'Efflorescenceはwhile版MIR VM。Spinelはfetchルート省略パッチ(6f1a2c259)を併用。',
|
|
125
|
+
fontsize=10.5, color='#43536A')
|
|
126
|
+
fig.text(0.075, 0.115, 'CLI全体の計測。起動・ロードを含み、WasmtimeはWasmコンパイルも含む(キャッシュ無効)。',
|
|
127
|
+
fontsize=10, color='#6E7C90')
|
|
128
|
+
fig.text(0.075, 0.07, '両パネルは同じ縦軸。Wasmtimeとの差は小さく、実測範囲・平均±σの区間が重なっています。',
|
|
129
|
+
fontsize=10, color='#6E7C90')
|
|
130
|
+
|
|
131
|
+
for suffix in ('png', 'svg'):
|
|
132
|
+
fig.savefig(OUT / f'spinel_new_vm_candlestick.{suffix}', dpi=180,
|
|
133
|
+
facecolor=fig.get_facecolor(), metadata={'Creator': 'Wardite benchmark plot'})
|
|
134
|
+
svg = OUT / 'spinel_new_vm_candlestick.svg'
|
|
135
|
+
svg.write_text('\n'.join(line.rstrip() for line in svg.read_text().splitlines()) + '\n')
|
|
136
|
+
plt.close(fig)
|
|
137
|
+
print(OUT / 'spinel_new_vm_candlestick.png')
|
|
Binary file
|