Skip to content

Use TypedArray.prototype.set in the _makeWrapper PostScript wasm-code - #22379

Open
Snuffleupagus wants to merge 1 commit into
mozilla:masterfrom
Snuffleupagus:_makeWrapper-TypedArray-set
Open

Snuffleupagus wants to merge 1 commit into
mozilla:masterfrom
Snuffleupagus:_makeWrapper-TypedArray-set

Conversation

@Snuffleupagus

@Snuffleupagus Snuffleupagus commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Rather than building an intermediate writeOut function, which always sets all of the outView anyway, it seems that we can simply use TypedArray.prototype.set instead.

Edit: I feel like I'm most likely overlooking some trivial reason for why this is a stupid idea.

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Reference tests

Results for 9957f99 (run, references from mozilla/pdf.js.refs@d16403bcaa).

Platform Status Tests Total runtime Errors Different FBF No reference Report
Linux ✅ 1414 13m 6s 0 0 0 0
Windows ✅ 1414 15m 8s 0 0 0 0

The report is kept for 30 days and replaced by the next run.

@codecov-commenter

codecov-commenter commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.58%. Comparing base (956f0cd) to head (9957f99).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #22379   +/-   ##
=======================================
  Coverage   90.57%   90.58%           
=======================================
  Files         278      278           
  Lines       68586    68564   -22     
=======================================
- Hits        62123    62109   -14     
+ Misses       6463     6455    -8     
Flag Coverage Δ
browsertest 66.27% <100.00%> (-0.01%) ⬇️
fonttest 8.99% <ø> (ø)
integrationtest 69.61% <40.00%> (+0.02%) ⬆️
unittest 61.25% <100.00%> (-0.02%) ⬇️
unittestcli 58.99% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Viewer preview

Commit 9957f99 (build logs).

Viewer Build Preview
Modern (gulp generic) ✅ viewer.html
Legacy (gulp generic-legacy) ✅ viewer.html

Previews are removed when the PR closes and may be pruned after 30 days without an update.

sync-pdfs-for-pdf-js Bot pushed a commit to mozilla/pdf.js.refs that referenced this pull request Oct 29, 2026
@codspeed

codspeed Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 10.27%

⚡ 1 improved benchmark
❌ 2 regressed benchmarks
✅ 85 untouched benchmarks
⏩ 174 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ PDFImage.createImageData: DeviceN, PostScript tint (colorspace_cos.pdf) 11.6 ms 16.2 ms -28.09%
❌ Pattern.parseShading: function-based, PostScript (function_based_shading.pdf) 45.7 ms 52.6 ms -13.05%
⚡ PartialEvaluator.buildPath: lines (bug1743245.pdf) 17.8 ms 15.4 ms +15.53%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing Snuffleupagus:_makeWrapper-TypedArray-set (9957f99) with master (956f0cd)

Open in CodSpeed

Footnotes

  1. 174 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

sync-pdfs-for-pdf-js Bot pushed a commit to mozilla/pdf.js.refs that referenced this pull request Oct 29, 2026
@Snuffleupagus
Snuffleupagus force-pushed the _makeWrapper-TypedArray-set branch from 19af665 to aac2fb4 Compare October 30, 2026 09:20
sync-pdfs-for-pdf-js Bot pushed a commit to mozilla/pdf.js.refs that referenced this pull request Oct 30, 2026
…code

Rather than building an intermediate `writeOut` function, which always sets all of the `outView` anyway, it seems that we can simply use `TypedArray.prototype.set` instead.
@Snuffleupagus

Snuffleupagus commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator Author

I don't know what to make of the benchmarking results above, since I cannot reproduce any regressions locally in Firefox Nightly when testing with the following manifest file:

[
  {
    "id": "colorspace_cos",
    "file": "pdfs/colorspace_cos.pdf",
    "md5": "d3703784c2558f33e03b91dccb745b6c",
    "rounds": 500,
    "type": "eq"
  },
  {
    "id": "function-based-shading",
    "file": "pdfs/function_based_shading.pdf",
    "md5": "7796f0131e7d6428c1bf24a73ff13f95",
    "rounds": 500,
    "type": "eq"
  },
  {
    "id": "personwithdog",
    "file": "pdfs/personwithdog.pdf",
    "md5": "cd68fb2ce00dab97801b3e51495b99e3",
    "rounds": 500,
    "type": "eq"
  }
]

which gave the following results, indicating no significant regression, when comparing this patch against the master branch:

-- Grouped By pdf, page, stat --
pdf                    | page | stat         | Count | Baseline(ms) | Current(ms) | +/- |     %  | Result(P<.05)
---------------------- | ---- | ------------ | ----- | ------------ | ----------- | --- | ------ | -------------
colorspace_cos         | 0    | Overall      |   500 |           14 |          15 |   0 |   0.65 |
colorspace_cos         | 0    | Page Request |   500 |            0 |           0 |   0 |  -6.28 |
colorspace_cos         | 0    | Rendering    |   500 |           14 |          14 |   0 |   0.87 |
function-based-shading | 0    | Overall      |   500 |           90 |          90 |   0 |   0.10 |
function-based-shading | 0    | Page Request |   500 |            1 |           0 |   0 | -11.11 |
function-based-shading | 0    | Rendering    |   500 |           89 |          89 |   0 |   0.16 |
personwithdog          | 0    | Overall      |   500 |           43 |          43 |   0 |   0.13 |
personwithdog          | 0    | Page Request |   500 |            1 |           1 |   0 |   5.19 |
personwithdog          | 0    | Rendering    |   500 |           42 |          42 |   0 |   0.02 |

@Snuffleupagus
Snuffleupagus force-pushed the _makeWrapper-TypedArray-set branch from aac2fb4 to 9957f99 Compare October 31, 2026 21:35
@Snuffleupagus
Snuffleupagus marked this pull request as ready for review October 31, 2026 21:36
sync-pdfs-for-pdf-js Bot pushed a commit to mozilla/pdf.js.refs that referenced this pull request Oct 31, 2026
sync-pdfs-for-pdf-js Bot pushed a commit to mozilla/pdf.js.refs that referenced this pull request Oct 31, 2026
sync-pdfs-for-pdf-js Bot pushed a commit to mozilla/pdf.js.refs that referenced this pull request Oct 31, 2026

This branch was successfully deployed

1 active deployment
sync_pdfs — 9957f992 Deployed Oct 31, 2026 by Snuffleupagus via request #687
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