Skip to content

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

Closed
liannacasper wants to merge 24 commits intomasterfrom
codex/add-auto-vectorization-for-array-access
Closed

Introduce SIMD hint annotations and propagate them through the bytecode translator#4718
liannacasper wants to merge 24 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
Contributor

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: 18676 alert(s) (2710 errors, 6367 warnings, 9599 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
Contributor

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

Android screenshot updates

Compared 36 screenshots: 35 matched, 1 updated.

  • ValidatorLightweightPicker — updated screenshot. Screenshot differs (320x640 px, bit depth 8).

    ValidatorLightweightPicker
    Preview info: JPEG preview quality 70; JPEG preview quality 70.
    Full-resolution PNG saved as ValidatorLightweightPicker.png in workflow artifacts.

Native Android coverage

  • 📊 Line coverage: 7.75% (4073/52579 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 6.08% (20143/331490), branch 2.91% (930/31974), complexity 3.62% (1107/30622), method 6.34% (907/14300), class 10.44% (198/1896)
    • 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/730 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 1033.000 ms
Base64 CN1 encode 134.000 ms
Base64 encode ratio (CN1/native) 0.130x (87.0% faster)
Base64 native decode 865.000 ms
Base64 CN1 decode 211.000 ms
Base64 decode ratio (CN1/native) 0.244x (75.6% faster)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

✅ ByteCodeTranslator Quality Report

Test & Coverage

  • Tests: 377 total, 0 failed, 2 skipped

Benchmark Results

  • Execution Time: 9710 ms

  • Hotspots (Top 20 sampled methods):

    • 25.60% java.lang.String.indexOf (439 samples)
    • 20.87% com.codename1.tools.translator.Parser.isMethodUsed (358 samples)
    • 12.65% java.util.ArrayList.indexOf (217 samples)
    • 4.20% java.lang.Object.hashCode (72 samples)
    • 3.67% com.codename1.tools.translator.ByteCodeClass.markDependent (63 samples)
    • 3.03% com.codename1.tools.translator.BytecodeMethod.addToConstantPool (52 samples)
    • 2.62% com.codename1.tools.translator.Parser.addToConstantPool (45 samples)
    • 2.27% java.lang.System.identityHashCode (39 samples)
    • 1.87% com.codename1.tools.translator.BytecodeMethod.equals (32 samples)
    • 1.63% com.codename1.tools.translator.ByteCodeClass.calcUsedByNative (28 samples)
    • 1.63% com.codename1.tools.translator.Parser.generateClassAndMethodIndexHeader (28 samples)
    • 1.46% com.codename1.tools.translator.BytecodeMethod.appendMethodC (25 samples)
    • 1.34% java.lang.StringBuilder.append (23 samples)
    • 1.11% com.codename1.tools.translator.BytecodeMethod.optimize (19 samples)
    • 0.93% java.lang.StringCoding.encode (16 samples)
    • 0.82% com.codename1.tools.translator.Parser.cullMethods (14 samples)
    • 0.82% com.codename1.tools.translator.BytecodeMethod.isMethodUsedByNative (14 samples)
    • 0.64% com.codename1.tools.translator.BytecodeMethod.appendCMethodPrefix (11 samples)
    • 0.47% java.util.TreeMap.getEntry (8 samples)
    • 0.47% sun.nio.fs.UnixNativeDispatcher.open0 (8 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

iOS screenshot updates

Compared 36 screenshots: 35 matched, 1 updated.

  • landscape — updated screenshot. Screenshot differs (2556x1179 px, bit depth 8).

    landscape
    Preview info: Preview provided by instrumentation.
    Full-resolution PNG saved as landscape.png in workflow artifacts.

Benchmark Results

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

Detailed Performance Metrics

Metric Duration
Simulator Boot 0 ms
Simulator Boot (Run) 1000 ms
App Install 1000 ms
App Launch 3000 ms
Test Execution 196000 ms
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 1851.000 ms
Base64 CN1 encode 14993.000 ms
Base64 encode ratio (CN1/native) 8.100x (710.0% slower)
Base64 native decode 1315.000 ms
Base64 CN1 decode 2344.000 ms
Base64 decode ratio (CN1/native) 1.783x (78.3% 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.

3 participants