Skip to content
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

unicodeTestIn script can be slow #125

Closed
mauritsvanrees opened this issue Apr 8, 2019 · 0 comments
Closed

unicodeTestIn script can be slow #125

mauritsvanrees opened this issue Apr 8, 2019 · 0 comments

Comments

@mauritsvanrees
Copy link
Sponsor Member

The unicodeTestIn script can be slow. The last change to this script was in 2010 by me. This speeded it up already, but today I saw that it can still be slow.

Case I saw today:

  • Plone 4.3.11
  • Over 3500 keywords/tags/subjects in the site.
  • Edit a page that has no tags: takes about three seconds.
  • Add five tags to the page.
  • Edit the page again: takes about twelve seconds.

The tags are rendered by the keyword.pt widget template, which calls unicodeTestIn in a few lines. The culprit is this line in the rendering of the select tag and its options, which gets called often. Translated to Python code, that part of the template does this:

# currently selected tags:
value = ['a', 'b, 'c']
# allowedKeywords is bug list of 3500 keywords
for keyword in allowedKeywords:
    context.unicodeTestIn(keyword, value)

So unicodeTestIn is called 3500 times, and each time it calls context.unicodeEncode(v) on each item in the current value. The worst thing about that, is that unicodeEncode is a separate skin script, so Plone has to locate this script, check permissions, etcetera, so that is probably what makes it take a lot of time.

I have prepared a fix that brings the edit-page rendering in the example back to three seconds. I will create a PR shortly.
Should probably be done on all current Archetypes branches, but let's start with branch 1.9.x for Plone 4.3.

@mauritsvanrees mauritsvanrees self-assigned this Apr 8, 2019
mauritsvanrees added a commit that referenced this issue Apr 8, 2019
Fixes #125

This contains performance tests, which are ignored by default, but can be activated by exporting a number:
$ export AT_UNICODETESTIN=3000
$ bin/test -s Products.Archetypes -m test_widgets -t test_unicodeTestIn
...
Testing unicodeTestIn with 3000 items, and 50 selected.
...

Timings before this fix:

First test part finished in 4.2931 seconds
Second test part finished in 12.6825 seconds

Timings after this fix:

First test part finished in 0.0373 seconds
Second test part finished in 0.2010 seconds

And with the fix and 30,000 items:

First test part finished in 0.0374 seconds
Second test part finished in 2.0301 seconds
mister-roboto pushed a commit to plone/buildout.coredev that referenced this issue Apr 9, 2019
Branch: refs/heads/1.9.x
Date: 2019-04-08T23:29:21+02:00
Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org>
Commit: plone/Products.Archetypes@ca3ae7b

Fixed slowness in unicodeTestIn script used by keyword template.

Fixes plone/Products.Archetypes#125

This contains performance tests, which are ignored by default, but can be activated by exporting a number:
$ export AT_UNICODETESTIN=3000
$ bin/test -s Products.Archetypes -m test_widgets -t test_unicodeTestIn
...
Testing unicodeTestIn with 3000 items, and 50 selected.
...

Timings before this fix:

First test part finished in 4.2931 seconds
Second test part finished in 12.6825 seconds

Timings after this fix:

First test part finished in 0.0373 seconds
Second test part finished in 0.2010 seconds

And with the fix and 30,000 items:

First test part finished in 0.0374 seconds
Second test part finished in 2.0301 seconds

Files changed:
A news/125.bugfix
M Products/Archetypes/skins/archetypes/unicodeTestIn.py
M Products/Archetypes/tests/test_widgets.py
Repository: Products.Archetypes

Branch: refs/heads/1.9.x
Date: 2019-04-09T08:09:46+02:00
Author: Jens W. Klein (jensens) <jk@kleinundpartner.at>
Commit: plone/Products.Archetypes@4f1e05b

Merge pull request #126 from plone/maurits-issue-125-unicode-test-in-19

Fixed slowness in unicodeTestIn script used by keyword template.

Files changed:
A news/125.bugfix
M Products/Archetypes/skins/archetypes/unicodeTestIn.py
M Products/Archetypes/tests/test_widgets.py
mauritsvanrees added a commit that referenced this issue Apr 9, 2019
Fixes #125

This contains performance tests, which are ignored by default, but can be activated by exporting a number:
$ export AT_UNICODETESTIN=3000
$ bin/test -s Products.Archetypes -m test_widgets -t test_unicodeTestIn
...
Testing unicodeTestIn with 3000 items, and 50 selected.
...

Timings before this fix:

First test part finished in 4.2931 seconds
Second test part finished in 12.6825 seconds

Timings after this fix:

First test part finished in 0.0373 seconds
Second test part finished in 0.2010 seconds

And with the fix and 30,000 items:

First test part finished in 0.0374 seconds
Second test part finished in 2.0301 seconds
mister-roboto pushed a commit to plone/buildout.coredev that referenced this issue Apr 10, 2019
Branch: refs/heads/master
Date: 2019-04-09T10:42:41+02:00
Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org>
Commit: plone/Products.Archetypes@5acdaa5

Fixed slowness in unicodeTestIn script used by keyword template.

Fixes plone/Products.Archetypes#125

This contains performance tests, which are ignored by default, but can be activated by exporting a number:
$ export AT_UNICODETESTIN=3000
$ bin/test -s Products.Archetypes -m test_widgets -t test_unicodeTestIn
...
Testing unicodeTestIn with 3000 items, and 50 selected.
...

Timings before this fix:

First test part finished in 4.2931 seconds
Second test part finished in 12.6825 seconds

Timings after this fix:

First test part finished in 0.0373 seconds
Second test part finished in 0.2010 seconds

And with the fix and 30,000 items:

First test part finished in 0.0374 seconds
Second test part finished in 2.0301 seconds

Files changed:
A news/125.bugfix
M Products/Archetypes/skins/archetypes/unicodeTestIn.py
M Products/Archetypes/tests/test_widgets.py
Repository: Products.Archetypes

Branch: refs/heads/master
Date: 2019-04-10T11:10:07+02:00
Author: Jens W. Klein (jensens) <jk@kleinundpartner.at>
Commit: plone/Products.Archetypes@aa05381

Merge pull request #128 from plone/maurits-issue-125-unicode-test-in-master

Fixed slowness in unicodeTestIn script used by keyword template. [master]

Files changed:
A news/125.bugfix
M Products/Archetypes/skins/archetypes/unicodeTestIn.py
M Products/Archetypes/tests/test_widgets.py
mister-roboto pushed a commit to plone/buildout.coredev that referenced this issue Apr 10, 2019
Branch: refs/heads/1.15.x
Date: 2019-04-09T10:30:01+02:00
Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org>
Commit: plone/Products.Archetypes@63287b4

Fixed slowness in unicodeTestIn script used by keyword template.

Fixes plone/Products.Archetypes#125

This contains performance tests, which are ignored by default, but can be activated by exporting a number:
$ export AT_UNICODETESTIN=3000
$ bin/test -s Products.Archetypes -m test_widgets -t test_unicodeTestIn
...
Testing unicodeTestIn with 3000 items, and 50 selected.
...

Timings before this fix:

First test part finished in 4.2931 seconds
Second test part finished in 12.6825 seconds

Timings after this fix:

First test part finished in 0.0373 seconds
Second test part finished in 0.2010 seconds

And with the fix and 30,000 items:

First test part finished in 0.0374 seconds
Second test part finished in 2.0301 seconds

Files changed:
A news/125.bugfix
M Products/Archetypes/skins/archetypes/unicodeTestIn.py
M Products/Archetypes/tests/test_widgets.py
Repository: Products.Archetypes

Branch: refs/heads/1.15.x
Date: 2019-04-10T11:10:36+02:00
Author: Jens W. Klein (jensens) <jk@kleinundpartner.at>
Commit: plone/Products.Archetypes@5b4317a

Merge pull request #127 from plone/maurits-issue-125-unicode-test-in-1.15

Fixed slowness in unicodeTestIn script used by keyword template. [1.15]

Files changed:
A news/125.bugfix
M Products/Archetypes/skins/archetypes/unicodeTestIn.py
M Products/Archetypes/tests/test_widgets.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant