-
Notifications
You must be signed in to change notification settings - Fork 292
CP-52880: Avoid O(N^2) behaviour in Xapi_vdi.update_allowed_operations #6183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5412b88
CP-52880: benchmark for Xapi_vdi.update_allowed_operations
edwintorok 5b52598
CP-52880: optimize List manipulation
edwintorok 49400e4
CP-52880: Use a Set instead of a list for checking VDI operations
edwintorok 8bd5737
CP-52880: change order of short-circuited boolean operator argument
edwintorok 50a39d7
CP-52880: Avoid O(N^2) behaviour in Xapi_vdi.update_allowed_operations
edwintorok File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
open Bechamel | ||
|
||
module D = Debug.Make (struct let name = __MODULE__ end) | ||
|
||
(* tested configuration limits *) | ||
let max_hosts = 64 | ||
|
||
let max_vms = (*2400*) 240 | ||
|
||
let max_vbds = (* 255 *) 25 | ||
|
||
let () = | ||
(* a minimal harness init *) | ||
Suite_init.harness_init () ; | ||
(* don't spam the logs in [allocate] *) | ||
Debug.set_level Syslog.Info | ||
|
||
let allocate () = | ||
let open Test_common in | ||
let __context = make_test_database () in | ||
let (_sm_ref : API.ref_SM) = make_sm ~__context () in | ||
let sr_ref = make_sr ~__context () in | ||
let (_ : API.ref_PBD array) = | ||
Array.init max_hosts (fun _ -> make_pbd ~__context ~sR:sr_ref ()) | ||
in | ||
let vms = | ||
Array.init max_vms @@ fun _ -> | ||
let vm_ref = make_vm ~__context () in | ||
Array.init (max_vbds / 2) @@ fun _ -> | ||
let vdi_ref = make_vdi ~__context ~sR:sr_ref () in | ||
let vbd_ref = | ||
make_vbd ~__context ~vDI:vdi_ref ~vM:vm_ref ~currently_attached:true | ||
~mode:`RO () | ||
in | ||
let vdi_ref' = make_vdi ~__context ~sR:sr_ref () in | ||
let vbd_ref' = | ||
make_vbd ~__context ~vDI:vdi_ref' ~vM:vm_ref ~currently_attached:true | ||
~mode:`RW () | ||
in | ||
(vdi_ref, vbd_ref, vdi_ref', vbd_ref') | ||
in | ||
D.info "Created test database" ; | ||
(__context, vms) | ||
|
||
let test_vdi_update_allowed_operations (__context, vm_disks) = | ||
let _, _, vdi_ref, vbd_ref = vm_disks.(0).(0) in | ||
Db.VBD.set_currently_attached ~__context ~self:vbd_ref ~value:true ; | ||
Xapi_vdi.update_allowed_operations ~__context ~self:vdi_ref ; | ||
Db.VBD.set_currently_attached ~__context ~self:vbd_ref ~value:false ; | ||
Xapi_vdi.update_allowed_operations ~__context ~self:vdi_ref | ||
|
||
let benchmarks = | ||
Test.make_grouped ~name:"update_allowed_operations" | ||
[ | ||
Test.make_with_resource ~name:"VDI" ~allocate ~free:ignore Test.uniq | ||
(Staged.stage test_vdi_update_allowed_operations) | ||
] | ||
|
||
let () = Bechamel_simple_cli.cli benchmarks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,21 @@ | ||
(executables | ||
(names bench_tracing bench_uuid bench_throttle2 bench_cached_reads) | ||
(libraries tracing bechamel bechamel-notty notty.unix tracing_export threads.posix fmt notty uuid xapi_aux tests_common log xapi_internal) | ||
) | ||
(names | ||
bench_tracing | ||
bench_uuid | ||
bench_throttle2 | ||
bench_cached_reads | ||
bench_vdi_allowed_operations) | ||
(libraries | ||
tracing | ||
bechamel | ||
bechamel-notty | ||
notty.unix | ||
tracing_export | ||
threads.posix | ||
fmt | ||
notty | ||
uuid | ||
xapi_aux | ||
tests_common | ||
log | ||
xapi_internal)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.