Skip to content
This repository has been archived by the owner on Nov 9, 2020. It is now read-only.

Optimize vmdkops_admin ls operation #1867

Merged
merged 1 commit into from
Sep 7, 2017

Conversation

shaominchen
Copy link
Contributor

@shaominchen shaominchen commented Sep 5, 2017

Fixes issue #1858: Optimize vmdkops_admin.get_policy() function. The fix is to cache vSAN datastore managed object. The vSAN datastore should be preconfigured, so it doesn't make sense to fetch it every time, which is extremely time consuming. Please refer to the last 2 comments in issue #1083 for more detailed analysis.

Here's a comparison before and after the fix being applied (time in seconds):

Volume Number Before Fix After Fix
100 9.854 2.996
200 14.053 4.743
400 23.991 8.554
500 28.787 10.493
600 36.201 12.267
800 47.249 16.886
1000 57.168 21.483

As we can see, the performance was improved significantly. Even though for very large number of volumes (>1000), it's still a bit slow, but at least it's reasonably acceptable now if volume number is less than 500.

Copy link
Contributor

@msterin msterin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice patch !
A few questions. Only #1 needs answer before LGTM from me.
(1) did you test if it works after vsanDatastore rename? I think it should as the URL/UUID won't change, but would be good to double check
(2) what happens if there re 2 vsanDatastores ? In 6.5 it was added for VMC (vshere on AWS) and is a hidden feature. It could be a separate issues/PR, but this PR seems like a good place to take a look at least
(3) Do we know what takes the rest of the time ?
(4) why did you decide to put in in is_vsan() , and not in get_vsan_datastore() ?

@shaominchen
Copy link
Contributor Author

shaominchen commented Sep 6, 2017

@msterin Thanks for the review! To answer your questions:

  1. Yes, it works. I verified with these steps:
    1. Create a vol at vsanDatastore
    2. Run "docker volume ls" and "vmdkops_admin volume ls"
    3. Rename vsanDatastore to vsanDS
    4. Run "docker volume ls" and "vmdkops_admin volume ls"
    5. Try to create a vol at vsanDatastore - fail
      All above steps got expected result.
  2. I don't have the environment right now, will check if I can set up one to verify that.
  3. Yes - issue Optimize vmdkops_admin.get_metadata() function #1859. Please see my last 2 comments in issue Admin cli volume ls is slow if there are large number of volumes #1083 for more detailed analysis.
  4. Two reasons:
    1. Logically I feel it's more natural (and clean) to patch in is_on_vsan()
    2. The optimization effect is better to patch in is_on_vsan(). If we patch in get_vsan_datastore - let's say cache "si" and/or "stores" instance, the remaining logic is still an unnecessary waste, even if it's trivial.

@shaominchen
Copy link
Contributor Author

BTW, CI failure is due to issue #1864.

Copy link
Contributor

@govint govint left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this issue get repro'ed on VMFS also? Earlier, I'd tested this config and it used to take a long time on vmfs.

return False
global _vsan_ds
if not _vsan_ds:
_vsan_ds = get_vsan_datastore()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the service starts it calls init_datastoreCache(), can't the datastore type be be cached in that map as well in addition to the name, URL and dockvols path? This code path of is_vsan_datastore() seems to be extra when we have a DS cache already.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree it's possible to improve&reuse existing datastore cache. Some minor concerns:

  1. Adding a new entry to existing datastore cache might break existing code paths, so we need thorough regression test
  2. The existing datastore cache is not very well encapsulated. The init_datastoreCache() is being called in multiple places. Ideally this should be avoided.

To reuse this cache, I will need to refactor existing implementation to improve the encapsulation and make it more robust. Otherwise I will have to call init_datastoreCache() in one more code path, which is really something I want to avoid.

Both are not critical concerns though. But it just means much more work to do. Considering that the current vsan_info.py is a module specifically for VSAN, I feel it's acceptable to maintain this minor cache in this module. So personally I don't have strong motivation to switch to the global datastore cache right now. Let me know what you think.

@shaominchen
Copy link
Contributor Author

@govint Thanks for the review! Yes, this issue get reproduced on VMFS as well. Actually it doesn't matter if the volumes are created on VMFS or VSAN datastore. The logic get_policy/is_on_vsan/get_vsan_datastore is always invoked as part of generate_ls_rows workflow.

@shaominchen
Copy link
Contributor Author

shaominchen commented Sep 6, 2017

@msterin Regarding your 2nd question, what I can do is to add a new VSAN cluster to get the 2nd VSAN datastore. However, I can't add the same host to two different VSAN clusters. So for the docker hosts (VMs) in one host, I can only create volumes on the attached VSAN datastore only. The other VSAN datastore which belongs to a different cluster is not visible/accessible to the docker hosts (VMs) in the current VSAN cluster.

@shaominchen shaominchen merged commit 79b2cca into vmware-archive:master Sep 7, 2017
@shaominchen shaominchen deleted the issue_1858 branch September 7, 2017 16:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants