Bug 1431578

Summary: improve V3 performance of retrieving VM disks
Product: [oVirt] ovirt-engine Reporter: Oved Ourfali <oourfali>
Component: RestAPIAssignee: Juan Hernández <juan.hernandez>
Status: CLOSED CURRENTRELEASE QA Contact: Aleksei Slaikovskii <aslaikov>
Severity: high Docs Contact:
Priority: unspecified    
Version: 4.1.0CC: bugs, lveyde
Target Milestone: ovirt-4.1.2Keywords: Improvement, Performance
Target Release: 4.1.2Flags: rule-engine: ovirt-4.1+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-05-23 08:22:40 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Infra RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Oved Ourfali 2017-03-13 10:46:18 UTC
Currently when version 3 of the API is used to request the disks of a
virtual machine, the API uses the GetAllDisksByVmId query, which in turn
uses the GetDisksbyVmGuid stored procedure to retrive the disks. In
addition this query, for each disk, calls the GetSnapshotByLeafGuid
stored procedure, to retrieve snapshot details, and the
GetDiskVmElementVyDiskVmElementId, to get attachment details. The
GetSnapshotByLeafGuid stored procedure is complex, and consumes a
important amount of database time. Version 4 of the API uses lighter
stored procedures. This patch changes the V3 compatibility layer of the
API so that it calls the V4 disk attachments and disk resources instead
of using the GetAllDisksByVmId query. In an otherwise idle enviroment
with approxy 4000 virtual machines this reduces the total use of CPU
(85% database + 15% engine) from 57 minutes to 14 minutes.

Reproducer:

This can be reproduced using the following Ruby script, which uses the
'ovirt' gem to retrieve the virtual machines and their disks:

  require 'active_support/all'
  require 'ovirt'

  service = Ovirt::Service.new(
    server: 'rhvm41.local',
    port: 443,
    domain: 'internal',
    username: 'admin',
    password: '...',
    verify_ssl: false,
    timeout: 1.hour
  )

  vms = Ovirt::Vm.all(service)

  vms.each do |vm|
    vm.disks.each do |disk|
      puts "#{vm[:name]}: #{disk[:name]}"
    end
  end

  service.disconnect

Comment 1 Aleksei Slaikovskii 2017-05-03 15:29:22 UTC
Verified on ovirt-engine-4.1.2-0.1.el7.noarch

6 vms:
4.1.1.2-0.1.el7 time: 3.567 sec
4.1.2-0.1.el7 time: 1.735 sec