candlepin/candlepin — pull request #129 by dgoodwin (2012-12-05 15:03:38+00:00)
Title: Overconsumption check performance fix.

Following a bind we check all pools that potentially may have been
modified during the bind to see if any are now oversubscribed. Currently
this is just to accomodate hosted binds to virt_limit pools when the
consumer is a manifest consumer. In this future this is probably going
to be used in other cases as well.

On-site, with virt bonus pools, we were looking at ~10k entitlements
from a virt_limit pool, plus one pool per entitlement for the host
restricted guest pools. This resulted in gradual performance
degredation, at the 10k mark a bind was taking about 20s.

Using some knowledge of what pools could actually be changed as the
result of a bind (or a modify entitlement quantity), we know that we
only need to check pools where the source entitlement is null (i.e. virt
bonus pools in hosted, at most 2), or the source entitlement is the
entitlement being granted/modified (at most 1). This cuts a massive
amount of data churn down to just a max of around 2 pools and eliminates
90% of the time spent in the bind operation.

After this bind should not experience any degredation as the number of
entitlements to the pool grows.

Conflicts:
src/main/java/org/candlepin/controller/CandlepinPoolManager.java