Look at reducing the runtime memory usage of the ValidatorFactory

Description

While profiling keycloak I noticed that the validator factory is using 3mb of heap memory, mostly in BeanMetaDataManager. It might be worth looking at trying to reduce this.

Environment

None

Activity

Show:

Gunnar Morling August 15, 2017 at 6:55 AM

Yeah, thanks a lot for reaching out, . It was a good opportunity for us to look into this kind of improvements and, thanks to Guillaume's work, things have nicely improved in HV 6.0.1. We also got some more ideas which we'll look into for upcoming releases.

Stuart Douglas August 13, 2017 at 11:48 PM

Thanks, this was not an urgent issue, just something that I noticed that I thought would be good for someone to look at (as reduction of memory usage in general will be a focus for us).

Guillaume Smet August 11, 2017 at 12:59 PM

I don't know how urgent this issue is to you.

We have released HV 6.0.1.Final and it will be a clear improvement on the version included in WildFly regarding the issue you reported.

If you want to benefit from the improvements, you can use the WildFly patch we have published here:


(we will release a patch for Beta1 with our next minor)

Considering your (lack of) usage of HV in Keycloak, it should be a drop in replacement, I don't expect any issue. We have integration tests running HV 6 on top of WF 10.1 and WF 11.0.

You can apply a patch file automatically when building using the WildFly Maven plugin: https://github.com/hibernate/hibernate-validator/blob/master/integration/pom.xml#L334 .

Guillaume Smet July 18, 2017 at 12:24 PM

Btw, quick explanation about why you are experiencing this issue so much: your bean contains a lot of properties and getters (think of RealmEntity for instance) and this is why it eats quite a lot of memory as metadata adds up.

I improved a few things here and there (the BeanMetaDataImpl instance of RealmEntity now takes 65 kB whereas it took 177 kB in your snapshot) but I'm wondering if we shouldn't take more drastic measures.

Will post something on hibernate-dev and add you in cc.

Guillaume Smet July 18, 2017 at 12:02 PM

Thanks for the snapshot.

FWIW, there are already some significant improvements in 6 but it looks like we still have some work to do on this front.

Fixed

Details

Assignee

Reporter

Participants

Guillaume Smet
Gunnar Morling
Stuart Douglas

Components

Fix versions

Priority

Created July 16, 2017 at 9:45 PM
Updated August 15, 2017 at 6:55 AM
Resolved August 3, 2017 at 9:12 AM