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

Memoize vocabularies #42

Merged
merged 8 commits into from
Jul 12, 2018
Merged

Memoize vocabularies #42

merged 8 commits into from
Jul 12, 2018

Conversation

tomgross
Copy link
Member

@tomgross tomgross commented Jun 1, 2017

This has a big performance win for huge vocabularies.


def update(self):
"""See z3c.form.interfaces.IWidget."""
SequenceWidget.update(self)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don't you use super(OrderedSelectWidget, self).update() here? I think widget.HTMLSelectWidget.update is not called right now.

time() // ONE_DAY
)
return key

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add another component to the key (not sure what) so that the cache is invalidated if you change the taxonomy ttw or by import?

@malthe
Copy link
Member

malthe commented Sep 21, 2017

Should we try and get this into 1.5?

@tomgross
Copy link
Member Author

I'd love to have it but don't have time at the moment to make this work in a generic way. This is the cache function we use. We invalidate only on changes to keywords.

ONE_DAY = 60 * 60 * 24

def _cache_one_day(fun, self):
    catalog = api.portal.get_tool(name='portal_catalog')
    subjects = len(catalog._catalog.uniqueValuesFor('Subject'))
    key = '{0}{1}'.format(
        subjects,
        time() // ONE_DAY
    )
    return key

If someone wants to step in go ahead.

@malthe
Copy link
Member

malthe commented Jul 10, 2018

@petschki – would be nice to get this into 1.5.0 perhaps?

I think using the _p_mtime attribute would make it pretty trivial to implement in a generic way.

@petschki
Copy link
Member

petschki commented Jul 10, 2018 via email

@petschki
Copy link
Member

@malthe @vincentfretin well ... this does the trick ... can anybody test this with some huge sample vdex file or mail it to me, so I can test it?

@vincentfretin
Copy link
Member

The changes looks good. I don't have huge vocabularies at hand. @andreesg may have that. See #36

@coveralls
Copy link

coveralls commented Jul 12, 2018

Coverage Status

Coverage decreased (-0.1%) to 45.824% when pulling 7655c8e on tomgross-memoize_voc into 923b6ca on master.

@petschki
Copy link
Member

I've tested this with a VDEX file with 3 languages and 1500 items each language ... so far no performance problems to me. I think we are ready to merge and release.

@malthe malthe merged commit dd4bdb5 into master Jul 12, 2018
@malthe malthe deleted the tomgross-memoize_voc branch July 12, 2018 08:19
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.

5 participants