-
Notifications
You must be signed in to change notification settings - Fork 251
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
UniqueIndex query performance improvement #106
Comments
Merged! I like that pull request, nice work! I made some minor adjustments:
Can you re-test with the latest code? |
It's now Ok, but not perfect :) I've updated my tests a bit here in case you'll need it. Let's consider following timings
It's definitely would not work now, but would save another 0.140 us/op and we will be pretty close to HashTest.queryHash timings.
And this is rather expensive for this kind of queries. I guess It's unfixable in current version. I'd have in QueryOptions fields instead of storing in hash flags and options that are known at compile time. This would definitely faster. For now I'm just checking those option and flag already present in the query - it's a bit faster than putting them to map. |
Add pull request #107 Thank you for your time. |
Thanks for the additional suggestions. Re: Change 1 - this would need to be in the retrieveRecursive() method instead of the retrieve() method, in order for it to work with nested queries. Re: Change 2 - I created an experimental branch to see if we could measure the performance difference by not allocating HashMaps in QueryOptions. It's a work in progress: https://github.com/npgall/cqengine/blob/optimize-query-options/code/src/main/java/com/googlecode/cqengine/query/option/QueryOptions.java |
Re: Re: Change 1 - this would need to be in the retrieveRecursive() method instead of the retrieve() method, in order for it to work with nested queries nested queries works well as it's properly handled in getResultSetWithLowestRetrievalCost() which is called from retrieveRecursive() |
I've experimented further based on the idea from your optiize-query-options branch.
As you could see, latest commits most win when not cache query option object. |
We can't represent all of the flags as an enum actually, because we need to allow for extensibility. Several companies using CQEngine (mine included) have their own implementations of indexes and queries, and we need a way to allow index-specific flags to be set, where we don't know the keys in advance. I have been reconsidering the approach I took in the branch actually. Mainly because of backward compatibility and the number of API changes involved. I think another option may be to provide a QueryOptions.reset() method, to allow QueryOption objects to be recycled between requests instead. The reset() method would remove request-specific parameters, but would leave existing but empty HashMap and FlagsEnabled objects in place. This way we could avoid the need for new objects to be allocated each time. I'll see if I can create a branch to test this. |
I agree about compatibility, but I'm afraid it's hard to get top values with hash (with reset as well). |
That's a good point about HashEntry/Node objects. I'll prepare a different branch so we can test it. It would be nice to find a way to avoid the HashEntry allocations. EDIT: relevant: http://stackoverflow.com/questions/23828425/is-there-a-hashmap-implementation-in-java-that-produces-no-garbage |
Just a heads up that I've released CQEngine 2.9.1 which includes your first pull request and some of these performance improvements (many thanks!). |
Thank you on update and the time you spend on cqengine. |
Opened for discussion.
Please see details in pull request #105
The text was updated successfully, but these errors were encountered: