Profile of DBIx/Class/Relationship/CascadeActions.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For xt/tapper-mcp-scheduler-with-db-longrun.t
Run on Tue May 22 17:18:39 2012
Reported on Tue May 22 17:23:01 2012

Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/DBIx/Class/Relationship/CascadeActions.pm
Statements | Executed 10877 statements in 58.4ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
877 | 6 | 5 | 79.6ms | 98.6s | DBIx::Class::Relationship::CascadeActions::::updateDBIx::Class::Relationship::CascadeActions::update
1 | 1 | 1 | 16µs | 19µs | DBIx::Class::Relationship::CascadeActions::::BEGIN@4DBIx::Class::Relationship::CascadeActions::BEGIN@4
1 | 1 | 1 | 8µs | 90µs | DBIx::Class::Relationship::CascadeActions::::BEGIN@6DBIx::Class::Relationship::CascadeActions::BEGIN@6
1 | 1 | 1 | 7µs | 15µs | DBIx::Class::Relationship::CascadeActions::::BEGIN@5DBIx::Class::Relationship::CascadeActions::BEGIN@5
0 | 0 | 0 | 0s | 0s | DBIx::Class::Relationship::CascadeActions::::deleteDBIx::Class::Relationship::CascadeActions::delete

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package # hide from PAUSE
2 |  |  |  |  | DBIx::Class::Relationship::CascadeActions;
3 |  |  |  |  |
4 | 3 | 18µs | 2 | 21µs | # spent 19µs (16+2) within DBIx::Class::Relationship::CascadeActions::BEGIN@4 which was called: # once (16µs+2µs) by Class::C3::Componentised::ensure_class_loaded at line 4 use strict; # spent 19µs making 1 call to DBIx::Class::Relationship::CascadeActions::BEGIN@4 # spent 2µs making 1 call to strict::import
5 | 3 | 20µs | 2 | 23µs | # spent 15µs (7+8) within DBIx::Class::Relationship::CascadeActions::BEGIN@5 which was called: # once (7µs+8µs) by Class::C3::Componentised::ensure_class_loaded at line 5 use warnings; # spent 15µs making 1 call to DBIx::Class::Relationship::CascadeActions::BEGIN@5 # spent 8µs making 1 call to warnings::import
6 | 3 | 309µs | 2 | 173µs | # spent 90µs (8+82) within DBIx::Class::Relationship::CascadeActions::BEGIN@6 which was called: # once (8µs+82µs) by Class::C3::Componentised::ensure_class_loaded at line 6 use DBIx::Class::Carp; # spent 90µs making 1 call to DBIx::Class::Relationship::CascadeActions::BEGIN@6 # spent 82µs making 1 call to DBIx::Class::Carp::import
7 |  |  |  |  |
8 | 1 | 2µs |  |  | our %_pod_inherit_config =
9 |  |  |  |  | (
10 |  |  |  |  | class_map => { 'DBIx::Class::Relationship::CascadeActions' => 'DBIx::Class::Relationship' }
11 |  |  |  |  | );
12 |  |  |  |  |
13 |  |  |  |  | sub delete {
14 |  |  |  |  | my ($self, @rest) = @_;
15 |  |  |  |  | return $self->next::method(@rest) unless ref $self;
16 |  |  |  |  | # I'm just ignoring this for class deletes because hell, the db should
17 |  |  |  |  | # be handling this anyway. Assuming we have joins we probably actually
18 |  |  |  |  | # *could* do them, but I'd rather not.
19 |  |  |  |  |
20 |  |  |  |  | my $source = $self->result_source;
21 |  |  |  |  | my %rels = map { $_ => $source->relationship_info($_) } $source->relationships;
22 |  |  |  |  | my @cascade = grep { $rels{$_}{attrs}{cascade_delete} } keys %rels;
23 |  |  |  |  |
24 |  |  |  |  | if (@cascade) {
25 |  |  |  |  | my $guard = $source->schema->txn_scope_guard;
26 |  |  |  |  |
27 |  |  |  |  | my $ret = $self->next::method(@rest);
28 |  |  |  |  |
29 |  |  |  |  | foreach my $rel (@cascade) {
30 |  |  |  |  | if( my $rel_rs = eval{ $self->search_related($rel) } ) {
31 |  |  |  |  | $rel_rs->delete_all;
32 |  |  |  |  | } else {
33 |  |  |  |  | carp "Skipping cascade delete on relationship '$rel' - related resultsource '$rels{$rel}{class}' is not registered with this schema";
34 |  |  |  |  | next;
35 |  |  |  |  | }
36 |  |  |  |  | }
37 |  |  |  |  |
38 |  |  |  |  | $guard->commit;
39 |  |  |  |  | return $ret;
40 |  |  |  |  | }
41 |  |  |  |  |
42 |  |  |  |  | $self->next::method(@rest);
43 |  |  |  |  | }
44 |  |  |  |  |
45 |  |  |  |  | # spent 98.6s (79.6ms+98.5) within DBIx::Class::Relationship::CascadeActions::update which was called 877 times, avg 112ms/call: # 180 times (12.3ms+16.1s) by main::toggle_host_free at line 62 of xt/tapper-mcp-scheduler-with-db-longrun.t, avg 89.6ms/call # 147 times (17.3ms+18.5s) by Tapper::Schema::TestrunDB::Result::TestrunScheduling::mark_as_running at line 206 of Tapper/Schema/TestrunDB/Result/TestrunScheduling.pm, avg 126ms/call # 147 times (24.3ms+18.1s) by Tapper::MCP::Scheduler::Controller::mark_job_as_running at line 136 of lib/Tapper/MCP/Scheduler/Controller.pm, avg 123ms/call # 147 times (7.66ms+17.4s) by Tapper::Schema::TestrunDB::Result::Testrun::rerun at line 182 of Tapper/Schema/TestrunDB/Result/Testrun.pm, avg 118ms/call # 147 times (10.1ms+16.5s) by Tapper::Schema::TestrunDB::Result::TestrunScheduling::mark_as_running at line 205 of Tapper/Schema/TestrunDB/Result/TestrunScheduling.pm, avg 112ms/call # 109 times (7.90ms+12.0s) by Tapper::MCP::Scheduler::Algorithm::WFQ::update_queue at line 62 of lib/Tapper/MCP/Scheduler/Algorithm/WFQ.pm, avg 110ms/call sub update {
46 | 5992 | 39.3ms |  |  | my ($self, @rest) = @_;
47 |  |  |  |  | return $self->next::method(@rest) unless ref $self;
48 |  |  |  |  | # Because update cascades on a class *really* don't make sense!
49 |  |  |  |  |
50 |  |  | 877 | 3.66ms | my $source = $self->result_source; # spent 3.66ms making 877 calls to DBIx::Class::Row::result_source, avg 4µs/call
51 | 3698 | 10.6ms | 4575 | 20.7ms | my %rels = map { $_ => $source->relationship_info($_) } $source->relationships; # spent 13.7ms making 3698 calls to DBIx::Class::ResultSource::relationship_info, avg 4µs/call # spent 7.03ms making 877 calls to DBIx::Class::ResultSource::relationships, avg 8µs/call
52 |  |  |  |  | my @cascade = grep { $rels{$_}{attrs}{cascade_update} } keys %rels;
53 |  |  |  |  |
54 | 735 | 6.13ms |  |  | if (@cascade) {
55 |  |  | 294 | 57.5ms | my $guard = $source->schema->txn_scope_guard; # spent 56.6ms making 147 calls to DBIx::Class::Schema::txn_scope_guard, avg 385µs/call # spent 829µs making 147 calls to DBIx::Class::ResultSource::schema, avg 6µs/call
56 |  |  |  |  |
57 |  |  | 147 | 1.69ms | my $ret = $self->next::method(@rest); # spent 1.69ms making 147 calls to next::method, avg 12µs/call
58 |  |  |  |  |
59 |  |  |  |  | foreach my $rel (@cascade) {
60 |  |  |  |  | next if (
61 | 441 | 1.98ms |  |  | $rels{$rel}{attrs}{accessor}
62 |  |  |  |  | &&
63 |  |  |  |  | $rels{$rel}{attrs}{accessor} eq 'single'
64 |  |  |  |  | &&
65 |  |  |  |  | !exists($self->{_relationship_data}{$rel})
66 |  |  |  |  | );
67 |  |  |  |  | $_->update for grep defined, $self->$rel;
68 |  |  |  |  | }
69 |  |  |  |  |
70 |  |  | 147 | 17.7s | $guard->commit; # spent 17.7s making 147 calls to DBIx::Class::Storage::TxnScopeGuard::commit, avg 120ms/call
71 |  |  |  |  | return $ret;
72 |  |  |  |  | }
73 |  |  |  |  |
74 |  |  | 730 | 13.3ms | $self->next::method(@rest); # spent 13.3ms making 730 calls to next::method, avg 18µs/call
75 |  |  |  |  | }
76 |  |  |  |  |
77 | 1 | 8µs | 1 | 227µs | 1; # spent 227µs making 1 call to B::Hooks::EndOfScope::__ANON__[B/Hooks/EndOfScope.pm:26]