In conjunction with the rest of the patches, and the patch that removes
the beautifulsoup integration that sets dir="auto" programmatically,
rendering files with many lines on Sourcehut will go from ~4.5 seconds
to ~300ms (the 4.5 seconds was reduced from 6.5 before my patch that
improves template rendering).
This patch depends on:
https://lists.sr.ht/~sircmpwn/sr.ht-dev/patches/47341
The following patches depend on the patch above:
https://lists.sr.ht/~sircmpwn/sr.ht-dev/patches/47343
https://lists.sr.ht/~sircmpwn/sr.ht-dev/patches/47344
https://lists.sr.ht/~sircmpwn/sr.ht-dev/patches/47345
https://lists.sr.ht/~sircmpwn/sr.ht-dev/patches/47346
https://lists.sr.ht/~sircmpwn/sr.ht-dev/patches/47347
https://lists.sr.ht/~sircmpwn/sr.ht-dev/patches/47349
At a later date, I can submit a patch to limit the maximum number of
lines rendered (with a warning at the top of the page) beyond ~100k or
so. With these patches, rendering 100k lines is slow, but managable (at
300ms ish, compared to nearly 7000ms).
The main culprit is the line markers. Rendering the line markers is
still the bulk of the 300ms (about 70%). The vast number of tags that BS
had to parse to add dir="auto" contributed to the very long times when
rendering large files.
I expect to optimise the generator at a later date. Currently, the
Python function that generates the lines is the main blocker. Perhaps an
approach where the memory for the lines is computed beforehand
(possible, since the pattern is fairly simple) would improve this
process. I do worry about how this may impact code readability and
maintainability, however.
---
gitsrht/templates/clone.html | 2 ++
gitsrht/templates/create.html | 2 ++
gitsrht/templates/send-email-end.html | 2 ++
gitsrht/templates/send-email-review.html | 1 +
gitsrht/templates/settings_access.html | 1 +
gitsrht/templates/settings_info.html | 2 ++
gitsrht/templates/settings_rename.html | 1 +
gitsrht/templates/user.html | 2 ++
8 files changed, 13 insertions(+)
diff --git a/gitsrht/templates/clone.html b/gitsrht/templates/clone.html
index e1130a9..012aacb 100644
--- a/gitsrht/templates/clone.html
+++ b/gitsrht/templates/clone.html
@@ -24,6 +24,7 @@
<label for="name">Name</label>
<input
type="text"
+ dir="auto"
name="name"
id="name"
class="form-control {{valid.cls("name")}}"
@@ -34,6 +35,7 @@
<label for="description">Description</label>
<input
type="text"
+ dir="auto"
name="description"
id="description"
class="form-control {{valid.cls("description")}}"
diff --git a/gitsrht/templates/create.html b/gitsrht/templates/create.html
index 4595173..3128a73 100644
--- a/gitsrht/templates/create.html
+++ b/gitsrht/templates/create.html
@@ -14,6 +14,7 @@
autofocus
{% endif %}
type="text"
+ dir="auto"
name="name"
id="name"
class="form-control {{valid.cls("name")}}"
@@ -24,6 +25,7 @@
<label for="description">Description</label>
<input
type="text"
+ dir="auto"
name="description"
id="description"
class="form-control {{valid.cls("description")}}"
diff --git a/gitsrht/templates/send-email-end.html b/gitsrht/templates/send-email-end.html
index 7e77f8b..9af5324 100644
--- a/gitsrht/templates/send-email-end.html
+++ b/gitsrht/templates/send-email-end.html
@@ -69,6 +69,7 @@
<div class="form-group">
<input
type="text"
+ dir="auto"
name="cover_letter_subject"
class="form-control {{valid.cls("cover_letter_subject")}}"
placeholder="Subject..."
@@ -76,6 +77,7 @@
{{valid.summary("cover_letter_subject")}}
</div>
<textarea
+ dir="auto"
class="form-control {{valid.cls("cover_letter")}}"
rows="8"
name="cover_letter"
diff --git a/gitsrht/templates/send-email-review.html b/gitsrht/templates/send-email-review.html
index 28923a3..5e1db6e 100644
--- a/gitsrht/templates/send-email-review.html
+++ b/gitsrht/templates/send-email-review.html
@@ -50,6 +50,7 @@
<label for="patchset_to">To</label>
<input
type="text"
+ dir="auto"
name="patchset_to"
id="patchset_to"
class="form-control {{valid.cls('patchset_to')}}"
diff --git a/gitsrht/templates/settings_access.html b/gitsrht/templates/settings_access.html
index 99dc5dd..49691fb 100644
--- a/gitsrht/templates/settings_access.html
+++ b/gitsrht/templates/settings_access.html
@@ -50,6 +50,7 @@
<label for="user">User</label>
<input
type="text"
+ dir="auto"
class="form-control {{valid.cls("user")}}"
id="user"
name="user"
diff --git a/gitsrht/templates/settings_info.html b/gitsrht/templates/settings_info.html
index f11c94b..9c056f8 100644
--- a/gitsrht/templates/settings_info.html
+++ b/gitsrht/templates/settings_info.html
@@ -16,6 +16,7 @@
</label>
<input
type="text"
+ dir="auto"
class="form-control"
id="name"
value="{{repo.name}}"
@@ -27,6 +28,7 @@
</label>
<input
type="text"
+ dir="auto"
class="form-control"
id="description"
name="description"
diff --git a/gitsrht/templates/settings_rename.html b/gitsrht/templates/settings_rename.html
index 6ecd05b..de9c79f 100644
--- a/gitsrht/templates/settings_rename.html
+++ b/gitsrht/templates/settings_rename.html
@@ -12,6 +12,7 @@
</label>
<input
type="text"
+ dir="auto"
class="form-control {{valid.cls('name')}}"
id="name"
name="name"
diff --git a/gitsrht/templates/user.html b/gitsrht/templates/user.html
index 92d5f09..8d3354c 100644
--- a/gitsrht/templates/user.html
+++ b/gitsrht/templates/user.html
@@ -35,6 +35,7 @@
<input
name="search"
type="text"
+ dir="auto"
placeholder="Search"
class="form-control"
value="{{ search if search else "" }}" />
@@ -48,6 +49,7 @@
<input
name="search"
type="text"
+ dir="auto"
placeholder="Search"
class="form-control{% if search_error %} is-invalid{% endif %}"
value="{{ search if search else "" }}" />
--
2.42.0