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

Enable APCu cache for Configuration objects #952

Merged
merged 14 commits into from
Jun 12, 2019

Conversation

smgallo
Copy link
Contributor

@smgallo smgallo commented Jun 6, 2019

Description

The GroupBy refactor will see data that is currently stored in PHP code moved to configuration files parsed via the Configuration classes. While these classes provide additional functionality such as references, include files, and comments, there is a performance overhead for providing these features. This work is an effort to reduce that overhead as well as improve overall performance.

Parsed Configuration objects are now cached using APCu to improve performance. APCu is a user-space in-memory cache for PHP that uses shared memory to cache data between requests. This cache is not persistent and is cleared on a restart of the web server but for our purposes this is OK as the cache will be reloaded automatically as calls are made. Note that on the first call, performance will be the same as the local configuration object cache as files are parsed and the cache is seeded but on subsequent calls Configuration objects will be pulled from the cache with only Configuration::factory() and Configuration::__construct() being called.

Changes to global or local configuration files are automatically detected by scanning the global and local configuration files and comparing the maximum modification time of all files to that of the object currently in the cache. If configuration files have been modified, they are re-parsed and the stale configuration object is updated in the cache.

Additional work was also performed:

  • Comments were updated and brought in line with current XDMoD standards
  • An iConfiguration interface is now provided that all Configuration object code must implement. This specifies the public methods that are available.
  • A bug was corrected where timestamp columns specifying CURRENT_TIMESTAMP as a default value would see that value quoted when it should not be.

Motivation and Context

Performance improvements prior to GroupBy refactoring.

Tests performed

Implemented new tests.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project as found in the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@smgallo smgallo added this to the 8.5.0 milestone Jun 6, 2019
@smgallo smgallo added bug Bugfixes new feature New functionality labels Jun 6, 2019
@plessbd
Copy link
Contributor

plessbd commented Jun 7, 2019

@smgallo
Copy link
Contributor Author

smgallo commented Jun 7, 2019

Updated docs as per @plessbd


$fullpath = $this->localConfigDir . '/' . $file;
$this->localConfigFiles[] = $fullpath;
$fileStats = stat($fullpath);
Copy link
Member

Choose a reason for hiding this comment

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

Should check for a false return code from stat() here and output some sort or useful error message.

@smgallo
Copy link
Contributor Author

smgallo commented Jun 11, 2019

@jpwhite4 requested changes made.

@smgallo smgallo merged commit cd2546a into ubccr:xdmod8.5 Jun 12, 2019
@smgallo smgallo deleted the config/config-cache-apcu branch June 12, 2019 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugfixes new feature New functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants