Skip to content

Commit 34d97b1

Browse files
Add native acceleration for G-code parsing and milling execution
- Introduced Cython-based native parser and executor for improved performance in G-code processing. - Added configuration options for maximum generated motions in the settings dialog. - Updated the main execution window to include execution limits based on user settings. - Enhanced build scripts to support native module compilation. - Added tests to validate the functionality of the new native acceleration features. - Updated translations to include new UI elements related to maximum generated motions.
1 parent 76f317f commit 34d97b1

45 files changed

Lines changed: 4226 additions & 2095 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.gitignore‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ pip-wheel-metadata/
2020
*.manifest
2121
*.spec
2222

23+
# Cython generated artifacts (the .pyx sources are authoritative)
24+
app/gcode/kernel/frontend/_native_parser.c
25+
app/gcode/kernel/frontend/_native_parser*.pyd
26+
app/gcode/kernel/frontend/_native_parser*.so
27+
app/gcode/kernel/milling/_native_executor.c
28+
app/gcode/kernel/milling/_native_executor*.pyd
29+
app/gcode/kernel/milling/_native_executor*.so
30+
app/tools/_native_discovery.c
31+
app/tools/_native_discovery*.pyd
32+
app/tools/_native_discovery*.so
33+
2334
# Logs / reports
2435
*.log
2536
coverage.*
@@ -54,4 +65,4 @@ builds/
5465
.ruff_cache/
5566

5667
tmp/
57-
.omx/
68+
.omx/

‎CHANGELOG.md‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
# Changelog
22

3+
## 1.5.9 - 2026-09-20
4+
5+
- Localized every user-visible Toolpath Statistics report label for the Russian UI while preserving the existing English report text, values, units and statistics calculations.
6+
- Fixed PyInstaller packages failing at startup with `ModuleNotFoundError: app.gcode.export` by explicitly collecting the canonical exporter package referenced through the legacy lazy module aliases.
7+
- Added a persistent **Maximum generated motions** setting to `Options -> General`; it controls the kernel-wide generated-motion resource limit for both turning and milling executions and defaults to 200,000.
8+
- Added a separate Cython tool-discovery scanner that performs line/comment scanning, literal T recognition, G20/G21 unit tracking and operation inference in one native pass while preserving the existing Python `refresh_setup()` orchestration and scanner fallback.
9+
- Made debounced editor Auto Update non-modal so typing remains usable during recalculation; edits made during an active refresh cancel the stale run, queue another refresh and prevent stale results from replacing the current plot.
10+
- Added a Cython native parser that accepts the complete G-code source in one call, scans lines, comments, words, numeric values, labels and flow constructs in compiled code, and produces the existing `Program`, `Block`, token and AST object model without changing CNC semantics.
11+
- Added a Cython native milling executor for contiguous ordinary literal/modal blocks, eliminating per-line Python/native transitions while retaining the existing Python interpreter for Macro B, cycles, transforms and other complex behavior.
12+
- Kept authoritative Python fallbacks for unsupported or complex input and for source environments where native extensions have not been built; cancellation checkpoints remain active in both execution paths.
13+
- Fused ordinary parsing and AST construction, added faster literal-word evaluation and reduced repeated scans and temporary allocations during program indexing and tool discovery.
14+
- Reduced interpreter and post-processing overhead by avoiding unchanged dataclass replacements, empty signal/flow allocations and unnecessary coordinate-transform work, and by rebuilding emitted-motion counts only when they change.
15+
- Added scoped cyclic-GC deferral around construction and execution of the large, predominantly acyclic CNC object graph, restoring the caller's previous GC state on every exit path.
16+
- Added slotted high-volume frontend and execution dataclasses to reduce allocation size and attribute-access overhead without changing equality, immutability or public result types.
17+
- Changed the GUI execution path to omit the optional full instruction list when it is not consumed, while preserving instructions for API and CLI callers that request them.
18+
- Consolidated tool discovery so source parsing results are reused instead of performing redundant full-file passes.
19+
- Improved the 77 MB / 2,577,485-line FANUC milling reference workload from approximately 110.7 seconds to 25.3 seconds at the 200,000-motion limit (about 4.37x overall on the reference machine).
20+
- Verified native/Python parity across every block and AST node in the reference file, label indexes and complete limited execution results, including motions, steps, diagnostics, events, signals and final state.
21+
- Added native-acceleration regression tests comparing the compiled parser and milling loop with their Python fallbacks; unbuilt source checkouts skip only the native-specific tests.
22+
- Added Cython to the PEP 517 build requirements and configured setuptools to compile `_native_parser.pyx` and `_native_executor.pyx` into platform-specific `.pyd`/`.so` modules.
23+
- Kept generated Cython `.c`, `.pyd` and `.so` artifacts out of version control; clean wheel builds start from the tracked `.pyx` sources and include both compiled extensions.
24+
- Added matching `build-native.ps1` and `build-native.sh` helpers that maintain a persistent `.venv-build`, rebuild native extensions when build inputs change, support an explicit refresh and verify both extension imports.
25+
- Made the PowerShell and shell PyInstaller workflows reuse the isolated `.venv-build`, validate native acceleration before packaging and skip dependency synchronization when the locked build inputs are unchanged.
26+
- Documented compiler prerequisites, native build verification, source-tree startup and the behavior of prebuilt Windows releases.
27+
328
## 1.5.8 - 2026-09-20
429

530
- Added persistent **Autodetect Arc Type** under `Settings -> Options -> CNC / Execution` for milling. Execution inspects the already parsed unresolved motion stream, skips R-only arcs while detecting, compares relative-IJK and absolute-center radius consistency against the configured arc tolerance, fixes one effective IJK mode for the whole run and falls back to the manually selected Arc Type when the program remains ambiguous. Turning and Arc Output export semantics are unchanged.

‎FAQ.md‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Use Shift+Click near the trajectory. The application selects the owning source b
6868

6969
### Why does Auto Update sometimes ask me to press Refresh?
7070

71-
Auto Update has a configurable sampled-segment limit. Large programs are left unchanged until an explicit Refresh so that typing remains responsive. Manual refresh displays staged progress for a large trace.
71+
Auto Update has a configurable sampled-segment limit. Normal edit-triggered Auto Update is non-modal. If the source changes while a refresh is running, the stale run is cancelled, another refresh is queued and the stale result is not published. Large programs are left unchanged until an explicit Refresh so that typing remains responsive. Manual refresh displays staged progress for a large trace.
7272

7373
### What does Cancel stop during Refresh?
7474

@@ -342,6 +342,7 @@ On Windows:
342342
- UTF-8 or Windows-1251 document encoding.
343343
- Default Text/ISO editor mode and default units.
344344
- Application logging.
345+
- Auto Update, its sampled-segment limit and the kernel-wide Maximum generated motions limit.
345346
- G41/G42 correction, arc tolerance and milling Arc Type autodetection.
346347
- Persistent optional-block control through `Ignore Block Skip`.
347348
- Editor font and visual settings.
@@ -453,6 +454,16 @@ $version = "X.Y.Z"
453454
.\scripts\ps1\release.ps1 -Version $version -Message "Release $version"
454455
```
455456

457+
Native/release tooling uses a separate persistent `.venv-build`; it does not
458+
replace or prune the developer `.venv`. `build-native.ps1`/`build-native.sh`
459+
synchronize locked build dependencies when `pyproject.toml` or `uv.lock`
460+
changes, rebuild the project when the tracked `.pyx` sources change, verify both
461+
native extension imports and otherwise reuse the existing build environment.
462+
Use `-Refresh`/`--refresh` for an explicit native-build refresh, or
463+
`-RefreshBuildEnvironment`/`--refresh-build-environment` with the full build.
464+
PyInstaller is invoked from that build environment rather than through the
465+
developer environment.
466+
456467
## License
457468

458469
MIT License — see [LICENSE.md](LICENSE.md).

0 commit comments

Comments
 (0)