-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Avoid to create any subarrays when optimizing 'save, transform, constructPath, restore' (bug 1961107) #19825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
/botio test |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @calixteman received. Current queue size: 0 Live output at: http://54.241.84.105:8877/4e0b914673636bc/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @calixteman received. Current queue size: 0 Live output at: http://54.193.163.58:8877/2e4b6141cfb520e/output.txt |
Do we "need" new methods for this, can't we just change the existing ones to accept an optional diff --git a/src/core/operator_list.js b/src/core/operator_list.js
index 5b1885ef9..f643f181a 100644
--- a/src/core/operator_list.js
+++ b/src/core/operator_list.js
@@ -524,11 +524,11 @@ addState(
switch (buffer[k++]) {
case DrawOPS.moveTo:
case DrawOPS.lineTo:
- Util.applyTransform(buffer.subarray(k), transform);
+ Util.applyTransform(buffer, transform, k);
k += 2;
break;
case DrawOPS.curveTo:
- Util.applyTransformToBezier(buffer.subarray(k), transform);
+ Util.applyTransformToBezier(buffer, transform, k);
k += 6;
break;
}
diff --git a/src/shared/util.js b/src/shared/util.js
index fd2d5fcb3..1d1cefc3b 100644
--- a/src/shared/util.js
+++ b/src/shared/util.js
@@ -730,15 +730,15 @@ class Util {
}
// For 2d affine transforms
- static applyTransform(p, m) {
- const p0 = p[0];
- const p1 = p[1];
- p[0] = p0 * m[0] + p1 * m[2] + m[4];
- p[1] = p0 * m[1] + p1 * m[3] + m[5];
+ static applyTransform(p, m, pos = 0) {
+ const p0 = p[pos];
+ const p1 = p[pos + 1];
+ p[pos] = p0 * m[0] + p1 * m[2] + m[4];
+ p[pos + 1] = p0 * m[1] + p1 * m[3] + m[5];
}
// For 2d affine transforms
- static applyTransformToBezier(p, transform) {
+ static applyTransformToBezier(p, transform, pos = 0) {
const m0 = transform[0];
const m1 = transform[1];
const m2 = transform[2];
@@ -746,10 +746,10 @@ class Util {
const m4 = transform[4];
const m5 = transform[5];
for (let i = 0; i < 6; i += 2) {
- const pI = p[i];
- const pI1 = p[i + 1];
- p[i] = pI * m0 + pI1 * m2 + m4;
- p[i + 1] = pI * m1 + pI1 * m3 + m5;
+ const pI = p[pos + i];
+ const pI1 = p[pos + i + 1];
+ p[pos + i] = pI * m0 + pI1 * m2 + m4;
+ p[pos + i + 1] = pI * m1 + pI1 * m3 + m5;
}
} |
From: Bot.io (Linux m4)FailedFull output at http://54.241.84.105:8877/4e0b914673636bc/output.txt Total script time: 30.74 mins
|
/botio-linux browsertest |
From: Bot.io (Linux m4)ReceivedCommand cmd_browsertest from @calixteman received. Current queue size: 0 Live output at: http://54.241.84.105:8877/667fed790b2349e/output.txt |
From: Bot.io (Windows)FailedFull output at http://54.193.163.58:8877/2e4b6141cfb520e/output.txt Total script time: 58.84 mins
|
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/667fed790b2349e/output.txt Total script time: 16.29 mins
|
Could we also replace this existing code pdf.js/src/core/font_renderer.js Lines 748 to 754 in f1e20cd
with something like the following now? for (let i = 0, ii = args.length; i < ii; i += 2) {
Util.applyTransform(args, this.currentTransform, i);
} |
…ructPath, restore' (bug 1961107) Removing those `subarray`calls helps to improve performance by a factor 6 on Linux and by a factor of 3 on Windows 11.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me, thank you.
/botio-linux browsertest |
From: Bot.io (Linux m4)ReceivedCommand cmd_browsertest from @calixteman received. Current queue size: 0 Live output at: http://54.241.84.105:8877/098491421bf0993/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/098491421bf0993/output.txt Total script time: 16.21 mins
|
Removing those
subarray
calls helps to improve performance by a factor 6 on Linux and by a factor of 3on Windows 11.