Overview
| Comment: | The annotated step is now approximately 3.6 times faster in the area calculation: 50.9 ms in v15, compared to 14.1 ms now—versus about 4 ms in "bare" Tcl. It has thus gone from being more than 12 times slower than bare Tcl to about 3.5 times slower. I have left this item open in the planning phase, noting the work that remains to be done. What the profiling revealed I measured each operation separately (using `bench_parties.tcl`) and then profiled the code with `callgrind`: Potential issue in planning Cost Redeclaration (`P is polygon = $p`) 4 µs per call: negligible `lindex` on 10,000 typed points 3.1 ms (0.6 ms in bare Tcl) Reading via path `$a(x)` approx. 1 µs per read—by far the largest contributor to the cost In a read operation `$a(x)`, the time was primarily spent on: Compiling the path `x`, which was being re-done for every read (21% of the time); Creating the type reference for the result (13%), involving an `snprintf` call and a hash operation for every value created; The remainder was spent on unnecessary copying and validation checks. The Six Optimizations Single-name path ($a(x), $L(3)): read in a single step, without compiling the index. Type reference cached in the type descriptor: no more `snprintf` or hashing. Elements wrapped by the index share this reference as well. Expression operands: a typed `int`, `double`, or `string` without an annotation provides its content directly, without resolution. Assignment (`a = lindex ...`): no extra work required for a value whose type is already resolved and which lacks an annotation. Deallocation: the table of auto-element slots is consulted only if a slot has actually been created. Reading a sub-part: the content is shared rather than copied. Since a value is immutable, any operation that modifies it is already working on a copy. Results 10,000 points (µs) v15 v15g Annotated area 50,867 14,110 $a(x) + $a(y) 23,241 6,117 `foreach` + paths 22,395 5,611 For `geometrie/bench.tcl`, step 2: Calculation v15 v15g Area 39.8 ms 15.7 ms Bounding box 36.1 ms 11.8 ms `dedans_tous` 841 ms 314 ms Bézier 149 ms 99 ms Perimeter 254 ms 202 ms The machine was somewhat under load during these measurements, and even the execution times for "bare" Tcl vary from one run to the next; please consider the ratios rather than the exact values. The perimeter calculation shows little improvement. Execution time is spent on calls to—and declarations of—typed procedures (such as `geo::distance` and `geo::vec`) for every edge. This is the next area to address, prior to implementing a compact representation. Verified against v15 Project: Tests and examples—including `cstruct`, `arduino`, and `geometrie/verifier.tcl`—yield the same results as v15. Tcl: 23 test files, 6,615 tests, with identical failures across the board. Memory: Valgrind reports no errors for `geometrie.tcl`, `t22`, `t30`, `t52`, `t55`, `t57`, and `t58`. This addresses the risks associated with shared content. Update Three type-related source files (`tclAnnotObj.c`, `tclTypes.h`, `tclTypePath.c`) have been updated—without requiring a kernel patch—followed by running `maj.sh`. Since `tclTypes.h` alters the type structure, `cstruct.dll` and `geo.dll` must also be recompiled. Details can be found in the `v15g` section of `noyau/LISEZMOI.md`, and the benchmarking suite is located at `exemples/geometrie/bench_parties.tcl`. |
|---|---|
| Timelines: | family | ancestors | descendants | both | tip-764_tcl90 |
| Files: | files | file ages | folders |
| SHA3-256: |
ac9be301b1d2dbf6981978009cd79516 |
| User & Date: | Florentis on 2026-10-23 09:10:57.702 |
| Other Links: | branch diff | manifest | tags |
Context
|
2026-10-23
| ||
| 09:26 | The bug has been fixed (v15h). I went a bit further than what was noted in the schedule: instead of ... check-in: a04ace5134 user: Florentis tags: tip-764_tcl90 | |
| 09:10 | The annotated step is now approximately 3.6 times faster in the area calculation: 50.9 ms in v15, co... check-in: ac9be301b1 user: Florentis tags: tip-764_tcl90 | |
| 08:39 | From now on, a or type specifier is compatible with a structural collection of the same kind, prov... check-in: cdeed58063 user: Florentis tags: tip-764_tcl90 | |
Changes
Modified generic/tclAnnotObj.c
from [ab0ee9ef1e]
to [93d252c278].
[diff]
Modified generic/tclTypePath.c
from [6ddd6474fd]
to [1e64927462].
[diff]
Modified generic/tclTypes.h
from [d78fcda13f]
to [74c4e4807e].
[diff]
Added typeparse/exemples/geometrie/bench_parties.tcl version [6277d074bb].
Modified typeparse/noyau/LISEZMOI.md
from [14a246b581]
to [e485a890d2].
[diff]
Modified typeparse/tclAnnotObj.c
from [ab0ee9ef1e]
to [93d252c278].
[diff]
Modified typeparse/tclTypePath.c
from [6ddd6474fd]
to [1e64927462].
[diff]
Modified typeparse/tclTypes.h
from [d78fcda13f]
to [74c4e4807e].
[diff]