Skip to content

Improve vector source clear() performance #3013

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

Merged

Conversation

gberaudo
Copy link
Member

@gberaudo gberaudo commented Dec 5, 2014

Speeds up from 8 seconds to 350ms the clearing of 100'000 features.

This 24 times improvement is in part gained by dispatching a single clear event in spite of sending a removefeature event for each of the 100'000` features.

Three seconds speed up for clearing 100'000 features.
Three seconds speed up when clearing 100'000 features.
Clearing is now around 350ms.
@elemoine
Copy link
Member

elemoine commented Dec 5, 2014

This is a significant improvement! We need to have this.

The only problem is that it may break applications that expect a removefeature event every time a feature is removed from the source.

One option is to add an opt_fast option to the clear option. If it's not provided or false the behavior of clear would be the same as today. If it's true the fast path will be used.

@gberaudo
Copy link
Member Author

gberaudo commented Dec 5, 2014

@elemoine, I added the opt_fast option, a test case and some documentation to link to the clear method.

@@ -37,7 +37,15 @@ ol.source.VectorEventType = {
CHANGEFEATURE: 'changefeature',

/**
* Triggered when a clear is called on the source.
Copy link
Member

Choose a reason for hiding this comment

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

-> Triggered when the clear function is called on the source.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@elemoine
Copy link
Member

elemoine commented Dec 5, 2014

Minor comments, otherwise looks very good to me!

@gberaudo gberaudo force-pushed the performance_vector_source_clear branch from 85a0538 to e3947fb Compare December 5, 2014 17:06
@elemoine
Copy link
Member

elemoine commented Dec 5, 2014

LGTM.

@gberaudo
Copy link
Member Author

gberaudo commented Dec 8, 2014

@elemoine, please merge.

elemoine pushed a commit that referenced this pull request Dec 8, 2014
Improve vector source clear() performance
@elemoine elemoine merged commit bcd9837 into openlayers:master Dec 8, 2014
@elemoine
Copy link
Member

elemoine commented Dec 8, 2014

Thanks for updating the patch.

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.

2 participants