Commit graph

555 commits

Author SHA1 Message Date
Ashley Svetlik
8c264d9249 Resolved offical roaring no containers error 2019-06-19 12:59:36 -05:00
Ashley Svetlik
42b2d0787b Merge branch 'iss#2005' 2019-06-19 12:48:05 -05:00
asvetlik
a9edf40a5b
Merge branch 'master' into iss#2005 2019-06-19 12:25:23 -05:00
asvetlik
ff46818072
Merge branch 'master' into master 2019-06-19 12:07:16 -05:00
Ashley Svetlik
453c29a465 Fixed a malformed bitmap bug in pilosa roaring 2019-06-19 11:38:20 -05:00
Ashley Svetlik
3eed3b472f Corrected If statement logic error 2019-06-19 10:36:04 -05:00
Ashley Svetlik
2d151cd41a Making CI happy 2019-06-18 16:48:03 -05:00
Ashley Svetlik
97f525ff06 Removed fuzz_test.go 2019-06-18 16:40:10 -05:00
Ashley Svetlik
8445f6bdef Test for no containers in pilosa roaring and fixed 2019-06-18 11:05:30 -05:00
Ashley Svetlik
cae1a76629 Fixed typo 2019-06-17 16:47:28 -05:00
Ashley Svetlik
ba05ef659b Organized TestUnmarshalRoaringWithNoErrors and created TestUnmarshalRoaringWithErrors 2019-06-17 16:36:05 -05:00
Ashley Svetlik
d24a157947 Addressed review feedback 2019-06-17 15:58:20 -05:00
Ashley Svetlik
d9f2792d1f Reworded max int error and reset max int value 2019-06-17 14:11:37 -05:00
Ashley Svetlik
81f8d80fe1 Provided example on how to copy Pilosa fragments in README.md 2019-06-17 08:40:31 -05:00
Ashley Svetlik
413492552c Rearranged if statement and declared maxOpSize value 2019-06-17 08:36:56 -05:00
Yuce Tekol
5c59449ed2
reset roaring.go and added bitmap.Min 2019-06-17 16:12:43 +03:00
Yuce Tekol
06aa2cf98e
updated for feedback from PR 1983 2019-06-15 15:15:20 +03:00
Ashley Svetlik
734daf79ee Simplified the if statement and made the calculation more precise 2019-06-14 14:30:21 -05:00
Ashley Svetlik
77cb1ea6d8 Claified the arithmetic behind the max op.value 2019-06-14 13:44:04 -05:00
Ashley Svetlik
56659f9d7b Added Licensing 2019-06-14 11:47:33 -05:00
Ashley Svetlik
f4157efcb9 Added Licensing 2019-06-14 11:46:13 -05:00
Ashley Svetlik
a00ef2760b Added Licensing 2019-06-14 11:11:53 -05:00
Ashley Svetlik
3f4543cfb4 Merge branch 'master' of https://github.com/asvetlik/pilosa 2019-06-14 10:52:46 -05:00
Ashley Svetlik
7182de5f30 Added -bin -workdir and -func flags to README.md 2019-06-14 10:41:31 -05:00
asvetlik
b0f4b8b94e
Merge branch 'master' into master 2019-06-14 10:21:14 -05:00
asvetlik
cbc7aa2dda
Merge branch 'master' into iss#2005 2019-06-14 10:20:23 -05:00
Ashley Svetlik
1e7638677b Fixed the :000000 bug by adding an = in readOfficalHeader 2019-06-14 10:08:23 -05:00
Ashley Svetlik
622fba4f27 Fixed the <000000000 bug by adding if statement 2019-06-14 10:06:37 -05:00
Ashley Svetlik
0a87d8108f Added the actual bytes and their respective errors 2019-06-14 10:05:06 -05:00
Ashley Svetlik
a1f6321b1d Added a test for slice bounds out of range 2019-06-13 11:54:52 -05:00
Ashley Svetlik
4039583ccd Added fuzzing code and readme.md to explain 2019-06-13 11:11:47 -05:00
Yuce Tekol
28f56b8c97
Merge branch 'master' into min-max-rowid 2019-06-12 17:14:34 +03:00
Yuce Tekol
2b91277155
Merged with master 2019-06-11 16:59:59 +03:00
Yuce Tekol
13a42d9c07
replaced min code with bmp.iterator 2019-06-11 16:58:32 +03:00
Seebs
089e7e127e handle insertions correctly
The "Update" case for Slice containers is broken, and can
insert a container without inserting a key. Fix this by using
the existing insert/add logic.
2019-06-10 15:22:38 -05:00
Seebs
372c369e7c Optimize needs to use the new container logic
When calling `.optimize`, need to grab the new container which
may be different from the original container.
2019-06-04 08:56:56 -05:00
Yuce Tekol
3e738e9760
Merge branch 'master' into min-max-rowid 2019-06-03 14:10:51 +03:00
Seebs
973579e662 on freeze, unmap mapped containers
It turns out that calling syscall.Munmap() is a thing which
can change any container holding a pointer into the mapped space,
but which wouldn't detect frozen containers. So we need to
copy storage for such things. This negates some of the memory
wins of the rowcache code, but makes it not crashy.
2019-05-31 16:17:06 -05:00
Matt Jaffee
1515ddaf14
fixed swapped order of flags and file version bytes on unmarshal
also fix tests to use correct flags for bsi fields
2019-05-31 09:18:05 -05:00
Yuce Tekol
08f4ccb29b
Fixed conflicts; Merged with master 2019-05-31 17:16:54 +03:00
Seebs
c133ce0376 Make containers copy-on-write
This patch replaces a lot of circumstances in which containers
were being copied with circumstances in which they are shared,
using copy-on-write semantics.

To achieve this, we emulate somewhat the design of go's
native `append` function. Operations on a container may optionally
yield a new container. A container can be marked "frozen",
after which no operation should ever write to it in any way;
that applies both to the container itself and the backing store
it refers to, if any. So for instance, instead of:

	c.arrayToBitmap()

we now write:

	c = c.arrayToBitmap()

Operations which need to modify a container in any way
need to be able to return a new container, which is a modified
copy of the previous container. This applies to operations
like add/remove, but also to things like unmapping memory-mapped
storage, or changing a container's type.

Bitmaps do not support the same copy-on-write semantics,
currently, but "copying" a bitmap and sharing the containers
instead of duplicating them is *much* cheaper than copying
the containers.

Bitmaps do support a .Freeze method, which currently copies
the previous bitmap, making a new one with the same container
pointers, and freezes the individual containers. Use this
if you need a writeable copy of a bitmap -- the resulting
bitmap can safely have its set of containers modified, and
bitmap operators that would want to modify the containers
will use copy-on-write for that.

The primary motivation of this is to reduce the cost of the
row cache used by fragments. As a secondary issue, the row cache
is no longer updated on writes -- that update was actually a
race condition waiting to happen. Rather, writes to a row
invalidate the cache entry for that row. The row cache is
created by creating a new bitmap, and freezing the relevant
containers from the fragment's storage. In the case where
nothing is being written, the row cache grows to contain
bitmaps containing all those containers, but never copies
any containers. If nothing's being read, the row cache is
never created, and the containers are in general not getting
frozen. The only circumstance where copies have to happen is
when things are read (and thus stored in the row cache) and
later modified. In that case, each read freezes objects, and
the first write to a container after it's been frozen will
create a new copy.

We drop the enterprise/b btree implementation, because we
don't really need it anymore -- we now provide that
implementation by default in the open source product anyway.

