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

[Routing] serialize the compiled route to speed things up #12329

Merged
merged 1 commit into from Oct 28, 2014

Conversation

Tobion
Copy link
Member

@Tobion Tobion commented Oct 27, 2014

Q A
Bug fix? no
New feature? not really
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #12012, #12220
License MIT
Doc PR -

This also makes the CompiledRoute implement Serializable in order to:

  1. make the serialization format shorter
  2. have no null bytes in there, which the native serializer add for private properties, and thus would complicate saving in databases etc.
  3. Since the Route now includes the CompiledRoute in the serialization, the CompiledRoute serialization must be consistent as well. We can only ensure that in future symfony version by implementing Serializable.

We should add to our symfony BC promise, that only classes that implement Serializable are ensured to be deserializable correctly with serialized representations of the class in previous symfony versions.

'tokens' => $this->tokens,
'staticPrefix' => $this->staticPrefix,
'regex' => $this->regex,
'pathVariables' => $this->pathVariables,
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 use underscore names as this is what we are using everywhere else for array keys?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

* Tests that the compiled version is also serialized to prevent the overhead
* of compiling it again after unserialize.
*/
public function testSerializeWhenCompiled()
Copy link
Contributor

Choose a reason for hiding this comment

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

I am a bit confused about that test. As far as I read this test, I am pretty sure it should have passed without the actual patch as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes it's not to test the compiled but it ensures that we don't break the deserialization in the future.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh wait, I thought you commented on testSerializedRepresentationKeepsWorking.

No the test does not pass without the patch because then the compiled attributes are not equal and thus the routes are not equal.

This also makes the CompiledRoute implement Serializable in order to:
1. make the serialization format shorter
2. have no null bytes in there, which the native serializer add for private properties, and thus would complicate saving in databases etc.
3. We should add to our symfony BC promise, that only classes that implement Serializable are ensured to be deserializable correctly with serialized representations of the class in previous symfony versions.
@@ -105,12 +108,16 @@ public function serialize()
'options' => $this->options,
'schemes' => $this->schemes,
'methods' => $this->methods,
'compiled' => $this->compiled,
Copy link
Member Author

Choose a reason for hiding this comment

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

@fabpot this will conflict with newer branches that have a condition, so you are aware when merging.

@fabpot
Copy link
Member

fabpot commented Oct 28, 2014

Thank you @Tobion.

@fabpot fabpot merged commit fd88de7 into symfony:2.3 Oct 28, 2014
fabpot added a commit that referenced this pull request Oct 28, 2014
…(Tobion)

This PR was merged into the 2.3 branch.

Discussion
----------

[Routing] serialize the compiled route to speed things up

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | not really
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #12012, #12220
| License       | MIT
| Doc PR        | -

This also makes the CompiledRoute implement Serializable in order to:

1. make the serialization format shorter
2. have no null bytes in there, which the native serializer add for private properties, and thus would complicate saving in databases etc.
3.  Since the Route now includes the CompiledRoute in the serialization, the CompiledRoute serialization must be consistent as well. We can only ensure that in future symfony version by implementing Serializable.

We should add to our symfony BC promise, that only classes that implement Serializable are ensured to be deserializable correctly with serialized representations of the class in previous symfony versions.

Commits
-------

fd88de7 [Routing] serialize the compiled route to speed things up
@Tobion Tobion deleted the route-serialize-compiled branch October 28, 2014 18:14
@xabbuh xabbuh mentioned this pull request Nov 3, 2014
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.

None yet

3 participants