Bugzilla – Attachment 28628 Details for
Bug 12347
Search performance improvements
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12347: Performance improvements in Search.pm
Bug-12347-Performance-improvements-in-Searchpm.patch (text/plain), 4.61 KB, created by
Tomás Cohen Arazi (tcohen)
on 2014-06-02 23:10:45 UTC
(
hide
)
Description:
Bug 12347: Performance improvements in Search.pm
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2014-06-02 23:10:45 UTC
Size:
4.61 KB
patch
obsolete
>From 1fa50c9a29f829d9a712f9fcf208ea12745dac73 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@gmail.com> >Date: Mon, 26 May 2014 15:44:54 -0300 >Subject: [PATCH] Bug 12347: Performance improvements in Search.pm > >Short: some costly stuff is done twice, this patch refactors that to make it >more reasonable. > >Long: Bug 11096 introduced a noticeable overhead to the facet building stage >of the getRecords code. This patch leverages it by propagating the MARC::Record >objects created upon facet building, and reusing them in the C4::Search::searchResults >function. > >To test: >- Search for a term on master >- Apply the patch >- Same results > >Unit tests reflecting API change in a separate patch. > >Regards >To+ > >Sponsored-by: Universidad Nacional de Cordoba >--- > C4/Search.pm | 51 +++++++++++++++++++++------------------------------ > 1 file changed, 21 insertions(+), 30 deletions(-) > >diff --git a/C4/Search.pm b/C4/Search.pm >index 748bb1c..beef11d 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -485,18 +485,27 @@ sub getRecords { > $tmprecord->append_fields($tmptitle); > $tmprecord->append_fields($tmpauthor); > } >- $results_hash->{'RECORDS'}[$j] = >- $tmprecord->as_usmarc(); >+ $results_hash->{'RECORDS'}[$j] = $tmprecord; > } > > # not an index scan > else { >- $record = $results[ $i - 1 ]->record($j)->raw(); >- # warn "RECORD $j:".$record; >+ $record = new_record_from_zebra ( >+ 'biblioserver', >+ $results[ $i - 1 ]->record($j)->raw() >+ ); >+ >+ if ( ! defined $record ) { >+ warn "ERROR DECODING RECORD - $@: " . >+ $results[ $i - 1 ]->record($j)->raw(); >+ next; >+ } >+ > $results_hash->{'RECORDS'}[$j] = $record; > } > > } >+ > $results_hashref->{ $servers[ $i - 1 ] } = $results_hash; > > # Fill the facets while we're looping, but only for the biblioserver and not for a scan >@@ -507,16 +516,10 @@ sub getRecords { > for my $facet (@$facets) { > for ( my $j = 0 ; $j < $jmax ; $j++ ) { > >- my $marc_record = new_record_from_zebra ( >- 'biblioserver', >- $results[ $i - 1 ]->record($j)->raw() >- ); >- >- if ( ! defined $marc_record ) { >- warn "ERROR DECODING RECORD - $@: " . >- $results[ $i - 1 ]->record($j)->raw(); >- next; >- } >+ my $marc_record = >+ $results_hashref->{ $servers[ $i - 1 ] }->{'RECORDS'}[$j]; >+ # we skip bad records >+ next if ( !defined $marc_record ); > > my @used_datas = (); > >@@ -528,6 +531,7 @@ sub getRecords { > # Removed when as_string fixed > my @subfields = $subfield_letters =~ /./sg; > >+ # Check $tag_num is a valid field for $marc_record > my @fields = $marc_record->field($tag_num); > foreach my $field (@fields) { > my $data = $field->as_string( $subfield_letters, $facet->{sep} ); >@@ -1715,22 +1719,9 @@ sub searchResults { > # loop through all of the records we've retrieved > for ( my $i = $offset ; $i <= $times - 1 ; $i++ ) { > >- my $marcrecord; >- if ($scan) { >- # For Scan searches we built USMARC data >- $marcrecord = MARC::Record->new_from_usmarc( $marcresults->[$i]); >- } else { >- # Normal search, render from Zebra's output >- $marcrecord = new_record_from_zebra( >- 'biblioserver', >- $marcresults->[$i] >- ); >- >- if ( ! defined $marcrecord ) { >- warn "ERROR DECODING RECORD - $@: " . $marcresults->[$i]; >- next; >- } >- } >+ my $marcrecord = $marcresults->[$i]; >+ # we skip bad records >+ next if ( !defined $marcrecord ); > > my $fw = $scan > ? undef >-- >1.9.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12347
:
28623
|
28627
| 28628