Skip to content

Simd revisited#4742

Open
shai-almog wants to merge 15 commits intomasterfrom
simd-revisite
Open

Simd revisited#4742
shai-almog wants to merge 15 commits intomasterfrom
simd-revisite

Conversation

@shai-almog
Copy link
Copy Markdown
Collaborator

No description provided.

@shai-almog shai-almog changed the title Simd revisite Simd revisited Apr 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 13, 2026

✅ Continuous Quality Report

Test & Coverage

Static Analysis

Generated automatically by the PR CI workflow.

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented Apr 13, 2026

iOS screenshot updates

Compared 37 screenshots: 35 matched, 2 updated.

  • BrowserComponent — updated screenshot. Screenshot differs (1179x2556 px, bit depth 8).

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

  • 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: 173 seconds

Build and Run Timing

Metric Duration
Simulator Boot 1000 ms
Simulator Boot (Run) 2000 ms
App Install 8000 ms
App Launch 4000 ms
Test Execution 206000 ms

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 1588.000 ms
Base64 CN1 encode 1829.000 ms
Base64 encode ratio (CN1/native) 1.152x (15.2% slower)
Base64 native decode 1139.000 ms
Base64 CN1 decode 1600.000 ms
Base64 decode ratio (CN1/native) 1.405x (40.5% slower)
Base64 SIMD encode 778.000 ms
Base64 encode ratio (SIMD/native) 0.490x (51.0% faster)
Base64 encode ratio (SIMD/CN1) 0.425x (57.5% faster)
Base64 SIMD decode 607.000 ms
Base64 decode ratio (SIMD/native) 0.533x (46.7% faster)
Base64 decode ratio (SIMD/CN1) 0.379x (62.1% faster)
Image encode benchmark iterations 250
Image PNG encode (SIMD off) 615.000 ms
Image PNG encode (SIMD on) 495.000 ms
Image PNG encode ratio (SIMD on/off) 0.805x (19.5% faster)
Image JPEG encode (SIMD off) 491.000 ms
Image JPEG encode (SIMD on) 433.000 ms
Image JPEG encode ratio (SIMD on/off) 0.882x (11.8% faster)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 13, 2026

✅ ByteCodeTranslator Quality Report

Test & Coverage

  • Tests: 381 total, 0 failed, 2 skipped

Benchmark Results

  • Execution Time: 10158 ms

  • Hotspots (Top 20 sampled methods):

    • 24.80% java.lang.String.indexOf (443 samples)
    • 18.87% com.codename1.tools.translator.Parser.isMethodUsed (337 samples)
    • 11.53% java.util.ArrayList.indexOf (206 samples)
    • 6.72% com.codename1.tools.translator.Parser.addToConstantPool (120 samples)
    • 4.37% com.codename1.tools.translator.ByteCodeClass.markDependent (78 samples)
    • 4.09% java.lang.Object.hashCode (73 samples)
    • 2.58% com.codename1.tools.translator.BytecodeMethod.optimize (46 samples)
    • 2.46% java.lang.System.identityHashCode (44 samples)
    • 1.68% com.codename1.tools.translator.ByteCodeClass.updateAllDependencies (30 samples)
    • 1.51% com.codename1.tools.translator.ByteCodeClass.fillVirtualMethodTable (27 samples)
    • 1.46% com.codename1.tools.translator.Parser.generateClassAndMethodIndexHeader (26 samples)
    • 1.34% com.codename1.tools.translator.ByteCodeClass.calcUsedByNative (24 samples)
    • 0.95% com.codename1.tools.translator.BytecodeMethod.appendMethodSignatureSuffixFromDesc (17 samples)
    • 0.95% com.codename1.tools.translator.Parser.getClassByName (17 samples)
    • 0.95% java.lang.StringCoding.encode (17 samples)
    • 0.84% com.codename1.tools.translator.Parser.cullMethods (15 samples)
    • 0.73% java.lang.StringBuilder.append (13 samples)
    • 0.56% com.codename1.tools.translator.BytecodeMethod.isMethodUsedByNative (10 samples)
    • 0.56% org.objectweb.asm.ClassReader.readCode (10 samples)
    • 0.50% sun.nio.cs.UTF_8$Encoder.encode (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 Author

shai-almog commented Apr 13, 2026

Compared 37 screenshots: 37 matched.

Native Android coverage

  • 📊 Line coverage: 7.85% (4146/52848 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 6.17% (20528/332823), branch 2.98% (958/32108), complexity 3.64% (1119/30710), method 6.40% (917/14321), class 10.63% (202/1900)
    • 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)

✅ Native Android screenshot tests passed.

Native Android coverage

  • 📊 Line coverage: 7.85% (4146/52848 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 6.17% (20528/332823), branch 2.98% (958/32108), complexity 3.64% (1119/30710), method 6.40% (917/14321), class 10.63% (202/1900)
    • 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 2381.000 ms
Base64 CN1 encode 277.000 ms
Base64 encode ratio (CN1/native) 0.116x (88.4% faster)
Base64 native decode 1533.000 ms
Base64 CN1 decode 147.000 ms
Base64 decode ratio (CN1/native) 0.096x (90.4% faster)
Image encode benchmark status skipped (SIMD unsupported)

shai-almog and others added 10 commits April 14, 2026 19:56
…e64 SIMD in Java (#4745)

* Add NEON-accelerated base64Encode/base64Decode to Simd API and wire into Base64 SIMD methods

Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/c218992e-943a-4ce5-8d63-f82c0792416f

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

* Address code review: clarify loop conditions and comment in NEON base64

Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/c218992e-943a-4ce5-8d63-f82c0792416f

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

* Add new SIMD generic primitive declarations and remove base64 methods from IOSSimd

- Added shl, shrLogical, addWrapping, subWrapping for byte arrays
- Added offset-based overloads for unpackUnsignedByteToInt, add, cmpEq, cmpLt, select
- Removed base64Encode and base64Decode declarations

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

* Replace base64 overrides with generic SIMD primitive validation wrappers in JavaSESimd

Remove base64Encode and base64Decode overrides. Add validation wrapper
overrides for new generic Simd primitives: shl, shrLogical, addWrapping,
subWrapping, unpackUnsignedByteToInt, add (int[]), cmpEq, cmpLt, and
select.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

* Replace base64 NEON section with generic SIMD primitives in IOSSimd.m

Remove NEON-accelerated Base64 encode/decode implementations and add
NEON implementations for new generic Simd primitives: shl, shrLogical,
addWrapping, subWrapping, unpackUnsignedByteToInt, add (int), cmpEq,
cmpLt, and select (with offset parameters).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

* Remove base64 methods from Simd; add generic byte/int primitives; rewrite Base64 SIMD in Java

- Remove base64Encode/base64Decode from Simd, IOSSimd, JavaSESimd, IOSSimd.m
- Add generic byte shift primitives: shl(byte[]), shrLogical(byte[])
- Add wrapping byte arithmetic: addWrapping(byte[]), subWrapping(byte[])
- Add offset-based int overloads: unpackUnsignedByteToInt, add, cmpLt, cmpEq, select
- Add NEON implementations for all new primitives in IOSSimd.m
- Add validation wrappers in JavaSESimd.java
- Rewrite encodeNoNewlineSimd in Java using int-domain SIMD compare/select
- Rewrite decodeNoWhitespaceSimd in Java using int-domain SIMD shift/or
- Update SimdTest with tests for new primitives
- All 2345 tests pass

Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/5fc6976c-f0ec-4638-b22b-2cbc9c9ca5dd

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

* Optimize SIMD Base64: replace slow scatter/gather + per-element SIMD calls with fast inline scalar Java

The previous approach called 15+ individual Simd operations per 48-byte chunk
(each a virtual dispatch + JNI transition on iOS), plus scalar scatter/gather
loops for byte↔int conversion. This added ~2500 JNI transitions per encode
of 8KB, making it 64-109% slower than the already-fast scalar code.

Replace with the same 4x-unrolled table-lookup approach used by
encodeNoNewline(), now with offset support. This matches the scalar
CN1 encode/decode performance while maintaining the same API contract.

Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/90b8c36e-8f20-47da-9fb4-56344f18a336

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

* Revert "Optimize SIMD Base64: replace slow scatter/gather + per-element SIMD calls with fast inline scalar Java"

This reverts commit 00e5103.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>
shai-almog and others added 5 commits April 14, 2026 21:13
…4755)

* Add generic SIMD interleave primitives

Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/bbcd3a3b-1fcc-4818-a045-011025111878

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

* Tighten iOS SIMD mask blending

Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/bbcd3a3b-1fcc-4818-a045-011025111878

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

* Implement byte-lane Base64 SIMD hot path

Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/c4483141-f308-4c53-9d5b-f8185272067f

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

* Fix performance comparison table grouping

Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/44fd1aa3-15ab-484f-908f-71ae605a2c5f

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

* Fix iOS benchmark stats extraction

Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/43c5792a-216e-4635-bec3-dce6ce1c16da

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

* Harden iOS Base64 benchmark reporting

Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/59bc0cc2-933a-457d-b5f2-7387ab1210f4

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

* Refine Base64 benchmark control flow

Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/59bc0cc2-933a-457d-b5f2-7387ab1210f4

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

* Fail iOS build on benchmark exceptions

Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/590ef420-e08c-4863-bc1d-374266ed3221

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

* Harden Base64 SIMD scratch initialization

Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/0af385dc-375d-435d-b488-72b71b1d5135

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

* Add generic VM lookup path for Base64 SIMD

Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/f779927e-d85c-407e-862f-61c4d64ddd86

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

* Clarify unsigned lookup semantics in IOSSimd

Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/f779927e-d85c-407e-862f-61c4d64ddd86

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

* Fuse SIMD decode unpack and lookup

Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/8587852f-737f-4503-9e44-7dd39ed13c3b

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

* Clarify generic SIMD lookup behavior

Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/8587852f-737f-4503-9e44-7dd39ed13c3b

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

* Refactor Base64 SIMD scratch handling

Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/806ca223-d5e2-458d-88a8-6e4347070c37

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

* Clarify native Base64 decode validation

Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/806ca223-d5e2-458d-88a8-6e4347070c37

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

* Keep SIMD API generic for Base64 path

Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/baa9db39-0b7b-4734-ac26-5bf3d2bc986f

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

* Restore native offset SIMD helpers

Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/50ddb198-a41b-4ec4-9be2-201d4a6f9527

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>
…ith SIMD on/off (#4771)

* Add Image SIMD toggle and benchmarks

Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/5dfd66c3-87f7-4e83-a9b0-af5f1401a286

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

* Finalize Image SIMD validation

Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/5dfd66c3-87f7-4e83-a9b0-af5f1401a286

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

* Simplify Image SIMD implementation

Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/f2b9cfbc-2c39-4c15-9946-45a6597c9c0f

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

* Polish simplified Image SIMD code

Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/f2b9cfbc-2c39-4c15-9946-45a6597c9c0f

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

* Simplify Image SIMD toggle and mask path

Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/04951212-c075-4568-9953-62a5c5cf6ce3

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

* Tighten final Image SIMD cleanup

Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/04951212-c075-4568-9953-62a5c5cf6ce3

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>
@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented Apr 18, 2026

Compared 7 screenshots: 7 matched.
✅ JavaSE simulator integration screenshots matched stored baselines.

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.

2 participants