View | Details | Raw Unified | Return to bug 28833
Collapse All | Expand All

(-)a/C4/HoldsQueue.pm (-13 / +40 lines)
Lines 170-175 Top level function that turns reserves into tmp_holdsqueue and hold_fill_targets Link Here
170
sub CreateQueue {
170
sub CreateQueue {
171
    my $params      = shift;
171
    my $params      = shift;
172
    my $unallocated = $params->{unallocated};
172
    my $unallocated = $params->{unallocated};
173
    my $loops       = $params->{loops} || 1;
173
    my $dbh         = C4::Context->dbh;
174
    my $dbh         = C4::Context->dbh;
174
175
175
    unless ($unallocated) {
176
    unless ($unallocated) {
Lines 187-193 sub CreateQueue { Link Here
187
    my $use_transport_cost_matrix = C4::Context->preference("UseTransportCostMatrix");
188
    my $use_transport_cost_matrix = C4::Context->preference("UseTransportCostMatrix");
188
    if ($use_transport_cost_matrix) {
189
    if ($use_transport_cost_matrix) {
189
        $transport_cost_matrix = TransportCostMatrix();
190
        $transport_cost_matrix = TransportCostMatrix();
190
        unless (keys %$transport_cost_matrix) {
191
        unless ( keys %$transport_cost_matrix ) {
191
            warn "UseTransportCostMatrix set to yes, but matrix not populated";
192
            warn "UseTransportCostMatrix set to yes, but matrix not populated";
192
            undef $transport_cost_matrix;
193
            undef $transport_cost_matrix;
193
        }
194
        }
Lines 197-221 sub CreateQueue { Link Here
197
198
198
    my $bibs_with_pending_requests = GetBibsWithPendingHoldRequests();
199
    my $bibs_with_pending_requests = GetBibsWithPendingHoldRequests();
199
200
200
    foreach my $biblionumber (@$bibs_with_pending_requests) {
201
    # Split the list of bibs into chunks to run in parallel
202
    my @chunks;
203
    if ( $loops > 1 ) {
204
        my $i = 0;
205
        while (@$bibs_with_pending_requests) {
206
            push( @{ $chunks[$i] }, pop(@$bibs_with_pending_requests) );
201
207
202
        $total_bibs++;
208
            $i++;
209
            $i = 0 if $i >= $loops;
210
        }
203
211
204
        my $result = update_queue_for_biblio(
212
        my $pm = Parallel::ForkManager->new($loops);
205
            {
213
206
                biblio_id             => $biblionumber,
214
    DATA_LOOP:
207
                branches_to_use       => $branches_to_use,
215
        foreach my $chunk (@chunks) {
208
                transport_cost_matrix => $transport_cost_matrix,
216
            my $pid = $pm->start and next DATA_LOOP;
209
                unallocated           => $unallocated
217
            foreach my $biblionumber (@$chunk) {
218
                update_queue_for_biblio(
219
                    {
220
                        biblio_id             => $biblionumber,
221
                        branches_to_use       => $branches_to_use,
222
                        transport_cost_matrix => $transport_cost_matrix,
223
                        unallocated           => $unallocated
224
                    }
225
                );
210
            }
226
            }
211
        );
227
            $pm->finish;
228
        }
212
229
213
        $total_requests        += $result->{requests};
230
        $pm->wait_all_children;
214
        $total_available_items += $result->{available_items};
231
    } else {
215
        $num_items_mapped      += $result->{mapped_items};
232
        foreach my $biblionumber (@$bibs_with_pending_requests) {
233
            update_queue_for_biblio(
234
                {
235
                    biblio_id             => $biblionumber,
236
                    branches_to_use       => $branches_to_use,
237
                    transport_cost_matrix => $transport_cost_matrix,
238
                    unallocated           => $unallocated
239
                }
240
            );
241
        }
216
    }
242
    }
217
}
243
}
218
244
245
219
=head2 GetBibsWithPendingHoldRequests
246
=head2 GetBibsWithPendingHoldRequests
220
247
221
  my $biblionumber_aref = GetBibsWithPendingHoldRequests();
248
  my $biblionumber_aref = GetBibsWithPendingHoldRequests();
(-)a/installer/data/mysql/atomicupdate/bug_28833.perl (+9 lines)
Line 0 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
    $dbh->do(q{
4
        INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
5
        ('HoldsQueueParallelLoopsCount', '1', NULL, 'Number of parallel loops to use when running the holds queue builder', 'Integer');
6
    });
7
8
    NewVersion( $DBversion, 28833, "Speed up holds queue builder via parallel processing");
9
}
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 302-307 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
302
('HoldsAutoFillPrintSlip','0',NULL,'If on, hold slip print dialog will be displayed automatically','YesNo'),
302
('HoldsAutoFillPrintSlip','0',NULL,'If on, hold slip print dialog will be displayed automatically','YesNo'),
303
('HoldsLog','0',NULL,'If ON, log create/cancel/suspend/resume actions on holds.','YesNo'),
303
('HoldsLog','0',NULL,'If ON, log create/cancel/suspend/resume actions on holds.','YesNo'),
304
('HoldsNeedProcessingSIP', '0', NULL, 'Require staff to check-in before hold is set to waiting state', 'YesNo' ),
304
('HoldsNeedProcessingSIP', '0', NULL, 'Require staff to check-in before hold is set to waiting state', 'YesNo' ),
305
('HoldsQueueParallelLoopsCount', '1', NULL, 'Number of parallel loops to use when running the holds queue builder', 'Integer'),
305
('HoldsQueuePrioritizeBranch','homebranch','holdingbranch|homebranch','Decides if holds queue builder patron home library match to home or holding branch','Choice'),
306
('HoldsQueuePrioritizeBranch','homebranch','holdingbranch|homebranch','Decides if holds queue builder patron home library match to home or holding branch','Choice'),
306
('HoldsQueueSkipClosed', '0', NULL, 'If enabled, any libraries that are closed when the holds queue is built will be ignored for the purpose of filling holds.', 'YesNo'),
307
('HoldsQueueSkipClosed', '0', NULL, 'If enabled, any libraries that are closed when the holds queue is built will be ignored for the purpose of filling holds.', 'YesNo'),
307
('HoldsSplitQueue','nothing','nothing|branch|itemtype|branch_itemtype','In the staff interface, split the holds view by the given criteria','Choice'),
308
('HoldsSplitQueue','nothing','nothing|branch|itemtype|branch_itemtype','In the staff interface, split the holds view by the given criteria','Choice'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+5 lines)
Lines 74-79 Circulation: Link Here
74
            - pref: HoldsToPullStartDate
74
            - pref: HoldsToPullStartDate
75
              class: integer
75
              class: integer
76
            - day(s) ago. Note that the default end date is controlled by the system preference <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=ConfirmFutureHolds">ConfirmFutureHolds</a>.
76
            - day(s) ago. Note that the default end date is controlled by the system preference <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=ConfirmFutureHolds">ConfirmFutureHolds</a>.
77
        -
78
            - When building the holds queue, calculate hold matches using
79
            - pref: HoldsQueueParallelLoopsCount
80
              class: integer
81
            - parallel loop(s). The more loops used, the faster it will calculate and the more computing resources it will use.
77
        -
82
        -
78
            - pref: AllowAllMessageDeletion
83
            - pref: AllowAllMessageDeletion
79
              choices:
84
              choices:
(-)a/misc/cronjobs/holds/build_holds_queue.pl (-2 / +2 lines)
Lines 85-90 if ( $rthq && !$force ) { Link Here
85
85
86
cronlogaction( { info => $command_line_options } );
86
cronlogaction( { info => $command_line_options } );
87
87
88
CreateQueue( { unallocated => $unallocated } );
88
my $loops = C4::Context->preference('HoldsQueueParallelLoopsCount');
89
CreateQueue( { loops => $loops, unallocated => $unallocated } );
89
90
90
cronlogaction( { action => 'End', info => "COMPLETED" } );
91
cronlogaction( { action => 'End', info => "COMPLETED" } );
91
- 

Return to bug 28833