Commit graph

4650 commits

Author SHA1 Message Date
Matt Jaffee
e469285fe3
add fragment mmap tracking and limiting
in the case that the map limit is reached, we'll fall back to reading the file
into memory normally.
2019-03-19 12:55:26 -05:00
Todd Gruben
327aa70924
add failure path for mmap 2019-03-19 12:55:25 -05:00
seebs
b2eff07d8d
Merge pull request #1897 from seebs/seebs/inplace
Address UnionInPlace performance regressions
2019-03-15 12:02:10 -05:00
Seebs
cf5f9f9a57 add clarifying comment 2019-03-15 11:19:49 -05:00
Seebs
97486f410b WIP: Union/UnionInPlace performance improvements
This consolidates a number of changes. The first is significant
reductions in allocation and copying during UnionInPlace
operations on very sparse containers -- for instance, combining
two array containers with one item each.

We fix up the logic for identifying and handling cases where
only one of the containers being unioned together has a given
key.

We generally favor cloning an existing container over unioning
it into a new empty container.

When unioning two containers, we were using unionIntoTargetSingle
on those two containers, into an empty bitmap. For more, we were
creating an empty bitmap, then unioning all the others into
it; it's faster to clone the first, then union the others into
it.

The overall logic for UnionInPlace is cleaned up and simplified
a bit. However, it's then complexified a bit, because it turns
out that while it's a bad idea to convert single-item arrays to
bitmaps to union them, by a few hundred items, the bitmap
conversion saves a lot of time even if it costs an allocation.

The value of N picked here is sort of arbitrary, but
512 seems to be about right. The big problem is a massive
performance hit in cases where, say, there's only a
couple of items per container, and the bitmap conversion
is extremely expensive. If you wait until N reaches
the array size cap, though, you take a very noticeable
performance hit (can be a factor of 2.5-3 in simple
testing).

We also add some stat counters, and rename an internal
method on the `handledIters` type.
2019-03-14 15:17:38 -05:00
Seebs
054cb206d5 improve union-related benchmarking
Add a benchmark to test a specific case where UnionInPlace is
underperforming the naive union operation badly.

Also, the UnionBulk test was reusing a bitmap, meaning that it ended
up doing a lot of unions into a bitmap that already had all the
bits it was supposed to have. This broke a couple of other tests
in unexpected ways.

We also now use UnionInPlace in importRoaring, and test it
in the container combinations tests via a wrapper.
2019-03-14 15:16:49 -05:00
Matthew Jaffee
53d018a2b1
Merge pull request #1892 from jaffee/import-roaring-union
smallWrite path for import-roaring
2019-03-12 08:16:25 -05:00
Matt Jaffee
a28141c466
revert to Union for importRoaring
UnionInPlace is still heavily affected by
https://github.com/pilosa/pilosa/issues/1875 where containers that exist in an
incoming bitmap can cause massive unnecessary allocations of bitmap containers
when an array of short length is all that's needed.
2019-03-11 17:43:55 -05:00
Matt Jaffee
52d43fb4e2
add smallPath for importRoaring
this converts the rowSet to a map from a slice which might be bad... benchmarks
will tell.
2019-03-11 17:43:55 -05:00
Matt Jaffee
d0f8304f1c
add importRoaring small updates benchmark 2019-03-11 17:43:55 -05:00
Matt Jaffee
19807ff3a7
use num containers to decide which direction to union
avoids doing a potentially expensive f.storage.Count()
2019-03-11 17:43:55 -05:00
Matt Jaffee
e33ca2d0ae
use UnionInPlace in import-roaring
get the count of the existing fragment and compare it to the incoming bits to
decide which should be unioned into the other. This should generally result in
far fewer allocations, though there is much work that needs to be done within
UnionInPlace to further improve things.

unrelatedly, I added a TODO to change the long-query-time option to move it out
of cluster. It should probably be happening at the API level so that different
handlers can reuse it, but if we're going to do that we'll want to make sure
that any potentially time intensive operations are pulled into api from
handler (e.g. protobuf decoding)
2019-03-11 17:43:55 -05:00
Matt Jaffee
663c725779
import benchmarking tweaks
importRoaring large fragment benchmark

