Skip to content

gogen: move a table instead of cloning it when CLEAR/FREE of the source follows (abapiti 044) - #701

Merged
oisee merged 1 commit into
mainfrom
perf/gogen-move-then-clear
Oct 10, 2026
Merged

oisee merged 1 commit into
mainfrom
perf/gogen-move-then-clear

Conversation

@oisee

@oisee oisee commented Oct 10, 2026

Copy link
Copy Markdown
Owner

gogen: move a table instead of cloning it when CLEAR/FREE of the source follows (abapiti 044)

abapiti inbox 044: Array.splice1 uses result->items = items. CLEAR items.
Every statements.splice(1) therefore cloned the remaining table. The structures
stage took kernel 7.6 s versus osgo 18.0 s: these are motivation numbers,
not a measured post-change result for the full abaplint workload.

Transfer plain, identical table storage before an immediate CLEAR/FREE,
including deep rows, independent structure components, and me.items into
result.items immediately after result = NEW #( ). Preserve both table-version
bumps and the complete following statement. Refuse keyed or differing types,
active source loops, bindings with overlapping or unknown paths, reference
parameters, and potentially aliased object storage. For attribute sources,
also refuse stable rows or row types bound anywhere in the program, including
callers; frontend typeOf makes fresh table types per access, so stable alone
cannot establish ownership across methods. Unknown program bindings also
refuse attribute moves. Keep the existing copy semantics in all refused cases.

Synthetic generated-Go benchmark, 8,192-row transfer plus DELETE, three runs:
median 3.50 us -> 0.355 us (~9.9x); 32,792 -> 24 B/op; 2 -> 1 allocs/op.
This measures the synthetic fixture, not the complete abaplint workload.
Skip the optional DELETE reslice: capacity, escaped aliases and vacated-tail
clearing need separate analysis. DELETE behavior remains unchanged.

Critic round 2 fixes findings 1-3 and 6: conservatively block unknown binding
paths, account for caller bindings across methods, retain existing regressions
and add CHANGING-alias/caller-binding regressions, and record the motivation.
Extract move analysis into emit-table-move.mjs to stay within the emitter's
existing size budget. Validation: semantics all ok, 0 FAIL; 18 emitter tests;
size budget --changed origin/main exits 0 (only inherited main breaches).

Critic round 2: a callee given a local table by reference could bind into
its rows and hand the binding back; the program-wide guard (stable rows, a
row type bound anywhere, an unknown binding) now applies to every source,
not only attributes, with a regression that fails without it.

abapiti measured the first round (47fad3fe8, same lib, zabapgit check kit, two interleaved runs each): clone_ lines in SPLICE1 1 -> 0; zabaplint clean 62/64 s -> 53 s, seeded 63/62 s -> 50 s; all outputs equal to Node. The later rounds only add refusals; its lib has no binding on the items row types, so splice1 still moves (abapiti re-measuring).

codex worker; codex critic two rounds (FIX, FIX), all findings fixed. semantics 392 ok, 0 FAIL; emit-go.test 19 pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VUy1x5QYimNEytFZpg7t7S

@oisee
oisee force-pushed the perf/gogen-move-then-clear branch from 92aa11a to 661389b Compare October 10, 2026 04:41
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Preview: open the launchpad - the OData gateway, the demo and Zork run in your browser, no server.

Screenshots - built from 1b4131f

@oisee
oisee force-pushed the perf/gogen-move-then-clear branch 2 times, most recently from 8716d07 to 78c03d0 Compare October 10, 2026 05:07
@oisee
oisee force-pushed the perf/gogen-move-then-clear branch from 78c03d0 to 98f6d7d Compare October 10, 2026 05:26
…ce follows (abapiti 044)

abapiti inbox 044: Array.splice1 uses result->items = items. CLEAR items.
Every statements.splice(1) therefore cloned the remaining table. The structures
stage took kernel 7.6 s versus osgo 18.0 s: these are motivation numbers,
not a measured post-change result for the full abaplint workload.

Transfer plain, identical table storage before an immediate CLEAR/FREE,
including deep rows, independent structure components, and me.items into
result.items immediately after result = NEW #( ). Preserve both table-version
bumps and the complete following statement. Refuse keyed or differing types,
active source loops, bindings with overlapping or unknown paths, reference
parameters, and potentially aliased object storage. For attribute sources,
also refuse stable rows or row types bound anywhere in the program, including
callers; frontend typeOf makes fresh table types per access, so stable alone
cannot establish ownership across methods. Unknown program bindings also
refuse attribute moves. Keep the existing copy semantics in all refused cases.

Synthetic generated-Go benchmark, 8,192-row transfer plus DELETE, three runs:
median 3.50 us -> 0.355 us (~9.9x); 32,792 -> 24 B/op; 2 -> 1 allocs/op.
This measures the synthetic fixture, not the complete abaplint workload.
Skip the optional DELETE reslice: capacity, escaped aliases and vacated-tail
clearing need separate analysis. DELETE behavior remains unchanged.

Critic round 2 fixes findings 1-3 and 6: conservatively block unknown binding
paths, account for caller bindings across methods, retain existing regressions
and add CHANGING-alias/caller-binding regressions, and record the motivation.
Extract move analysis into emit-table-move.mjs to stay within the emitter's
existing size budget. Validation: semantics all ok, 0 FAIL; 18 emitter tests;
size budget --changed origin/main exits 0 (only inherited main breaches).

Critic round 2: a callee given a local table by reference could bind into
its rows and hand the binding back; the program-wide guard (stable rows, a
row type bound anywhere, an unknown binding) now applies to every source,
not only attributes, with a regression that fails without it.

Measured by abapiti on 409e82a65: the move no longer fired in its program
(no gain). The program-wide scan visited every subexpression of a binding
(a key value, an index, a reference parameter's base) and so declared an
"unknown binding" for any READ ... ASSIGNING. A binding is now judged by
the type it points into (a table's row type, or the bound value's type);
only a generic one is unknown, and a dereference or ASSIGN COMPONENT,
which only passes on an existing pointer, counts in the moving method
alone.

Critic round 3: a binding into a table nested in a row of the moved
table (LOOP AT obj->items[ 1 ]-items ASSIGNING) recorded only the inner
row type. The scan now records every type along the bound operand's
storage chain (base, table, wrapped value); ZCL_GOGEN_T_MOVNEST in
testdata-move pins it and fails without the change.

Round 4: add GOGEN_MOVE_TRACE=1 with method/storage paths and explicit
refusal rules, including generic-binding provenance. Replace the global
unknown-binding veto with escaped row types: generic by-reference calls
(including output wrappers), bounded component access, and unbounded dynamic
names exposing object attributes but not other methods' locals. Retain typed
storage ancestry, contained tables, typed-helper actual ancestry, and the
per-method moveBound guard; scalar structure fields do not bind independent
tables of that scalar type. Add generic IMPORTING/CHANGING, VALUE isolation,
dynamic-name, inline-field-symbol, and nested-storage regressions.
Real read-only abapiti input, through the osabap pipeline stopped after Go
emission under /mnt/ram/stoker: 2126 classes, 199 existing statement stubs;
9 candidate traces, 6 moved, 2 boundRows, 1 unknownBinding. SPLICE1 of
Z_RUNTIME_ARRA_3615468A4BF830 traces moved and emits result.items = me.items;
its clone of the separate head table remains. No full binary build or new
runtime performance claim. Validation: 392 semantics checks ok, 0 FAIL;
27 emitter tests pass; size budget --changed origin/main exits 0.

Round 5: close typed-to-generic forwarding by treating every by-reference
actual's table storage ancestry as an escape, regardless of the formal type.
Keep typed boundRows, dynamic-name escapes, escaped rows plus any generic
binding, per-method moveBound, and all existing guards. Independent scalar
actuals do not escape same-type table rows. Include escape provenance in the
trace, caching visited storage without changing the escape set. Add a typed inner-table helper forwarding to ANY TABLE, exporting a
row reference and writing through it after the outer move/CLEAR: the clone
is retained and both Go and JS preserve destination value 1. The original
HEAD emits a = b for this fixture; Round 5 emits a = clone_0(b).
Validation: 394 semantics checks ok, 0 FAIL; 29 emitter tests pass;
size budget --changed origin/main exits 0 (only inherited main breaches).
Real-input re-emission is blocked: /mnt/ram/abapiti/ab/out/native disappeared
during the run, and the retry fails with ENOENT for the report. No Round 5
real-input SPLICE1 verdict or candidate counts are claimed; restore the exact
Round 4 input and rerun emit-only with GOGEN_MOVE_TRACE=1 before reporting them.

Round 6: key bindings and escapes by storage identity: attr:<NAME> across
classes and local:<class=>method>:<NAME>, following only operand storage
ancestry. Unknown parameter/field-symbol/dereference/generic roots add no
global taint by themselves. Every by-reference actual escapes its chain
regardless of formal type; dynamic component access escapes only its
structure chain, literal attribute names only that name, and non-literal
dynamic attribute names all attributes. Preserve per-method moveBound,
loop, alias, keyed/type/stable, and fresh-object guards. Refusal traces name
the storage key and originating class=>method/statement kind. Correct two
old row-type-based test setups to bind the actual source storage, retaining
their caller-binding and whole-structure safety checks. Add unrelated generic
loop_data/string-attribute and real-frontend dynamic object-name regressions
(non-literal, matching literal, and unrelated literal).
Real regenerated read-only abapiti input, emit-only under /mnt/ram/stoker:
2126 classes, 199 existing statement stubs; 9 candidates, 9 moved, 0 refused.
Z_RUNTIME_ARRA_3615468A4BF830=>SPLICE1 traces moved and its generated Go
contains result.items = me.items followed by the source CLEAR and both
version bumps. No full real-input binary build or runtime speed claim.
Validation: semantics 394 ok, 0 FAIL; emit-go.test 31/31 pass;
size budget --changed origin/main exits 0 (only inherited main breaches).

Round 7: the scan also covers instance constructors (kept apart from
cls.methods) and function module bodies (critic round 5: a constructor
binding GET REFERENCE OF items[ 1 ] escaped it); regression fails
without it. Real input again: 9 candidates, 9 moved, SPLICE1 moved.
semantics 394 ok, 0 FAIL; emit-go.test 32/32.

Measured by abapiti on 78c03d0 (the same SPLICE1 move): zabaplint on
zabapgit, linux-amd64, two interleaved runs each: clean 62/63 s -> 50/49 s,
seeded 61/61 s -> 50/48 s (about -20 %), outputs equal to Node.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01VUy1x5QYimNEytFZpg7t7S
@oisee
oisee force-pushed the perf/gogen-move-then-clear branch from 98f6d7d to 0ecd663 Compare October 10, 2026 05:36
@oisee

oisee commented Oct 10, 2026

Copy link
Copy Markdown
Owner Author

Final: 0ecd663. Escapes keyed by storage identity; constructors and function modules scanned. Real abapiti input: 9 candidates, 9 moved (SPLICE1 moved). abapiti on the same move: zabaplint 61-63 s -> 48-50 s (~-20 %), outputs equal to Node. semantics 394 ok / 0 FAIL, emit-go.test 32/32. codex critic: six rounds, last MERGE.

@github-actions

Copy link
Copy Markdown
Contributor

PR tests: 🟢 pass

Commit: 0ecd6632 · Full test log

Job Result Time
build 🟢 pass 302 s
packaging 🟢 pass 236 s
adt-lifecycle 🟢 pass 1768 s
osgo-host 🟢 pass 252 s
e2e 🟢 pass 152 s
suites (2) 🟢 pass 958 s
kernel-conformance 🟢 pass 239 s
suites (4) 🟢 pass 1356 s
suites (3) 🟢 pass 1028 s
suites (1) 🟢 pass 1169 s
suites (5) 🟢 pass 1062 s
suites (6) 🟢 pass 560 s

ADT lifecycle: PASS

Commit: 1b4131f · SDK 8.4.3 · VSP baac6f4c97fb3ea1dee9b7772e24d52855af2985

124 PASS, 4 N/A, 3 MISSING

Functional operations, active readback, cleanup and warm-swap checks determine the required gate.

Timing advisory: ⚠️ WARN

Client wall time in ms. VSP update includes Check and Activate. Cold REPORT/DDLS are measured too. Parallel CI job; operations within each server are sequential.

Reference: median of ABAP-FS/CLAS/edit, ABAP-FS/CLAS/readback-active, ABAP-FS/INTF/edit, ABAP-FS/INTF/readback-active; current 49 ms.

History: 5/5 compatible green main runs (newest first; fewer when unavailable). Each run is normalized by its own reference before taking the main median.

Warn when at least 2 operations exceed 1.3x, or any operation reaches 2x. Timing never fails the CI gate.

  • Advisory timing slowdown: 3 operations above 1.3x; ABAP-FS/CLAS/edit: 129 ms, main 70 ms, normalized 1.692x; ABAP-FS/PROG/readback-active: 93 ms, main 63 ms, normalized 1.336x; ABAP-FS/DDLS/check: 8206 ms, main 4797 ms, normalized 1.431x
Client/type/operation Median ms Samples ms main ms (raw median) Current/reference main normalized median Ratio Main runs Timing
ABAP-FS/CLAS/edit 129 153, 129, 77 70 2.633 1.556 1.692x 5 above margin
ABAP-FS/CLAS/check 2589 2178, 2589, 2663 2016 52.837 48.073 1.099x 5 quiet
ABAP-FS/CLAS/activate-edit 3939 3710, 3939, 4232 3248 80.388 75.333 1.067x 5 quiet
ABAP-FS/CLAS/readback-active 22 132, 22, 21 22 0.449 0.486 0.923x 5 quiet
ABAP-FS/INTF/edit 76 73, 76, 149 76 1.551 1.551 1.000x 5 quiet
ABAP-FS/INTF/check 2543 2616, 2543, 2352 2071 51.898 49.976 1.038x 5 quiet
ABAP-FS/INTF/activate-edit 3683 4115, 3664, 3683 3464 75.163 80.067 0.939x 5 quiet
ABAP-FS/INTF/readback-active 18 24, 15, 18 17 0.367 0.414 0.886x 5 quiet
ABAP-FS/PROG/edit 101 75, 130, 101 92 2.061 2.044 1.008x 5 quiet
ABAP-FS/PROG/check 5914 6397, 5914, 4781 4457 120.694 95.755 1.260x 5 quiet
ABAP-FS/PROG/activate-edit 54078 55347, 54078, 49953 38830 1103.633 862.889 1.279x 5 quiet
ABAP-FS/PROG/readback-active 93 78, 96, 93 63 1.898 1.421 1.336x 5 above margin
ABAP-FS/INCL/edit 104 104, 228, 67 87 2.122 1.816 1.169x 5 quiet
ABAP-FS/INCL/check 2380 2051, 2439, 2380 2165 48.571 52.244 0.930x 5 quiet
ABAP-FS/INCL/activate-edit 3758 3286, 3758, 4018 3402 76.694 78.333 0.979x 5 quiet
ABAP-FS/INCL/readback-active 25 103, 17, 25 23 0.510 0.561 0.909x 5 quiet
ABAP-FS/DDLS/edit 103 69, 271, 103 73 2.102 1.756 1.197x 5 quiet
ABAP-FS/DDLS/check 8206 9784, 7561, 8206 4797 167.469 117.000 1.431x 5 above margin
ABAP-FS/DDLS/activate-edit 54042 69099, 54042, 53995 38991 1102.898 888.763 1.241x 5 quiet
ABAP-FS/DDLS/readback-active 96 91, 96, 98 64 1.959 1.561 1.255x 5 quiet
VSP/CLAS/edit+check+activate 6484 5590, 6609, 6484 5332 132.327 132.685 0.997x 5 quiet
VSP/INTF/edit+check+activate 6988 7684, 6988, 6148 5617 142.612 123.459 1.155x 5 quiet
VSP/PROG/edit+check+activate 56771 56771, 52053, 57365 37884 1158.592 924.000 1.254x 5 quiet
VSP/INCL/edit+check+activate 7626 6489, 8142, 7626 5101 155.633 120.756 1.289x 5 quiet
VSP/DDLS/edit+check+activate 62719 61427, 62719, 65603 44415 1279.980 1083.293 1.182x 5 quiet
Client Type Operation Result ms Note
ABAP-FS DEVC validate PASS 27
ABAP-FS DEVC create PASS 114
ABAP-FS DEVC edit N/A Package metadata update has no SDK/VSP source operation
ABAP-FS DEVC activate N/A Package is created active; no source activation
ABAP-FS CLAS validate PASS 22
ABAP-FS CLAS create PASS 75
ABAP-FS CLAS write-initial PASS 93
ABAP-FS INTF validate PASS 20
ABAP-FS INTF create PASS 45
ABAP-FS INTF write-initial PASS 62
ABAP-FS PROG validate MISSING 9 /sap/bc/adt/programs/validation is not served by OSD
ABAP-FS PROG create PASS 40
ABAP-FS PROG write-initial PASS 70
ABAP-FS INCL validate MISSING 11 /sap/bc/adt/includes/validation is not served by OSD
ABAP-FS INCL create PASS 8364
ABAP-FS INCL write-initial PASS 516
ABAP-FS DDLS validate MISSING 10 /sap/bc/adt/ddic/ddl/validation is not served by OSD
ABAP-FS DDLS create PASS 42
ABAP-FS DDLS write-initial PASS 71
ABAP-FS ALL5 activate-initial PASS 48247
ABAP-FS CLAS edit #1 PASS 153
ABAP-FS CLAS check #1 PASS 2178
ABAP-FS CLAS activate-edit #1 PASS 3710
ABAP-FS CLAS readback-active #1 PASS 132
ABAP-FS CLAS edit #2 PASS 129
ABAP-FS CLAS check #2 PASS 2589
ABAP-FS CLAS activate-edit #2 PASS 3939
ABAP-FS CLAS readback-active #2 PASS 22
ABAP-FS CLAS edit #3 PASS 77
ABAP-FS CLAS check #3 PASS 2663
ABAP-FS CLAS activate-edit #3 PASS 4232
ABAP-FS CLAS readback-active #3 PASS 21
ABAP-FS INTF edit #1 PASS 73
ABAP-FS INTF check #1 PASS 2616
ABAP-FS INTF activate-edit #1 PASS 4115
ABAP-FS INTF readback-active #1 PASS 24
ABAP-FS INTF edit #2 PASS 76
ABAP-FS INTF check #2 PASS 2543
ABAP-FS INTF activate-edit #2 PASS 3664
ABAP-FS INTF readback-active #2 PASS 15
ABAP-FS INTF prepare-baseline PASS 46526
ABAP-FS INTF edit #3 PASS 149
ABAP-FS INTF check #3 PASS 2352
ABAP-FS INTF activate-edit #3 PASS 3683
ABAP-FS INTF readback-active #3 PASS 18
ABAP-FS PROG edit #1 PASS 75
ABAP-FS PROG check #1 PASS 6397
ABAP-FS PROG activate-edit #1 PASS 55347
ABAP-FS PROG readback-active #1 PASS 78
ABAP-FS PROG edit #2 PASS 130
ABAP-FS PROG check #2 PASS 5914
ABAP-FS PROG activate-edit #2 PASS 54078
ABAP-FS PROG readback-active #2 PASS 96
ABAP-FS PROG edit #3 PASS 101
ABAP-FS PROG check #3 PASS 4781
ABAP-FS PROG activate-edit #3 PASS 49953
ABAP-FS PROG readback-active #3 PASS 93
ABAP-FS INCL edit #1 PASS 104
ABAP-FS INCL check #1 PASS 2051
ABAP-FS INCL activate-edit #1 PASS 3286
ABAP-FS INCL readback-active #1 PASS 103
ABAP-FS INCL edit #2 PASS 228
ABAP-FS INCL check #2 PASS 2439
ABAP-FS INCL activate-edit #2 PASS 3758
ABAP-FS INCL readback-active #2 PASS 17
ABAP-FS INCL edit #3 PASS 67
ABAP-FS INCL check #3 PASS 2380
ABAP-FS INCL activate-edit #3 PASS 4018
ABAP-FS INCL readback-active #3 PASS 25
ABAP-FS DDLS edit #1 PASS 69
ABAP-FS DDLS check #1 PASS 9784
ABAP-FS DDLS activate-edit #1 PASS 69099
ABAP-FS DDLS readback-active #1 PASS 91
ABAP-FS DDLS edit #2 PASS 271
ABAP-FS DDLS check #2 PASS 7561
ABAP-FS DDLS activate-edit #2 PASS 54042
ABAP-FS DDLS readback-active #2 PASS 96
ABAP-FS DDLS edit #3 PASS 103
ABAP-FS DDLS check #3 PASS 8206
ABAP-FS DDLS activate-edit #3 PASS 53995
ABAP-FS DDLS readback-active #3 PASS 98
VSP DEVC create PASS 122
VSP DEVC edit N/A VSP has CreatePackage; no package metadata update tool
VSP DEVC activate N/A Created active
VSP CLAS create+write+activate PASS 46737
VSP CLAS edit+check+activate #1 PASS 5590
VSP CLAS edit+check+activate #2 PASS 6609
VSP CLAS edit+check+activate #3 PASS 6484
VSP CLAS check-explicit PASS 2537
VSP CLAS activate-explicit PASS 2983
VSP CLAS readback-vsp PASS 23
VSP INTF create+write+activate PASS 66008
VSP INTF edit+check+activate #1 PASS 7684
VSP INTF edit+check+activate #2 PASS 6988
VSP INTF edit+check+activate #3 PASS 6148
VSP INTF check-explicit PASS 2690
VSP INTF activate-explicit PASS 3010
VSP INTF readback-vsp PASS 29
VSP PROG create+write+activate PASS 60696
VSP PROG edit+check+activate #1 PASS 56771
VSP PROG edit+check+activate #2 PASS 52053
VSP PROG edit+check+activate #3 PASS 57365
VSP PROG check-explicit PASS 2090
VSP PROG activate-explicit PASS 26574
VSP PROG readback-vsp PASS 21
VSP INCL create+write+activate PASS 57641
VSP INCL edit+check+activate #1 PASS 6489
VSP INCL edit+check+activate #2 PASS 8142
VSP INCL edit+check+activate #3 PASS 7626
VSP INCL check-explicit PASS 3080
VSP INCL activate-explicit PASS 3412
VSP INCL readback-vsp PASS 25
VSP DDLS create+write+activate PASS 63878
VSP DDLS edit+check+activate #1 PASS 61427
VSP DDLS edit+check+activate #2 PASS 62719
VSP DDLS edit+check+activate #3 PASS 65603
VSP DDLS check-explicit PASS 5413
VSP DDLS activate-explicit PASS 27238
VSP DDLS readback-vsp PASS 31
VSP DDLS delete+confirmed-404 PASS 100
VSP INCL delete+confirmed-404 PASS 2615
VSP PROG delete+confirmed-404 PASS 64
VSP INTF delete+confirmed-404 PASS 61
VSP CLAS delete+confirmed-404 PASS 59
VSP DEVC delete+confirmed-404 PASS 59
ABAP-FS DDLS delete+confirmed-404 PASS 58
ABAP-FS INCL delete+confirmed-404 PASS 2566
ABAP-FS PROG delete+confirmed-404 PASS 63
ABAP-FS INTF delete+confirmed-404 PASS 51
ABAP-FS CLAS delete+confirmed-404 PASS 56
ABAP-FS DEVC delete+confirmed-404 PASS 49

Required merge checks: test + scan. ADT lifecycle timing, Docker, gogen, preview, size and queue are advisory on PRs; lifecycle functional checks remain required (Alice, 2026-10-07).

@oisee
oisee merged commit 221cc49 into main Oct 10, 2026
28 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant