Skip to content

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

Open
liannacasper wants to merge 9 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 9 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: 18650 alert(s) (2707 errors, 6360 warnings, 9583 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 36 screenshots: 36 matched.

Native Android coverage

  • 📊 Line coverage: 7.93% (4060/51218 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 6.25% (20096/321673), branch 2.98% (929/31205), complexity 3.71% (1108/29859), method 6.50% (905/13925), class 10.65% (197/1849)
    • 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.93% (4060/51218 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 6.25% (20096/321673), branch 2.98% (929/31205), complexity 3.71% (1108/29859), method 6.50% (905/13925), class 10.65% (197/1849)
    • 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 810.000 ms
Base64 CN1 encode 200.000 ms
Base64 encode ratio (CN1/native) 0.247x (75.3% faster)
Base64 native decode 782.000 ms
Base64 CN1 decode 235.000 ms
Base64 decode ratio (CN1/native) 0.301x (69.9% 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: 10738 ms

  • Hotspots (Top 20 sampled methods):

    • 27.77% java.util.ArrayList.indexOf (527 samples)
    • 20.50% java.lang.String.indexOf (389 samples)
    • 18.18% com.codename1.tools.translator.Parser.isMethodUsed (345 samples)
    • 4.90% java.lang.Object.hashCode (93 samples)
    • 2.32% java.lang.System.identityHashCode (44 samples)
    • 1.84% com.codename1.tools.translator.ByteCodeClass.markDependent (35 samples)
    • 1.69% com.codename1.tools.translator.Parser.getClassByName (32 samples)
    • 1.37% com.codename1.tools.translator.BytecodeMethod.optimize (26 samples)
    • 1.21% java.lang.Integer.getChars (23 samples)
    • 1.11% com.codename1.tools.translator.Parser.cullMethods (21 samples)
    • 1.11% java.lang.StringBuilder.append (21 samples)
    • 1.00% com.codename1.tools.translator.ByteCodeClass.calcUsedByNative (19 samples)
    • 0.84% com.codename1.tools.translator.BytecodeMethod.appendCMethodPrefix (16 samples)
    • 0.84% com.codename1.tools.translator.Parser.generateClassAndMethodIndexHeader (16 samples)
    • 0.74% com.codename1.tools.translator.BytecodeMethod.isMethodUsedByNative (14 samples)
    • 0.68% com.codename1.tools.translator.BytecodeMethod.addToConstantPool (13 samples)
    • 0.68% sun.nio.fs.UnixNativeDispatcher.open0 (13 samples)
    • 0.63% java.util.ArrayList$Itr.next (12 samples)
    • 0.63% com.codename1.tools.translator.ByteCodeClass.isDefaultInterfaceMethod (12 samples)
    • 0.63% java.lang.StringCoding.encode (12 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 36 screenshots: 36 matched.
✅ Native iOS screenshot tests passed.

Benchmark Results

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

Detailed Performance Metrics

Metric Duration
Simulator Boot 0 ms
Simulator Boot (Run) 1000 ms
App Install 5000 ms
App Launch 4000 ms
Test Execution 216000 ms
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 2308.000 ms
Base64 CN1 encode 3556.000 ms
Base64 encode ratio (CN1/native) 1.541x (54.1% slower)
Base64 native decode 1467.000 ms
Base64 CN1 decode 1920.000 ms
Base64 decode ratio (CN1/native) 1.309x (30.9% 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