Ticket #671: d8af1fde685626283826ecaf52d4ac49cebdea98.patch

File d8af1fde685626283826ecaf52d4ac49cebdea98.patch, 2.5 KB (added by Olly Betts, 10 years ago)

super hacky patch from github

  • xapian-core/common/io_utils.cc

    From d8af1fde685626283826ecaf52d4ac49cebdea98 Mon Sep 17 00:00:00 2001
    From: Will Greenberg <will@endlessm.com>
    Date: Mon, 16 Mar 2015 17:56:38 -0700
    Subject: [PATCH] Really gross fix for sharded db performance
    
    ---
     xapian-core/common/io_utils.cc    | 12 ++++++++++++
     xapian-core/common/io_utils.h     |  2 ++
     xapian-core/matcher/multimatch.cc | 10 ++++++++++
     3 files changed, 24 insertions(+)
    
    diff --git a/xapian-core/common/io_utils.cc b/xapian-core/common/io_utils.cc
    index fefef8e..2f6e7ac 100644
    a b throw_block_error(const char * s, off_t b, int e)  
    104104    throw Xapian::DatabaseError(m, e);
    105105}
    106106
     107// dirty dirty hack that turns all preads into readaheads; preempts heavy disk
     108// io operations
     109bool IS_READAHEAD = false;
     110void set_readahead(bool val) {
     111    IS_READAHEAD = val;
     112}
     113
    107114void
    108115io_read_block(int fd, char * p, size_t n, off_t b)
    109116{
    io_read_block(int fd, char * p, size_t n, off_t b)  
    113120    // per block read.
    114121#ifdef HAVE_PREAD
    115122    while (true) {
     123        if (IS_READAHEAD) {
     124            // readahead has reversed order of parameters to pread, for some reason...
     125            readahead(fd, o, n);
     126            return;
     127        }
    116128        ssize_t c = pread(fd, p, n, o);
    117129        // We should get a full read most of the time, so streamline that case.
    118130        if (usual(c == ssize_t(n)))
  • xapian-core/common/io_utils.h

    diff --git a/xapian-core/common/io_utils.h b/xapian-core/common/io_utils.h
    index 89d5d46..5c728dd 100644
    a b inline bool io_sync(int fd)  
    4747#endif
    4848}
    4949
     50void set_readahead(bool val);
     51
    5052inline bool io_full_sync(int fd)
    5153{
    5254#ifdef F_FULLFSYNC
  • xapian-core/matcher/multimatch.cc

    diff --git a/xapian-core/matcher/multimatch.cc b/xapian-core/matcher/multimatch.cc
    index ef8525e..5bb096b 100644
    a b  
    3232#include "debuglog.h"
    3333#include "submatch.h"
    3434#include "localsubmatch.h"
     35#include "io_utils.h"
    3536#include "omassert.h"
    3637#include "api/omenquireinternal.h"
    3738#include "realtime.h"
    MultiMatch::MultiMatch(const Xapian::Database &db_,  
    350351    }
    351352
    352353    stats.set_query(query);
     354
     355    set_readahead(true);
     356    // readahead all the blocks we're about to read
     357        for (size_t leaf = 0; leaf < leaves.size(); ++leaf) {
     358                SubMatch * submatch = leaves[leaf].get();
     359                submatch->prepare_match(true, stats);
     360    }
     361    set_readahead(false);
     362
    353363    prepare_sub_matches(leaves, errorhandler, stats);
    354364    stats.set_bounds_from_db(db);
    355365}