Along with this, there's a lot of other changes which
improve support for nil containers, as a cheaper representation
for empty containers. Operations which we know will provide
an empty container can always short-circuit and just yield
a nil *Container. Similarly, operations which would provide
a full container can return a single shared full container
object (which is frozen). The higher-level (non type-specific)
container ops are now using that logic to short-circuit
operations for empty and full containers. (For instance,
difference of anything minus an empty container is the
original thing, union of anything and empty is the original
thing, and so on.)

The Containers interface adds "Update" and "UpdateEvery"
methods, based in part on the "Put" interface provided
by the underlying btree implementation; Update performs
a possible update in-place of a container for a given
key, bypassing the need to replicate the search for that
key in the container. UpdateEvery loops through all the
containers.

Containers do not strictly guarantee that they won't
return nil `*Container` objects. However, the container
iterators won't return those -- empty containers aren't
interesting. Some tests are updated to reflect this.

Some of the container internals, like N(), or the isArray()
and related functions, accept nil container pointers. Some,
like Thaw(), do not. For the array(), bitmap(), and runs()
methods, roaringparanoia enables an explicit panic on a nil
container explaining the problem, but the intent is that those
should never be called unless you already know you have the
right kind of container, so by default they don't perform
the extra checks. In most cases, this is already covered
because a nil container is empty, and there's no operation
we can perform that requires us to inspect the contents of
an empty container. This is passing a fair amount of testing,
but the testing may not be comprehensive enough.

The overall impact of this is pretty trivial performance-wise.
In our default roaring/ benchmarks, a few things get a few
percent faster, or slower. The advantage is that, with
read-heavy workloads, the row cache no longer eats up incredible
amounts of memory.

For a smallish test case, pilosa's memory usage (RES in top) after
startup was ~2.5GB. Without this patch, simply reading every
row a few times got memory usage to about 9GB, which seemed
reasonably stable. With this patch, memory usage went to about
3GB. This will be less noticeable in mixed read/write loads,
but it should be consistently significantly lower.

In addition to dropping things from the rowCache on modifications,
we also stopped performing a full count on a modified row when
not using a cache of a kind that would use that count, and don't
repopulate the rowCache regardless. We don't want every write
to imply a corresponding read after it.

There's a lot of room for possible future optimizations in
terms of things like in-place operations, and some of the
row/rowSegment code is a little suspicious to me, but I don't
think it should be *worse* in any cases.
2019-05-30 16:36:20 -05:00
Seebs
63120e3715 rename slice containers source file descriptively
The containers.go file contains one of two Containers implementations,
it should have a name reflecting this.
2019-05-30 16:36:20 -05:00
Yuce Tekol
f15cb9e05c
added roaring min 2019-05-30 15:15:08 +03:00
Ben Johnson
7ed9fba335
Unbounded BSI w/ sign magnitude
This commit implements BSI with variable bit depth using a
sign magnitudeto indicate whether a value is positive or negative.
This also rearranges the existence bit to be the first bit instead
of the last bit.
2019-05-17 15:52:17 -06:00
Seebs
302830ed60 fix lint in btree_test 2019-04-16 12:08:40 -05:00
Seebs
77d49ded64 so much lint
So with the switch to a new linter, we get a lot of new warnings,
and the majority of them are harmless probably, but a few might be
real. Variously just use _ to suppress warnings, or report errors.
There's probably things here that deserve better fixes, but we can
always revisit it.
2019-04-16 12:07:18 -05:00
Cody Soyland
fdbfc68f7c Add license headers to files missing them and CI check to verify they are present. Fixes #1633 2019-04-12 11:30:41 -05:00
Cody Soyland
7ede65bf80
Merge branch 'master' into shardwidth22 2019-04-11 10:10:47 -05:00
Matt Jaffee
bd085e0a21
simply setting list of values with *N methods 2019-04-05 14:08:11 -05:00
Matt Jaffee
836b467d3d
add support to modify shard width at build time
use "make <x> SHARD_WIDTH=nn"

fix tests to run and pass at different shardwidths

add shardwidth22 test to circle ci
2019-04-04 13:46:26 -05:00