skip concurrent import benchmarks with testing.short
2019-03-11 17:43:07 -05:00
Matthew Jaffee
6f9bac960e
Merge pull request #1871 from jaffee/1864-random-import-perf
1864 random import perf
2019-03-07 10:55:22 -06:00
Matt Jaffee
9fe58e5e36
exterminate unnecessary sprintf 2019-03-07 10:24:41 -06:00
Matt Jaffee
b71096b688
update licensing and NOTICE to reflect btree being moved to roaring 2019-03-05 15:52:32 -06:00
Matt Jaffee
831195e7d2
update roaring container benchmarks to do both slice and btree 2019-03-05 15:46:13 -06:00
Matt Jaffee
e54dbd6731
simplify row/lastRow comparison in bulkImport 2019-03-05 12:20:21 -06:00
Matt Jaffee
cfb2a80866
write large fragment import benchmark
needed to pull in btree containers to get acceptable perf building the initial
data. Still quite slow though.
2019-03-05 08:48:33 -06:00
Matt Jaffee
6fe1ab45c2
fixup Fragment_Import benchmark
It was doing a fresh import on the first round and then importing the same data
into the fragment over and over.
2019-03-05 08:47:44 -06:00
Matt Jaffee
7af64e382c
comments to make import mutex less confusing 2019-03-04 21:38:09 -06:00
Matt Jaffee
8476fffaa7
always operate on storage in importPositions regardless of smallWrite
This greatly simplifies the code, and with the recent addition of DirectAddN and
DirectRemoveN should be as or more performant than doing the separate bitmap and
union (in most cases, unsorted data could still be slower). Perhaps more
importantly, it is also less allocation heavy than the union approach. Also
makes it trivial to get the counts of changed bits, so I've cleaned up the stats
to show number of bits we're importing/clearing and the number of bits that
actually changed.
2019-03-04 21:38:09 -06:00
Matt Jaffee
868342d338
fix benchmarks broken by import modifying its args in-place 2019-03-04 21:38:08 -06:00
Matt Jaffee
4c42069d5d
implements bitmap batch Direct* operations which are optimized for sorted data
also reset the data on AddN and RemoveN ops if the log write fails
2019-03-04 21:38:08 -06:00
Matt Jaffee
c32c8cda84
only write changed values to op log 2019-03-04 21:38:08 -06:00
Matt Jaffee
9b8a97ccb6
maintain column set in bulkImportMutex to guard against repeats 2019-03-04 21:38:08 -06:00
Matt Jaffee
4082ce655a
wip on adding mutex support to random import perf 2019-03-04 21:38:08 -06:00
Matt Jaffee
f06a9f0e6e
positionsForValue appends to existing slices rather than allocating small ones 2019-03-04 21:38:08 -06:00
Matt Jaffee
a58459cf0f
fix spelling of unnecessary 2019-03-04 21:38:08 -06:00
Matt Jaffee
d429d7c496
code review feedback: add Bitmap.Any and remove unecessary condition 2019-03-04 21:38:07 -06:00
Matt Jaffee
023faebd90
fix bug where opN wasn't getting set/cleared correctly 2019-03-04 21:38:07 -06:00
Matt Jaffee
7037ebf4b3
rename smallPath->smallWrite for consistency 2019-03-04 21:38:07 -06:00
Matt Jaffee
088d618040
increase default MaxOpN 2019-03-04 21:38:07 -06:00
Matt Jaffee
04957308ba
gofmt -s 2019-03-04 21:38:07 -06:00
Matt Jaffee
3cbcb238fb
aggregate small bsi imports into a single-write append 2019-03-04 21:38:07 -06:00
Matt Jaffee
ce656bbcda
factor out code to import/clear by positions 2019-03-04 21:38:07 -06:00
Matt Jaffee
537ae99fb9
add import support with aggregated op log writes 2019-03-04 21:38:07 -06:00
Matt Jaffee
dd4a8755ae
add importValue benchmark and move data building to per benchmark 2019-03-04 21:38:06 -06:00
Matt Jaffee
0de419c95e
add a SetBit/ClearBit path to bulkImport for small updates
also add benchmarks for this situation and set default MaxOpN higher which
benchmarks suggest is a good idea
2019-03-04 21:38:06 -06:00
Matthew Jaffee
5027a7a883
Merge pull request #1887 from jaffee/metric.service-fix
[fix] improve help strings for metrics options
2019-03-04 21:37:34 -06:00
Matt Jaffee
52fe460f84
improve help for metrics options 2019-03-04 17:36:01 -06:00
Yuce Tekol
3f5feeb83c
Merge pull request #1881 from yuce/1880-shardwidth-in-indexinfo
Adds shardWidth to index info in schema
2019-03-01 18:08:24 +03:00
Yuce Tekol
d8ba398dd8
added missing index.go changes 2019-03-01 15:02:49 +03:00
Yuce Tekol
767062ab7c
Adds shardWidth to index info in schema 2019-03-01 14:57:46 +03:00
Matthew Jaffee
784cadd1b1
Merge pull request #1876 from jaffee/union-in-place-unmap
[fix] make sure to unmap containers before modifying
2019-02-26 11:13:56 -06:00
Matt Jaffee
67e7281a55
make sure to unmap containers before modifying 2019-02-25 17:12:27 -06:00
seebs
5b43c90762
Merge pull request #1863 from seebs/seebs/flock
avoid probable race when creating fragments
2019-02-21 20:17:23 -06:00
Seebs
dde6954de4 view.go: deal with races in fragment creation
There existed a case where two goroutines would try to
CreateIfNotExists the same fragment, and the first would
create it, but not put it in the fragments table, then
drop the lock, try to broadcast a message, and if it
succeeded then populate the fragments table. The second
would come along during the broadcast, not find an
entry, try to create one, and fail because the file was
already locked.

Basic problem: At least one test in server/ will fail
if we don't delay to send out broadcast messages. Everything
will lock up if we can wait forever (or even just a very
long time) for the message broadcast. We don't ever want
to have an inconsistent state -- so we don't want to either
fail to get a fragment when one's been created, or get one
that's about to be deleted if the broadcast fails.

So, creation and stashing in the fragments table is
atomic and immediate. After that, we optimistically attempt
to broadcast. If we fail, we fail. We delay up to about
50ms for the broadcast to be done, but after that return
anyway. This way, if things are going well everything
works, and if there's unexpected delays, things work except
some nodes in a cluster may not know about available
shards on other nodes sometimes. But that would have
happened anyway. A proper fix is beyond the scope of this
patch.
2019-02-21 16:43:19 -06:00
tgruben
11fe06be85
Merge pull request #1865 from tgruben/roaring-import-opt
removed copy for pilosa roaring files
2019-02-19 11:21:51 -06:00
Todd Gruben
e3fe55522d comment adjustments 2019-02-19 10:54:09 -06:00