Skip to content

test: add PartialApplyFmt unit tests for ASCII-safe handling#856

Merged
stephenamar-db merged 1 commit into
databricks:masterfrom
He-Pin:perf/simple-format-ascii-safe
May 20, 2026
Merged

test: add PartialApplyFmt unit tests for ASCII-safe handling#856
stephenamar-db merged 1 commit into
databricks:masterfrom
He-Pin:perf/simple-format-ascii-safe

Conversation

@He-Pin
Copy link
Copy Markdown
Contributor

@He-Pin He-Pin commented May 13, 2026

Summary

Follow-up unit coverage for #860 (which propagates ASCII-safety through Format outputs).

The original branch held the production implementation, but #860 covers the same optimization with a slightly different approach and was merged first. Reduce this PR to the regression tests that were developed for the original implementation — they pass unchanged against the current Format.scala.

Changes

  • sjsonnet/test/src/sjsonnet/FormatTests.scala — 4 new tests directly exercising Format.PartialApplyFmt.evalRhs via a minimal in-memory EvalScope:
    1. simple named format preserves ascii-safe result for numeric values
    2. simple named format does not mark unsafe string values ascii-safe
    3. simple named format does not mark unsafe static literals ascii-safe
    4. simple named format combines ascii-safety across multiple keys

Verification

./mill 'sjsonnet.jvm[3.3.7]'.test.testOnly sjsonnet.FormatTests
# Tests: 4, Passed: 4, Failed: 0

./mill __.checkFormat
# SUCCESS

References

He-Pin added a commit to He-Pin/sjsonnet that referenced this pull request May 13, 2026
Motivation:
A follow-up probe reused parser ASCII-safe metadata to skip static format literal safety scanning after PR databricks#856, but internal debug counter gains did not translate into Native whole-process speed.

Modification:
Record the rejected parser `_asciiSafe` format hint experiment in the gap ledger and sync-points file so it is not repeated without materially new evidence.

Result:
The accepted simple-format ASCII-safe optimization remains unchanged, and the rejected hint path is documented with forward/reverse Native benchmark evidence.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
He-Pin added a commit to He-Pin/sjsonnet that referenced this pull request May 13, 2026
Motivation:
A Native-only ASCII-safe byte-copy probe tested whether a manual low-byte loop could improve large formatted string rendering after PR databricks#856.

Modification:
Record the rejected manual copy-loop experiment in the gap ledger and sync-points file with forward/reverse Native benchmark evidence.

Result:
The optimized implementation remains on the faster platform `String.getBytes(0, len, dst, dstPos)` path, and the slower manual copy route is documented to avoid repeated work.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@He-Pin He-Pin closed this May 13, 2026
@He-Pin He-Pin reopened this May 14, 2026
Motivation:
PR databricks#860 propagates ASCII-safety through Format outputs by tracking the
ASCII-safety of compiled format literals and each interpolated value,
then setting Val.Str._asciiSafe on the result. Add direct unit coverage
for PartialApplyFmt so future refactors of format-string parsing or
ASCII-safety detection cannot regress the optimization without a
visible test failure.

Modification:
* New FormatTests.scala exercising PartialApplyFmt.evalRhs through a
  minimal in-memory EvalScope. Four cases: safe numeric value, unsafe
  string value, unsafe static literal in the format, and ASCII-safety
  combined across multiple keys (one safe + one unsafe).

Result:
* ./mill 'sjsonnet.jvm[3.3.7]'.test.testOnly sjsonnet.FormatTests
  -- 4/4 PASS.
* ./mill __.checkFormat green.

References:
Follow-up unit coverage for databricks#860
@He-Pin He-Pin force-pushed the perf/simple-format-ascii-safe branch from f2a2e3b to cd29839 Compare May 19, 2026 04:23
@He-Pin He-Pin changed the title perf: preserve ASCII-safe simple format results test: add PartialApplyFmt unit tests for ASCII-safe handling May 19, 2026
@He-Pin He-Pin marked this pull request as ready for review May 19, 2026 07:04
@stephenamar-db stephenamar-db merged commit 1f764fa into databricks:master May 20, 2026
5 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.

2 participants