Skip to content

Introduce SIMD hint annotations and propagate them through the bytecode translator#4718

Open
liannacasper wants to merge 4 commits intomasterfrom
codex/add-auto-vectorization-for-array-access
Open

Introduce SIMD hint annotations and propagate them through the bytecode translator#4718
liannacasper wants to merge 4 commits intomasterfrom
codex/add-auto-vectorization-for-array-access

Conversation

@liannacasper
Copy link
Copy Markdown
Collaborator

Motivation

  • Provide an explicit, forward-compatible way to mark hot, data-parallel methods with SIMD/vectorization hints so translators can use that metadata for future optimizations.
  • Annotate existing hot code (Base64) with vectorization hints and document usage so profiles can guide optimizations.

Description

  • Added a new annotation holder com.codename1.annotations.Simd with @Candidate, @Reduction, and @WidthHint annotations and a private constructor to prevent instantiation.
  • Annotated Base64.decodeNoWhitespace and Base64.encodeNoNewline with @Simd.Candidate and @Simd.WidthHint(16) and imported the new annotation package.
  • Extended documentation docs/developer-guide/performance.asciidoc with a new SIMD Hint Annotations section describing the annotations, examples, and guidance.
  • Extended the translator parsing and metadata plumbing: Parser.MethodVisitorWrapper recognizes the Simd annotation descriptors (including extracting the value from WidthHint) and sets flags on BytecodeMethod.
  • Added SIMD hint state and helpers to BytecodeMethod (simdCandidateHint, simdReductionHint, simdWidthHint, getters/setters, hasSimdHints, and getSimdHintSummary) and a verbose log when optimizer is enabled.

Testing

  • Performed a source tree compilation to verify the new annotations and translator changes integrate and compile without errors; compilation succeeded.
  • No automated unit tests were modified or executed as part of this change.

Codex Task

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

Developer Guide build artifacts are available for download from this workflow run:

Developer Guide quality checks:

  • AsciiDoc linter: 1 issue(s) flagged (1 errors) (exit code 1) (report)
  • Vale: 18637 alert(s) (2707 errors, 6359 warnings, 9571 suggestions) (exit code 1) (report)
  • Image references: 33 unused image(s) found (report)

Unused image preview:

  • img/uwp-app-manager-apps.png
  • img/uwp-certificate-generator.png
  • img/uwp-cn1settings-debug-desktop-selected.png
  • img/uwp-cn1settings-disk-icon.png
  • img/uwp-cn1settings-uwp.png
  • img/uwp-cn1settings-windows-settings-menu-item.png
  • img/uwp-dashboard-download-appxbundle.png
  • img/uwp-extract-zip-file.png
  • img/uwp-mobile-recently-added.png
  • img/uwp-mobile-settings-developer-mode.png
  • ... and 23 more

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

✅ Continuous Quality Report

Test & Coverage

Static Analysis

Generated automatically by the PR CI workflow.

@shai-almog
Copy link
Copy Markdown
Collaborator

shai-almog commented Apr 7, 2026

Compared 35 screenshots: 35 matched.

