Commit graph

5531 commits

Author SHA1 Message Date
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
Matthew Jaffee
85e5c885cf
Merge branch 'master' into update-contributing-guide 2019-05-03 09:26:23 -05:00
Kuba Podgórski
42c62187cf
Merge branch 'master' into reopen 2019-05-03 01:11:15 +02:00
Matthew Jaffee
67d53f6b48
Merge pull request #1939 from jaffee/extra-tracing
Extra tracing
2019-05-02 12:16:25 -05:00
Kuba Podgórski
97e7f86372
Merge branch 'master' into reopen 2019-05-02 14:07:25 +02:00
kuba--
51ac675e82
TranslateFile - reopen the same instance
Signed-off-by: kuba-- <kuba@sourced.tech>
2019-05-02 14:05:40 +02:00
Matt Jaffee
27fab06e78
simplify contributing instructions by removing weird upstream thing
we can probably remove GOPATH too, but I'll save that for another day.

For now, we make it so that the obvious thing (cloning the official
repo) works as a normal part of the contribution process.
2019-05-01 17:37:52 -05:00
Matt Jaffee
00911d024b
add span around fragment lock, bytes written metadata 2019-04-30 16:55:46 -05:00
Matt Jaffee
61bf3d929d
Add more tracing and metdata to importRoaring 2019-04-30 15:49:52 -05:00
Travis Turner
e1e0d0cdfa
Merge pull request #1950 from travisturner/more-debugf
Add more Debugf() statements to the holder open process
2019-04-30 15:49:21 -05:00
Travis Turner
875c95b2c3
add more Debugf() statements to the holder open process 2019-04-30 15:16:10 -05:00
alanbernstein
962d8c200c
Merge pull request #1961 from alanbernstein/doc-fixes
Fix typos
2019-04-30 12:18:28 -05:00
Alan Bernstein
82f5f632ad Fix typos 2019-04-30 11:48:57 -05:00
Matthew Jaffee
6e24c45631
Merge pull request #1959 from jaffee/1958-apply-schema-all
send POSTed schema to all nodes in cluster
2019-04-30 08:29:07 -07:00
Matt Jaffee
9e6662fb00
send POSTed schema to all nodes in cluster
also fix a *bunch* of tests that weren't closing the clusters they
created. Cleaned up one test to use t.Run instead of just checking
everything in a loop
2019-04-29 19:31:23 -05:00
Matthew Jaffee
e5e7ac3ab5
Merge pull request #1956 from jaffee/1955-post-schema
add ability to post schema using holder.applySchema
2019-04-26 19:09:04 -05:00
Matt Jaffee
a6ee142403
update docs, add test 2019-04-26 18:27:10 -05:00
Cody Soyland
53fb82ea72
remove errant debugging println
Co-Authored-By: jaffee <matthew.jaffee@gmail.com>
2019-04-26 15:55:10 -05:00
Matt Jaffee
0ef3e5e144
add ability to post schema using holder.applySchema
New API warning: this adds ApplySchema to pilosa.API and allows
POSTing to the /schema endpoint
2019-04-25 16:03:44 -05:00