Conflicting Files ? Failure

User tests: Successful: Unsuccessful:

avatar chrisdavenport
chrisdavenport
11 Jun 2017

Note: This replaces and is the same as #12649 but without the branch merge that I was unable to recover from. It includes the suggestions by @nikosdion such that the new memory cache handler is not listed in global configuration.

Summary of Changes

Running the Smart Search indexer on a medium-sized site often results in "out of memory" failures which can only be addressed by running the CLI indexer with more memory allocated, like this:

php -d memory_limit=256M finder_indexer.php

However, this option is not usually available for web-based indexing.

It turns out that the problem is largely due to the tokeniser attempting to reduce execution time by caching all previous tokenisations under 128 bytes long. This PR addresses that issue by limiting the number of cached tokenisations to 100. Note: the number could be made configurable, but I am doubtful of the benefit to be gained so that is not part of this PR.

Hat tip to @mahagr for pointing out the problem with the tokeniser.

Since this might conceivably be of use elsewhere, the fix has been implemented by adding a new storage class to the JCache library. The new JCacheStorageMemory class uses a regular PHP array to store cached items. A maxBuffers option allows you to define the maximum number of items to cache (default 100). If an attempt is made to store a new item when the cache is already full, the least recently used item will be deleted to make room.

Testing Instructions

Find or construct a site with enough content that the CLI indexer fails with an out of memory error. As a rough guide you'll probably need over 1,000 articles to trigger the error. The size of the articles doesn't matter much because tokenisations of strings more than 128 bytes long are not cached and most articles are likely to be longer than that.

Apply the PR and run the indexer again. Hopefully you won't get the out of memory error!

Alternatively, since #12679 and #12680 have now been merged, simply look at the amount of memory used.

I am aware that unit tests need to be added for JCacheStorageMemory and I'd appreciate help in writing them.

Documentation Changes Required

None.

Votes

# of Users Experiencing Issue
1/1
Average Importance Score
4.00

avatar chrisdavenport chrisdavenport - open - 11 Jun 2017
avatar chrisdavenport chrisdavenport - change - 11 Jun 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 11 Jun 2017
Category Administration com_finder Libraries
avatar franz-wohlkoenig franz-wohlkoenig - change - 19 Apr 2019
Title
[Smart Search] Limit memory used by tokeniser
Limit memory used by tokeniser
avatar franz-wohlkoenig franz-wohlkoenig - edited - 19 Apr 2019
avatar Hackwar
Hackwar - comment - 16 May 2021

This has since become outdated. Thanks for your work, however the tokeniser has been improved in other ways which hopefully make this obsolete.

avatar jwaisner
jwaisner - comment - 16 May 2021

Closing. Thank you for the work. Please check the tokeniser in latest nightly build.

avatar jwaisner jwaisner - change - 16 May 2021
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2021-05-16 17:03:33
Closed_By jwaisner
avatar jwaisner jwaisner - close - 16 May 2021

Add a Comment

Login with GitHub to post a comment