Skip to content

Skip UTF-16 REPLACE work for absent whole-string literals - #706

Merged
oisee merged 1 commit into
mainfrom
perf/replace-absent-fastpath
Oct 10, 2026
Merged

oisee merged 1 commit into
mainfrom
perf/replace-absent-fastpath

Conversation

@oisee

@oisee oisee commented Oct 10, 2026

Copy link
Copy Markdown
Owner

The zabapgit CPU profile attributed 40.63% inclusive CPU to ReplaceStmt,
with count16 at 8.17% flat and hasHalf at 4.47% flat. Literal REPLACE
chains repeatedly pay UTF-16 length and section costs for absent patterns.

Add one strings.Index before UTF-16 processing. Return the unchanged
subject and sy-subrc 4 only for a nonempty case-sensitive non-regex
pattern, a string target (cLen < 0), offset 0, omitted length (NoLength),
subject byte length <= MaxInt32, and no WTF-8 surrogate halves in either
operand. FIRST and ALL share this no-match result. Keep present patterns,
fixed c targets, explicit sections, IGNORING CASE, regex, and empty/half
patterns on the existing path. Byte mode/PCRE and JS remain unchanged.
REPLACEMENT COUNT/OFFSET/LENGTH/LINE remain unsupported by the frontend.

Retain the slow implementation behind a per-call test seam, without global
state. Compare value, subrc, and exception type/text in 2,286 table cases:
absent/present, c/string, valid/invalid sections, FIRST/ALL, Unicode case
folds, halves, empty patterns, regex and truncation. Independently assert
unchanged subjects and subrc 4. Compiling an overlay that returns subrc 0
makes TestReplaceAbsentFields fail as required; the real source passes.

Checks: go test ./abap/... exit 0; full node tools/gogen/semantics.mjs
394 ok, 0 FAIL, exit 0; size budget --changed origin/main exit 0 (two
inherited notices); leak scan of both changed files: 0 hits, exit 0;
git diff --check clean. Keep strings.go at its existing 636-line ceiling.

Go benchmarks, median of three 300ms samples, retained slow -> fast,
eight rotating ASCII subjects, FIRST present case:
1024 bytes, present=false: 448 -> 165.6 ns/op (2.71x)
1024 bytes, present=true: 1050 -> 1067 ns/op (0.98x)
65536 bytes, present=false: 21361 -> 8379 ns/op (2.55x)
65536 bytes, present=true: 39311 -> 41019 ns/op (0.96x)
Absent fast path allocates 0 B/op; present allocations remain unchanged.

Optional end-to-end: compile the read-only abapiti native input with this
branch and origin/main e7dd62c into
isolated output trees. Each build reports 2,127 classes and 199 stubs.
Clean copied kit, --times, GOGC=400, two runs each: main 25.60/23.12 s;
branch 22.83/22.94 s. All exit 0 and first output line 0. Report raw times
under varying host load, without a statistical speedup claim.

Heavy runs use nice -n10, GOFLAGS=-buildvcs=false, the supplied shared
GOCACHE and RAM scratch, instance range 50-59, and the resource gates.

Kit (abapiti perf/upper-ascii input, zabapgit check kit) with this branch: clean equal to Node (0 issues, 22 s), seeded equal to Node (5 issues, 23 s).

Codex worker; codex critic one round: MERGE.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VUy1x5QYimNEytFZpg7t7S

The zabapgit CPU profile attributed 40.63% inclusive CPU to ReplaceStmt,
with count16 at 8.17% flat and hasHalf at 4.47% flat. Literal REPLACE
chains repeatedly pay UTF-16 length and section costs for absent patterns.

Add one strings.Index before UTF-16 processing. Return the unchanged
subject and sy-subrc 4 only for a nonempty case-sensitive non-regex
pattern, a string target (cLen < 0), offset 0, omitted length (NoLength),
subject byte length <= MaxInt32, and no WTF-8 surrogate halves in either
operand. FIRST and ALL share this no-match result. Keep present patterns,
fixed c targets, explicit sections, IGNORING CASE, regex, and empty/half
patterns on the existing path. Byte mode/PCRE and JS remain unchanged.
REPLACEMENT COUNT/OFFSET/LENGTH/LINE remain unsupported by the frontend.

Retain the slow implementation behind a per-call test seam, without global
state. Compare value, subrc, and exception type/text in 2,286 table cases:
absent/present, c/string, valid/invalid sections, FIRST/ALL, Unicode case
folds, halves, empty patterns, regex and truncation. Independently assert
unchanged subjects and subrc 4. Compiling an overlay that returns subrc 0
makes TestReplaceAbsentFields fail as required; the real source passes.

Checks: go test ./abap/... exit 0; full node tools/gogen/semantics.mjs
394 ok, 0 FAIL, exit 0; size budget --changed origin/main exit 0 (two
inherited notices); leak scan of both changed files: 0 hits, exit 0;
git diff --check clean. Keep strings.go at its existing 636-line ceiling.

Go benchmarks, median of three 300ms samples, retained slow -> fast,
eight rotating ASCII subjects, FIRST present case:
1024 bytes, present=false: 448 -> 165.6 ns/op (2.71x)
1024 bytes, present=true: 1050 -> 1067 ns/op (0.98x)
65536 bytes, present=false: 21361 -> 8379 ns/op (2.55x)
65536 bytes, present=true: 39311 -> 41019 ns/op (0.96x)
Absent fast path allocates 0 B/op; present allocations remain unchanged.

Optional end-to-end: compile the read-only abapiti native input with this
branch and origin/main e7dd62c into
isolated output trees. Each build reports 2,127 classes and 199 stubs.
Clean copied kit, --times, GOGC=400, two runs each: main 25.60/23.12 s;
branch 22.83/22.94 s. All exit 0 and first output line 0. Report raw times
under varying host load, without a statistical speedup claim.

Heavy runs use nice -n10, GOFLAGS=-buildvcs=false, the supplied shared
GOCACHE and RAM scratch, instance range 50-59, and the resource gates.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01VUy1x5QYimNEytFZpg7t7S
@github-actions

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 b02a589

@github-actions

Copy link
Copy Markdown
Contributor

PR tests: 🟢 pass

Commit: 45de75a4 · Full test log

Job Result Time
build 🟢 pass 326 s
adt-lifecycle 🟢 pass 1855 s
packaging 🟢 pass 326 s
e2e 🟢 pass 155 s
kernel-conformance 🟢 pass 246 s
osgo-host 🟢 pass 243 s
suites (2) 🟢 pass 969 s
suites (5) 🟢 pass 1054 s
suites (6) 🟢 pass 800 s
suites (3) 🟢 pass 1113 s
suites (1) 🟢 pass 1215 s
suites (4) 🟢 pass 1165 s

ADT lifecycle: PASS

Commit: b02a589 · 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: QUIET

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 53.5 ms.

History: 1/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.

  • Main run 38053416750: Incompatible baseline identity: runtime
  • Main run 38043921883: Incompatible baseline identity: runtime
  • Main run 38030174014: Incompatible baseline identity: runtime
  • Main run 38005255170: Incompatible baseline identity: runtime
  • Main run 37999316752: Incompatible baseline identity: runtime
  • Main run 37989062556: Incompatible baseline identity: runtime
  • Main run 37886161097: Incompatible baseline identity: runtime
  • Main run 37879544660: Incompatible baseline identity: runtime
  • Main run 37876553083: Incompatible baseline identity: runtime
  • Main run 37873917768: Incompatible baseline identity: runtime
  • Main run 37870413609: Incompatible baseline identity: runtime
  • Main run 37852981673: Incompatible baseline identity: runtime
  • Main run 37851253083: Incompatible baseline identity: runtime
  • Main run 37844524313: Incompatible baseline identity: runtime
  • Main run 37834090942: Incompatible baseline identity: runtime
  • Main run 37827343465: Incompatible baseline identity: runtime
  • Main run 37823204608: Incompatible baseline identity: runtime
  • Main run 37817992577: Incompatible baseline identity: runtime
  • Main run 37812058097: Incompatible baseline identity: runtime
  • Main run 37810654018: Incompatible baseline identity: runtime
  • Main run 37807757231: Incompatible baseline identity: runtime
  • Main run 37799237344: Incompatible baseline identity: runtime
  • Main run 37796250964: Incompatible baseline identity: runtime
  • Main run 37792960295: Incompatible baseline identity: runtime
  • Main run 37786636609: Incompatible baseline identity: runtime
  • Main run 37780075902: Incompatible baseline identity: runtime
  • Main run 37769100182: Incompatible baseline identity: runtime
  • Main run 37766039452: Incompatible baseline identity: runtime
  • Main run 37752961212: Incompatible baseline identity: runtime
