Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CP-51352: Compare before setting a new value in
last_active
Experimenting with xapi under different loads of `xe vm-list`s revealed that xapi often waits a considerable amount of time for the database lock. e.g. Attempting to start a VM under a constant load of 20 `xe vm-list`s can take up to 30s and the total amount of time that xapi requests would spend in `Db_actions.Session.set_last_active` would be close to 9s. It seems that each API call does a `Session_check.check` implicitly updating the last time the current session is been used. From what I gathered, this value is used for the garbage collection of session where the current default threshold value is 24 hours, `Xapi.globs.inactive_session_timeout`. To avoid holding the database lock to update the `last_active` field every time, this commit gets the current value of `last_active` and compares it with the current time. If the difference is greater than 10 minutes only then we set a new value in the field. Otherwise, we continue without writing in the database. This has the following improvement on the total time of `xe vm-start` under different loads: - 20 `xe vm-list`: - - Before: 30.670s | 30.086s | 30.958s | - - After: 28.185s | 28.383s | 28.909s | - 80 `xe vm-list`: - - Before: 2m38.425s | 2m43.539s | 2m39.045s | - - After: 1m46.266s | 1m49.327s | 1m36.825s | For smaller loads, the improvement is between 5-10%. Whereas for bigger loads, the improvement is much more visible. Signed-off-by: Gabriel Buica <[email protected]>
- Loading branch information