-
Notifications
You must be signed in to change notification settings - Fork 229
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
faster newInstance and setField via sun.misc.Unsafe #67
Conversation
Wow, this really looks promising. Unfortunately I can't get the tests to run! I'm using Oracle java 1.7 on a Ubuntu box. I think there is an error on line 24 of the UnsafeFieldSetterFactory. You should call But even after fixing this, many of the tests fail! |
All tests all passed now. Found many awfull code (seems like You doesn't care about thread-safety)... |
|
Tested this by selecting 1,000,000 rows from a H2 database and parsing into pojos. Your implementation seems to give a descent performance increase of about 10-15 %. We need to do something about the FactoryFacade class. The current implementation sets the setter-factories in the static constructor, which makes it hard to create unit testing that tests both the Unsafe-based implementation and the reflection-based implementation. Maybe each instance of Sql2o should have its own FactoryFacade? I can see what you mean about thread-safety in the PojoMetadata cache... That is not good! I will create a ticket about it and get it fixed. Did you find any other examples of non-threadsafe code? |
You doesn't need to unit-test whole DB->POJO sequence. Create unit-test against also current FactoryFacade is temporary solution, needs some refactoring.
Yes, FutureDetector as example. Actually I believe You need strong refactoring wich breaks some public API. I have a serious expirience in ORM development, also with dealing with JDBC "quirks" etc. Also I found some algoritmic bottlenecks wich is hard to resolve without some refactoring. |
just inherit and implement evaluate method
commited abstract thread-safe cache implementation |
@aaberg |
Merged! |
enjoy