Client/type/operation Median ms Samples ms main ms (raw median) Current/reference main normalized median Ratio Main runs Timing
ABAP-FS/CLAS/edit 94 165, 94, 76 96 1.757 1.939 0.906x 1 quiet
ABAP-FS/CLAS/check 2756 2210, 2984, 2756 2734 51.514 55.232 0.933x 1 quiet
ABAP-FS/CLAS/activate-edit 4163 3546, 4163, 4259 4108 77.813 82.990 0.938x 1 quiet
ABAP-FS/CLAS/readback-active 29 38, 29, 24 25 0.542 0.505 1.073x 1 quiet
ABAP-FS/INTF/edit 78 78, 74, 159 74 1.458 1.495 0.975x 1 quiet
ABAP-FS/INTF/check 2736 2833, 2736, 2433 2698 51.140 54.505 0.938x 1 quiet
ABAP-FS/INTF/activate-edit 4175 4175, 4241, 3749 4183 78.037 84.505 0.923x 1 quiet
ABAP-FS/INTF/readback-active 23 23, 30, 20 25 0.430 0.505 0.851x 1 quiet
ABAP-FS/PROG/edit 109 82, 109, 112 116 2.037 2.343 0.869x 1 quiet
ABAP-FS/PROG/check 5089 6365, 5089, 5036 5175 95.121 104.545 0.910x 1 quiet
ABAP-FS/PROG/activate-edit 52974 61071, 52974, 52346 56892 990.168 1149.333 0.862x 1 quiet
ABAP-FS/PROG/readback-active 89 95, 89, 87 101 1.664 2.040 0.815x 1 quiet
ABAP-FS/INCL/edit 101 101, 190, 88 105 1.888 2.121 0.890x 1 quiet
ABAP-FS/INCL/check 2439 2112, 2711, 2439 2536 45.589 51.232 0.890x 1 quiet
ABAP-FS/INCL/activate-edit 3848 3342, 3848, 4120 3945 71.925 79.697 0.902x 1 quiet
ABAP-FS/INCL/readback-active 29 76, 27, 29 39 0.542 0.788 0.688x 1 quiet
ABAP-FS/DDLS/edit 108 86, 108, 282 104 2.019 2.101 0.961x 1 quiet
ABAP-FS/DDLS/check 7954 10488, 7619, 7954 8835 148.673 178.485 0.833x 1 quiet
ABAP-FS/DDLS/activate-edit 58845 64977, 58213, 58845 58743 1099.907 1186.727 0.927x 1 quiet
ABAP-FS/DDLS/readback-active 102 996, 81, 102 89 1.907 1.798 1.060x 1 quiet
VSP/CLAS/edit+check+activate 7067 6504, 7067, 7242 7145 132.093 144.343 0.915x 1 quiet
VSP/INTF/edit+check+activate 7247 7877, 7247, 6240 8610 135.458 173.939 0.779x 1 quiet
VSP/PROG/edit+check+activate 58435 58602, 56918, 58435 60819 1092.243 1228.667 0.889x 1 quiet
VSP/INCL/edit+check+activate 6855 5712, 6855, 7196 7862 128.131 158.828 0.807x 1 quiet
VSP/DDLS/edit+check+activate 71438 75231, 67361, 71438 69164 1335.290 1397.253 0.956x 1 quiet
Client Type Operation Result ms Note
ABAP-FS DEVC validate PASS 27
ABAP-FS DEVC create PASS 112
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 20
ABAP-FS CLAS create PASS 78
ABAP-FS CLAS write-initial PASS 94
ABAP-FS INTF validate PASS 15
ABAP-FS INTF create PASS 47
ABAP-FS INTF write-initial PASS 75
ABAP-FS PROG validate MISSING 10 /sap/bc/adt/programs/validation is not served by OSD
ABAP-FS PROG create PASS 43
ABAP-FS PROG write-initial PASS 81
ABAP-FS INCL validate MISSING 13 /sap/bc/adt/includes/validation is not served by OSD
ABAP-FS INCL create PASS 8983
ABAP-FS INCL write-initial PASS 534
ABAP-FS DDLS validate MISSING 12 /sap/bc/adt/ddic/ddl/validation is not served by OSD
ABAP-FS DDLS create PASS 45
ABAP-FS DDLS write-initial PASS 68
ABAP-FS ALL5 activate-initial PASS 50845
ABAP-FS CLAS edit #1 PASS 165
ABAP-FS CLAS check #1 PASS 2210
ABAP-FS CLAS activate-edit #1 PASS 3546
ABAP-FS CLAS readback-active #1 PASS 38
ABAP-FS CLAS edit #2 PASS 94
ABAP-FS CLAS check #2 PASS 2984
ABAP-FS CLAS activate-edit #2 PASS 4163
ABAP-FS CLAS readback-active #2 PASS 29
ABAP-FS CLAS edit #3 PASS 76
ABAP-FS CLAS check #3 PASS 2756
ABAP-FS CLAS activate-edit #3 PASS 4259
ABAP-FS CLAS readback-active #3 PASS 24
ABAP-FS INTF edit #1 PASS 78
ABAP-FS INTF check #1 PASS 2833
ABAP-FS INTF activate-edit #1 PASS 4175
ABAP-FS INTF readback-active #1 PASS 23
ABAP-FS INTF edit #2 PASS 74
ABAP-FS INTF check #2 PASS 2736
ABAP-FS INTF activate-edit #2 PASS 4241
ABAP-FS INTF readback-active #2 PASS 30
ABAP-FS INTF prepare-baseline PASS 46542
ABAP-FS INTF edit #3 PASS 159
ABAP-FS INTF check #3 PASS 2433
ABAP-FS INTF activate-edit #3 PASS 3749
ABAP-FS INTF readback-active #3 PASS 20
ABAP-FS PROG edit #1 PASS 82
ABAP-FS PROG check #1 PASS 6365
ABAP-FS PROG activate-edit #1 PASS 61071
ABAP-FS PROG readback-active #1 PASS 95
ABAP-FS PROG edit #2 PASS 109
ABAP-FS PROG check #2 PASS 5089
ABAP-FS PROG activate-edit #2 PASS 52974
ABAP-FS PROG readback-active #2 PASS 89
ABAP-FS PROG edit #3 PASS 112
ABAP-FS PROG check #3 PASS 5036
ABAP-FS PROG activate-edit #3 PASS 52346
ABAP-FS PROG readback-active #3 PASS 87
ABAP-FS INCL edit #1 PASS 101
ABAP-FS INCL check #1 PASS 2112
ABAP-FS INCL activate-edit #1 PASS 3342
ABAP-FS INCL readback-active #1 PASS 76
ABAP-FS INCL edit #2 PASS 190
ABAP-FS INCL check #2 PASS 2711
ABAP-FS INCL activate-edit #2 PASS 3848
ABAP-FS INCL readback-active #2 PASS 27
ABAP-FS INCL edit #3 PASS 88
ABAP-FS INCL check #3 PASS 2439
ABAP-FS INCL activate-edit #3 PASS 4120
ABAP-FS INCL readback-active #3 PASS 29
ABAP-FS DDLS edit #1 PASS 86
ABAP-FS DDLS check #1 PASS 10488
ABAP-FS DDLS activate-edit #1 PASS 64977
ABAP-FS DDLS readback-active #1 PASS 996
ABAP-FS DDLS edit #2 PASS 108
ABAP-FS DDLS check #2 PASS 7619
ABAP-FS DDLS activate-edit #2 PASS 58213
ABAP-FS DDLS readback-active #2 PASS 81
ABAP-FS DDLS edit #3 PASS 282
ABAP-FS DDLS check #3 PASS 7954
ABAP-FS DDLS activate-edit #3 PASS 58845
ABAP-FS DDLS readback-active #3 PASS 102
VSP DEVC create PASS 108
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 48205
VSP CLAS edit+check+activate #1 PASS 6504
VSP CLAS edit+check+activate #2 PASS 7067
VSP CLAS edit+check+activate #3 PASS 7242
VSP CLAS check-explicit PASS 2967
VSP CLAS activate-explicit PASS 3402
VSP CLAS readback-vsp PASS 16
VSP INTF create+write+activate PASS 65050
VSP INTF edit+check+activate #1 PASS 7877
VSP INTF edit+check+activate #2 PASS 7247
VSP INTF edit+check+activate #3 PASS 6240
VSP INTF check-explicit PASS 2758
VSP INTF activate-explicit PASS 3219
VSP INTF readback-vsp PASS 26
VSP PROG create+write+activate PASS 61825
VSP PROG edit+check+activate #1 PASS 58602
VSP PROG edit+check+activate #2 PASS 56918
VSP PROG edit+check+activate #3 PASS 58435
VSP PROG check-explicit PASS 2231
VSP PROG activate-explicit PASS 26678
VSP PROG readback-vsp PASS 21
VSP INCL create+write+activate PASS 58822
VSP INCL edit+check+activate #1 PASS 5712
VSP INCL edit+check+activate #2 PASS 6855
VSP INCL edit+check+activate #3 PASS 7196
VSP INCL check-explicit PASS 2744
VSP INCL activate-explicit PASS 3110
VSP INCL readback-vsp PASS 25
VSP DDLS create+write+activate PASS 63475
VSP DDLS edit+check+activate #1 PASS 75231
VSP DDLS edit+check+activate #2 PASS 67361
VSP DDLS edit+check+activate #3 PASS 71438
VSP DDLS check-explicit PASS 5734
VSP DDLS activate-explicit PASS 28237
VSP DDLS readback-vsp PASS 26
VSP DDLS delete+confirmed-404 PASS 93
VSP INCL delete+confirmed-404 PASS 3242
VSP PROG delete+confirmed-404 PASS 75
VSP INTF delete+confirmed-404 PASS 65
VSP CLAS delete+confirmed-404 PASS 68
VSP DEVC delete+confirmed-404 PASS 62
ABAP-FS DDLS delete+confirmed-404 PASS 67
ABAP-FS INCL delete+confirmed-404 PASS 2646
ABAP-FS PROG delete+confirmed-404 PASS 69
ABAP-FS INTF delete+confirmed-404 PASS 61
ABAP-FS CLAS delete+confirmed-404 PASS 56
ABAP-FS DEVC delete+confirmed-404 PASS 52

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 023b823 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