lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael McCandless (JIRA)" <j...@apache.org>
Subject [jira] Commented: (LUCENE-2293) IndexWriter has hard limit on max concurrency
Date Mon, 15 Mar 2010 09:59:27 GMT

    [ https://issues.apache.org/jira/browse/LUCENE-2293?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12845263#action_12845263
] 

Michael McCandless commented on LUCENE-2293:
--------------------------------------------

bq.  For example, currently a nice optimization would be to store the first posting in the
PostingList object and only allocate slices once you see the second occurrence (similar to
the pulsing codec)?

I think we can do even better, ie, that class wastes RAM for the single posting case (intStart,
byteStart, lastDocID, docFreq, lastDocCode, lastDocPosition are not needed).

EG we could have a separate class dedicated to the singleton case.  When term is first encountered
it's enrolled there.  We'd probably need a separate hash to store these (though not necessarily?).
 If it's seen again it's switched to the full posting.

bq. What exactly do you mean with parallel arrays? Parallel to the termHash array? Then the
termsHash array would not be an array of PostingList objects anymore, but an array of pointers
into the char[] array? And you'd have e.g. a parallel int[] array for df, another int[] for
pointers into the postings byte pool, etc? Something like that?

I mean instead of allocating an instance per unique term, we assign an integer ID (dense,
ie, 0, 1, 2...).

And then we have an array for each member now in FreqProxTermsWriter.PostingList, ie int[]
docFreqs, int [] lastDocIDs, etc.  Then to look up say the lastDocID for a given postingID
you just get lastDocIDs[postingID].  If we're worried about oversize allocation overhead,
we can make these arrays paged... but that'd slow down each access.

> IndexWriter has hard limit on max concurrency
> ---------------------------------------------
>
>                 Key: LUCENE-2293
>                 URL: https://issues.apache.org/jira/browse/LUCENE-2293
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>            Reporter: Michael McCandless
>            Assignee: Michael McCandless
>             Fix For: 3.1
>
>         Attachments: LUCENE-2293.patch
>
>
> DocumentsWriter has this nasty hardwired constant:
> {code}
> private final static int MAX_THREAD_STATE = 5;
> {code}
> which probably I should have attached a //nocommit to the moment I
> wrote it ;)
> That constant sets the max number of thread states to 5.  This means,
> if more than 5 threads enter IndexWriter at once, they will "share"
> only 5 thread states, meaning we gate CPU concurrency to 5 running
> threads inside IW (each thread must first wait for the last thread to
> finish using the thread state before grabbing it).
> This is bad because modern hardware can make use of more than 5
> threads.  So I think an immediate fix is to make this settable
> (expert), and increase the default (8?).
> It's tricky, though, because the more thread states, the less RAM
> efficiency you have, meaning the worse indexing throughput.  So you
> shouldn't up and set this to 50: you'll be flushing too often.
> But... I think a better fix is to re-think how threads write state
> into DocumentsWriter.  Today, a single docID stream is assigned across
> threads (eg one thread gets docID=0, next one docID=1, etc.), and each
> thread writes to a private RAM buffer (living in the thread state),
> and then on flush we do a merge sort.  The merge sort is inefficient
> (does not currently use a PQ)... and, wasteful because we must
> re-decode every posting byte.
> I think we could change this, so that threads write to private RAM
> buffers, with a private docID stream, but then instead of merging on
> flush, we directly flush each thread as its own segment (and, allocate
> private docIDs to each thread).  We can then leave merging to CMS
> which can already run merges in the BG without blocking ongoing
> indexing (unlike the merge we do in flush, today).
> This would also allow us to separately flush thread states.  Ie, we
> need not flush all thread states at once -- we can flush one when it
> gets too big, and then let the others keep running.  This should be a
> good concurrency gain since is uses IO & CPU resources "throughout"
> indexing instead of "big burst of CPU only" then "big burst of IO
> only" that we have today (flush today "stops the world").
> One downside I can think of is... docIDs would now be "less
> monotonic", meaning if N threads are indexing, you'll roughly get
> in-time-order assignment of docIDs.  But with this change, all of one
> thread state would get 0..N docIDs, the next thread state'd get
> N+1...M docIDs, etc.  However, a single thread would still get
> monotonic assignment of docIDs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message