Commit graph

5199 commits

Author SHA1 Message Date
Todd Gruben
085e29543e False Positive nodeLeave events put cluster in an unusable state 2019-06-05 11:28:41 -05:00
seebs
aa5c5a3afa
Merge pull request #1990 from seebs/renameSemantics
use os.Rename semantically correctly
2019-06-04 11:50:05 -05:00
Ben Johnson
7ff684c193
Allow partial translate file reads.
This commit fixes an issue where translation `LogEntry` must be
read in its entirety, however, large entries can exceed the buffer
size. This has been changed so that partial entries reads are allowed.

The `LogEntry.ReadFrom()` may still generate large byte slices
during reads of large individual fields or keys.
2019-06-04 10:08:52 -06:00
Seebs
388efd0e73 use os.Rename semantically correctly
So it's true that Rename's arguments are called oldname/newname, and
you want to rename from the previous name to the new name.

And it's true that we're calling Rename on oldPath and newPath.

But in our case, oldPath is the name the fragment file had before
the operation, and newPath is the name of the temporary file
created during the operation. Use tmpPath and frag.path to make
the semantics clearer.
2019-06-04 10:00:16 -05:00
seebs
83ec03a245
Merge pull request #1989 from seebs/rowcacheFix
Rowcache fixes
2019-06-04 09:28:48 -05:00
Seebs
77cd21e89f don't check errors we don't care about in a test 2019-06-04 09:16:01 -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
b64a3e0c68
adds filter support to MinRow and MaxRow 2019-06-03 16:29:04 +03:00
Yuce Tekol
3e738e9760
Merge branch 'master' into min-max-rowid 2019-06-03 14:10:51 +03:00
Yuce Tekol
8be7bd6956
add tests for MinRow and MaxRow 2019-06-03 13:56:50 +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
Seebs
636f132564 add a test case which breaks the rowcache code
It turns out that frozen containers which have mmapped data are
only safe *until the data gets unmapped*. Which it does on a snapshot.
2019-05-31 16:16:51 -05:00
Matthew Jaffee
f09c3ebf7c
Merge pull request #1986 from jaffee/1985-flags-unmarshal
fixed swapped order of flags and file version bytes on unmarshal
2019-05-31 10:20:40 -05:00
Yuce Tekol
1379cbbcd6
remove unused code 2019-05-31 17:35:50 +03:00
Yuce Tekol
592a191aee
translate key into Pair only for MinRow, MaxRow 2019-05-31 17:21:44 +03: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
Yuce Tekol
dd728f28ed
remove unused code 2019-05-31 17:13:25 +03:00
Yuce Tekol
d2aca3bbfc
Added MinRow and MaxRow calls 2019-05-31 15:32:15 +03:00
seebs
dfbb666f9d
Merge pull request #1974 from seebs/rowcache3
WIP: Improve row cache (mostly by not doing it)
2019-05-30 16:57:49 -05: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
Seebs
c587dbc94d drop enterprise/b
We added the containers_btree implementation to roaring/, which
makes it silly to keep this one. Also, this one is the only reason
that container.Mapped needed to be exported.
2019-05-30 16:36:20 -05:00
Yuce Tekol
778ae1e8e2
added enterprise btree first 2019-05-30 15:20:04 +03:00
Yuce Tekol
f15cb9e05c
added roaring min 2019-05-30 15:15:08 +03:00
Yuce Tekol
8706dd990f
Merge pull request #1980 from yuce/1977-fix-int-field-min-max
1977 fix int field min max
2019-05-29 10:08:24 +03:00
Yuce Tekol
c8a3dc8c18
fix int min max test for 32bit 2019-05-28 14:25:46 +03:00
Yuce Tekol
5e102154ca
make linter happy 2019-05-28 14:12:04 +03:00
Yuce Tekol
5f4c5d4d35
added test for 1977 fix 2019-05-28 13:54:12 +03:00
Yuce Tekol
b5e4b90438
fixes #1977 2019-05-27 17:43:53 +03:00
Yuce Tekol
62e2b16b88
set defaults for int field min and max 2019-05-27 15:49:10 +03:00
Ben Johnson
5612a827ab
Merge pull request #1978 from benbjohnson/topn-errors
Improve TopN() errors
2019-05-25 19:59:01 -06:00
Ben Johnson
dd4227f5e3
Improve TopN() errors
This commit improves field not found, integer field, and cache errors
for the `TopN()` command.
2019-05-25 15:16:45 -06:00
Ben Johnson
f59b49e4bb
Merge pull request #1902 from benbjohnson/unbounded-bsi-sigbit
Unbounded BSI w/ sign magnitude
2019-05-19 21:29:34 -06:00
Ben Johnson
40803372dd
Add min/max constraints; fix tests 2019-05-19 16:05:22 -06:00
Ben Johnson
d4de122549
Add min/max constraints 2019-05-17 15:52:17 -06: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
Shaquille Wyan Que
29e6bd29d7
Merge pull request #1975 from hackskills/1971-out-of-bounds
Fixed out of bounds panic to show error
2019-05-15 12:39:41 -05:00
Shaquille Wyan Que
44088d4f29 added check for unexpected parser error 2019-05-15 12:11:55 -05:00
Shaquille Wyan Que
6ba6218ae4 changed out of range error message name and fixed formatting 2019-05-15 11:22:04 -05:00
Shaquille Wyan Que
b770167db6 fixed formatting 2019-05-15 10:52:15 -05:00
Shaquille Wyan Que
98a864634e fixed out of bounds panic to show error 2019-05-14 16:58:03 -05:00
Shaquille Wyan Que
5f22aa3765
Merge pull request #1973 from hackskills/master
Fixed error message returned by regex on field and index names
2019-05-14 12:12:03 -05:00
Shaquille Wyan Que
fb93f90f31 fixed error message returned by regex on field and index names 2019-05-14 11:57:07 -05:00
Matthew Jaffee
6d26e69cf0
Merge pull request #1970 from jaffee/1967-groupby-filter-strings
Fix filter calls in GroupBy not being translated
2019-05-13 16:10:27 -05:00
Matt Jaffee
e185a01e67
add translation for groupby filter arg, improve test 2019-05-10 14:15:06 -05:00
Matt Jaffee
de61d04172
failing test for group by with filter using string keys
also, apparently our API code was assuming that imports with keys
always had timestamps which seemed wrong, so I fixed that.
2019-05-10 13:55:21 -05:00
Matthew Jaffee
d7d52d6b4e
Merge pull request #1954 from kuba--/reopen
TranslateFile - reopen the same instance
2019-05-06 10:41:43 -07:00
Matthew Jaffee
a74ca1ea3e
Merge branch 'master' into reopen 2019-05-03 13:42:33 -05:00
Matthew Jaffee
88634cbee8
Merge pull request #1966 from jaffee/update-contributing-guide
simplify contributing instructions by removing weird upstream thing
2019-05-03 10:34:14 -05:00