Native Android coverage

  • 📊 Line coverage: 7.90% (4047/51204 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 6.23% (20021/321604), branch 2.97% (927/31205), complexity 3.70% (1105/29856), method 6.49% (903/13922), class 10.61% (196/1848)
    • Lowest covered classes
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysKt – 0.00% (0/6327 lines covered)
      • kotlin.collections.unsigned.kotlin.collections.unsigned.UArraysKt___UArraysKt – 0.00% (0/2384 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.ClassReader – 0.00% (0/1519 lines covered)
      • kotlin.collections.kotlin.collections.CollectionsKt___CollectionsKt – 0.00% (0/1148 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.MethodWriter – 0.00% (0/923 lines covered)
      • kotlin.sequences.kotlin.sequences.SequencesKt___SequencesKt – 0.00% (0/712 lines covered)
      • kotlin.text.kotlin.text.StringsKt___StringsKt – 0.00% (0/623 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.Frame – 0.00% (0/564 lines covered)
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysJvmKt – 0.00% (0/495 lines covered)
      • kotlinx.coroutines.kotlinx.coroutines.JobSupport – 0.00% (0/423 lines covered)

✅ Native Android screenshot tests passed.

Native Android coverage

  • 📊 Line coverage: 7.90% (4047/51204 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 6.23% (20021/321604), branch 2.97% (927/31205), complexity 3.70% (1105/29856), method 6.49% (903/13922), class 10.61% (196/1848)
    • Lowest covered classes
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysKt – 0.00% (0/6327 lines covered)
      • kotlin.collections.unsigned.kotlin.collections.unsigned.UArraysKt___UArraysKt – 0.00% (0/2384 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.ClassReader – 0.00% (0/1519 lines covered)
      • kotlin.collections.kotlin.collections.CollectionsKt___CollectionsKt – 0.00% (0/1148 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.MethodWriter – 0.00% (0/923 lines covered)
      • kotlin.sequences.kotlin.sequences.SequencesKt___SequencesKt – 0.00% (0/712 lines covered)
      • kotlin.text.kotlin.text.StringsKt___StringsKt – 0.00% (0/623 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.Frame – 0.00% (0/564 lines covered)
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysJvmKt – 0.00% (0/495 lines covered)
      • kotlinx.coroutines.kotlinx.coroutines.JobSupport – 0.00% (0/423 lines covered)

Benchmark Results

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 1153.000 ms
Base64 CN1 encode 260.000 ms
Base64 encode ratio (CN1/native) 0.225x (77.5% faster)
Base64 native decode 1272.000 ms
Base64 CN1 decode 309.000 ms
Base64 decode ratio (CN1/native) 0.243x (75.7% faster)

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

✅ ByteCodeTranslator Quality Report

Test & Coverage

  • Tests: 379 total, 0 failed, 2 skipped

Benchmark Results

  • Execution Time: 10211 ms

  • Hotspots (Top 20 sampled methods):

    • 21.52% java.lang.String.indexOf (387 samples)
    • 18.85% com.codename1.tools.translator.Parser.isMethodUsed (339 samples)
    • 13.63% com.codename1.tools.translator.Parser.addToConstantPool (245 samples)
    • 9.23% java.util.ArrayList.indexOf (166 samples)
    • 5.56% java.lang.Object.hashCode (100 samples)
    • 3.34% java.lang.System.identityHashCode (60 samples)
    • 2.56% com.codename1.tools.translator.ByteCodeClass.fillVirtualMethodTable (46 samples)
    • 1.72% com.codename1.tools.translator.ByteCodeClass.markDependent (31 samples)
    • 1.39% com.codename1.tools.translator.Parser.cullMethods (25 samples)
    • 1.28% com.codename1.tools.translator.BytecodeMethod.optimize (23 samples)
    • 1.28% java.lang.StringBuilder.append (23 samples)
    • 1.22% com.codename1.tools.translator.Parser.getClassByName (22 samples)
    • 1.06% com.codename1.tools.translator.ByteCodeClass.calcUsedByNative (19 samples)
    • 0.95% java.lang.AbstractStringBuilder.append (17 samples)
    • 0.89% com.codename1.tools.translator.BytecodeMethod.equals (16 samples)
    • 0.83% com.codename1.tools.translator.BytecodeMethod.isMethodUsedByNative (15 samples)
    • 0.72% com.codename1.tools.translator.BytecodeMethod.appendCMethodPrefix (13 samples)
    • 0.72% com.codename1.tools.translator.Parser.generateClassAndMethodIndexHeader (13 samples)
    • 0.67% java.lang.StringCoding.encode (12 samples)
    • 0.50% com.codename1.tools.translator.BytecodeMethod.appendMethodSignatureSuffixFromDesc (9 samples)
  • ⚠️ Coverage report not generated.

Static Analysis

  • ✅ SpotBugs: no findings (report was not generated by the build).
  • ⚠️ PMD report not generated.
  • ⚠️ Checkstyle report not generated.

Generated automatically by the PR CI workflow.

@shai-almog
Copy link
Copy Markdown
Collaborator

shai-almog commented Apr 7, 2026

Compared 35 screenshots: 35 matched.
✅ Native iOS screenshot tests passed.

Benchmark Results

  • VM Translation Time: 0 seconds
  • Compilation Time: 161 seconds

Detailed Performance Metrics

Metric Duration
Simulator Boot 2000 ms
Simulator Boot (Run) 1000 ms
App Install 4000 ms
App Launch 2000 ms
Test Execution 209000 ms
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 1410.000 ms
Base64 CN1 encode 2626.000 ms
Base64 encode ratio (CN1/native) 1.862x (86.2% slower)
Base64 native decode 963.000 ms
Base64 CN1 decode 1449.000 ms
Base64 decode ratio (CN1/native) 1.505x (50.5% slower)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants