Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Cache] Add PhpArrayAdapter to use shared memory on PHP 7.0#18823

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:masterfromtgalopin:opcache-adapter
Jun 28, 2016

Conversation

@tgalopin
Copy link
Contributor

@tgalopintgalopin commentedMay 20, 2016
edited by javiereguiluz
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?WIP
Fixed tickets-
LicenseMIT
Doc PR-

Depends on#18825

This PR aims to implement a Symfony Cache adapter able to build files optimized for OPCache memory storage. Any kind of static data that can be warmed up is a candidate for OPcache storage.

This PR is limited to the implementation of the Adapter. It's usage in the annotations caching system is implemented in the PR#18533. The aim is also to use this adapter in other contexts (validator, serializer, ...).


if ('N;' === $value) {
$value = null;
} elseif (isset($value[2]) && is_string($value) && ':' === $value[1]) {
Copy link
Member

Choose a reason for hiding this comment

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

is_string should come beforeisset($value[2]) IMO

}
}

$dump = <<<EOF
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be enclosed with nowdoc instead of heredoc.

*/
class NullAdapter implements AdapterInterface
{
private $createCacheItem;
Copy link
Contributor

Choose a reason for hiding this comment

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

phpdoc missing

@tgalopintgalopinforce-pushed theopcache-adapter branch 2 times, most recently from928dc61 toc6e08fcCompareMay 25, 2016 11:43
@tgalopin
Copy link
ContributorAuthor

I did the changes

OskarStark reacted with thumbs up emoji

EOF;

foreach ($values as $key => $value) {
CacheItem::validateKey($key);

Choose a reason for hiding this comment

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

because PHP casts numeric string keys to ints, we should cast ints to string here:
`is_int($key) ? (string) $key : $key);

$fallbackKeys = array();

foreach ($keys as $key) {
if (!is_string($key)) {

Choose a reason for hiding this comment

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

this check should be done before calling generateItems

Copy link
Member

Choose a reason for hiding this comment

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

indeed. Doing it in the generator will throw the exception too late (the iterator will throw it during iteration, while it must be throw by getItems)

@nicolas-grekas
Copy link
Member

I suggest renaming this adapter to Php7Adapter (ans use the OpcacheAdapter name in#18894)

@tgalopintgalopin changed the title[Cache] Add OpCacheAdapter to use shared memory on PHP 7.0+[Cache] Add Php7Adapter to use shared memory on PHP 7.0+May 26, 2016
@tgalopin
Copy link
ContributorAuthor

I did some benchmarks to check the PHP 5.6 support in this PR.

I used three Docker containers with only PHP/HHVM installed, on the same host. I used Apache Benchmark with 1000 requests at a concurrency of 100 (ab -n 1000 -c 100).

The results are the following:

EngineContextTime per request
PHP 5.6Empty array0.953 ms/req
PHP 5.6Array with 15 000 keys4.671 ms/req
PHP 7.0Empty array0.688 ms/req
PHP 7.0Array with 15 000 keys0.709 ms/req
HHVM 3.12Empty array0.869 ms/req
HHVM 3.12Array with 15 000 keys0.875 ms/req

This seems to indicate that having an array filled with data in PHP 5.6 is significantly slower than having an empty array. Therefore, I removed the PHP 5.6 support for this PhpArrayAdapter in thecreate factory method (and I added the HHVM support).

@nicolas-grekas
Copy link
Member

👍

@tgalopintgalopinforce-pushed theopcache-adapter branch 6 times, most recently frombb8e068 toc507cc0CompareJune 27, 2016 13:05
@dunglas
Copy link
Member

👍

try {
$value = serialize($value);
} catch (\Exception $e) {
throw new InvalidArgumentException(sprintf('Cache key "%s has non-serializable %s value', $key, get_class($value)), 0, $e);
Copy link
Member

Choose a reason for hiding this comment

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

Missing closing double quote.

Copy link
Member

Choose a reason for hiding this comment

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

Also missing a dot at the end.

@tgalopin
Copy link
ContributorAuthor

I did the changes.

private $fallbackPool;

/**
* @param string $file The PHP file were values are cached.
Copy link
Member

Choose a reason for hiding this comment

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

dots at the end of@param (@return,@throws, ... as well) should be removed

@tgalopin
Copy link
ContributorAuthor

I did the change

@fabpot
Copy link
Member

Thank you@tgalopin.

@fabpotfabpot merged commit28a40d2 intosymfony:masterJun 28, 2016
fabpot added a commit that referenced this pull requestJun 28, 2016
…P 7.0 (tgalopin)This PR was merged into the 3.2-dev branch.Discussion----------[Cache] Add PhpArrayAdapter to use shared memory on PHP 7.0| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | WIP| Fixed tickets | -| License       | MIT| Doc PR        | -Depends on#18825This PR aims to implement a Symfony Cache adapter able to build files optimized for OPCache memory storage. Any kind of static data that can be warmed up is a candidate for OPcache storage.This PR is limited to the implementation of the Adapter. It's usage in the annotations caching system is implemented in the PR#18533. The aim is also to use this adapter in other contexts (validator, serializer, ...).Commits-------28a40d2 [Cache] Add PhpArrayAdapter to use shared memory on PHP 7.0+
@tgalopintgalopin deleted the opcache-adapter branchJune 28, 2016 10:06
fabpot added a commit that referenced this pull requestJul 30, 2016
…e warmer for annotations (tgalopin)This PR was squashed before being merged into the 3.2-dev branch (closes#18533).Discussion----------[FrameworkBundle] Wire PhpArrayAdapter with a new cache warmer for annotations| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | WIP| Fixed tickets | -| License       | MIT| Doc PR        | -Depends on#18825 and#18823This PR implements the usage of the new OpCacheAdapter in the annotations caching system. The idea to use this adapter as much as possible in Symfony (validator, serializer, ...). These other implementations will be the object of different PRs.Commits-------f950a2b [FrameworkBundle] Wire PhpArrayAdapter with a new cache warmer for annotations
symfony-splitter pushed a commit to symfony/cache that referenced this pull requestJul 30, 2016
…e warmer for annotations (tgalopin)This PR was squashed before being merged into the 3.2-dev branch (closes #18533).Discussion----------[FrameworkBundle] Wire PhpArrayAdapter with a new cache warmer for annotations| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | WIP| Fixed tickets | -| License       | MIT| Doc PR        | -Depends onsymfony/symfony#18825 andsymfony/symfony#18823This PR implements the usage of the new OpCacheAdapter in the annotations caching system. The idea to use this adapter as much as possible in Symfony (validator, serializer, ...). These other implementations will be the object of different PRs.Commits-------f950a2b [FrameworkBundle] Wire PhpArrayAdapter with a new cache warmer for annotations
symfony-splitter pushed a commit to symfony/http-kernel that referenced this pull requestJul 30, 2016
…e warmer for annotations (tgalopin)This PR was squashed before being merged into the 3.2-dev branch (closes #18533).Discussion----------[FrameworkBundle] Wire PhpArrayAdapter with a new cache warmer for annotations| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | WIP| Fixed tickets | -| License       | MIT| Doc PR        | -Depends onsymfony/symfony#18825 andsymfony/symfony#18823This PR implements the usage of the new OpCacheAdapter in the annotations caching system. The idea to use this adapter as much as possible in Symfony (validator, serializer, ...). These other implementations will be the object of different PRs.Commits-------f950a2b [FrameworkBundle] Wire PhpArrayAdapter with a new cache warmer for annotations
symfony-splitter pushed a commit to symfony/framework-bundle that referenced this pull requestJul 30, 2016
…e warmer for annotations (tgalopin)This PR was squashed before being merged into the 3.2-dev branch (closes #18533).Discussion----------[FrameworkBundle] Wire PhpArrayAdapter with a new cache warmer for annotations| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | WIP| Fixed tickets | -| License       | MIT| Doc PR        | -Depends onsymfony/symfony#18825 andsymfony/symfony#18823This PR implements the usage of the new OpCacheAdapter in the annotations caching system. The idea to use this adapter as much as possible in Symfony (validator, serializer, ...). These other implementations will be the object of different PRs.Commits-------f950a2b [FrameworkBundle] Wire PhpArrayAdapter with a new cache warmer for annotations
@fabpotfabpot mentioned this pull requestOct 27, 2016
weaverryan added a commit to symfony/symfony-docs that referenced this pull requestJan 28, 2017
…weaverryan)This PR was merged into the 3.2 branch.Discussion----------Covering two missing Cache adapters introduced in 3.2Hi guys!These are 2 missing adapters that were introduced in 3.2!symfony/symfony#18894 andsymfony/symfony#18823Cheers!Commits-------a3e69e2 Tweaks based on feedback!1b6cb69 Covering two missing adapters introduced in 3.2
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

10 participants

@tgalopin@nicolas-grekas@fabpot@dunglas@stof@OskarStark@phansys@xabbuh@javiereguiluz@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp