Commit Graph

118 Commits (63ec32ef321972daedc5f45f3b799adac9dda110)

Author SHA1 Message Date
funkygao 6d043164a9 add comment: db.dataref is readonly 2015-03-25 22:05:58 +08:00
funkygao 20852b29c4 fix comment bug: minium db mmapSize is 1MB instead of 4MB 2015-03-25 22:04:41 +08:00
Tommi Virtanen adbb1a19c1 Add transaction batching
DB.Batch makes it easy to make lots of small transactions with
significantly better performance. Batch combines multiple concurrent
Update calls into a single disk transaction, managing errors smartly.
2015-02-18 12:26:45 -08:00
Ben Johnson e7f5c931e2 Fix large mmap resize.
This commit fixes an issue where large databases were being resized to
larger sizes on every open.
2015-02-16 15:23:48 -07:00
Ben Johnson ac1149a3f5 Persist sequence-only changes.
This commit fixes a bug where only calling NextSequence() on a Bucket does not cause the Bucket to be
peristed. The simple fix is to simply materialize the root node so that the bucket is flushed out
during commit.

Thanks to Matthew Dawson (@MJDSys) for reporting.

https://github.com/boltdb/bolt/issues/296
2015-02-02 08:27:34 -07:00
Ben Johnson b4d00c394a Expand assertion statements.
This commit expands calls to _assert() that use variadic arguments. These calls require conversion to interface{} so there
was a large number of calls to Go's internal convT2E() function. In some profiling this was taking over 20% of total runtime.
I don't remember seeing this before Go 1.4 so perhaps something has changed.
2015-01-30 14:15:49 -05:00
Ben Johnson 338d8e78e2 Fix max mmap check for 32-bit arch. 2015-01-28 16:27:06 -05:00
Ben Johnson dacc1873d1 Fix mmap step & max size check.
This commit adds fixes suggested by @tv42 for the mmap step fix in 834b38e:

* Check max size before calculating the new the mmap size.
* Fix mmap step loop to go to 1GB instead of 512MB.
2015-01-28 13:03:30 -05:00
Ben Johnson 834b38e3e7 Fix mmap resize calculation.
This commit fixes an issue where the database would grow whenever it was opened. This was caused by
a recent change that performed a truncation when the database grew. Now there are fixed growth sizes
for the database (1MB, 2MB, 4MB, 8MB, etc) up to 1GB and then the database will grow by 1GB when it
resizes.

See also: 6bb25854a1
2015-01-28 11:29:27 -05:00
pmcgrath 2110587fdd Removed redundant duplicate line of code 2015-01-22 12:15:40 +00:00
Ben Johnson 8374d6adc5 Add check for max mmap size.
The max mmap size was previous unchecked which resulted in a panic once
the maximum size was reached. This commit adds a check for the max size
when re-mapping and returns an error if the new map will exceed the size.

Thanks to Tamás Gulácsi for testing out the change on i386.
2015-01-12 08:06:42 -07:00
Josh Rickmar a2cbaa05f9 Fix bolt on OpenBSD.
OpenBSD does not include a UBC kernel and writes must be synchronized
with the msync(2) syscall.  In addition, the NoSync field of the DB
struct should be ignored on OpenBSD, since unlike other platforms,
missing msyncs will result in data corruption.

Depends on PR #258.

Fixes #257.
2014-09-18 18:14:50 -05:00
Ben Johnson ba6badc57f Move tests to a test package. 2014-07-26 15:11:47 -06:00
Ben Johnson c3400efefd Change fill percent to be per-bucket.
This commit moves the DB.FillPercent field to Bucket.FillPercent. This
allows the fill percentage to be specified per-bucket, per-tx. This
value is not persisted and should be set whenever using it.
2014-07-24 10:36:09 -06:00
Ben Johnson 048d3f19b2 Add DB.NoSync option for bulk loading.
This commit adds the DB.NoSync flag to skip fsync() calls on each commit. This should only
be used for bulk loading as it can corrupt your database in the event of a system failure.

Initial tests show it can provide a 2x speed up for sequential inserts.
2014-07-15 07:37:46 -06:00
Ben Johnson ac4838472d Recover from panics appropriately.
This commit adds a defer handler to ensure that transactions are always closed out - even
in the event of a panic within user code. It's recommended that applications always fail
in the event of a panic but some packages such as net/http will automatically recover
which is a problem (IHMO).
2014-07-11 09:54:10 -06:00
Ben Johnson cc8004c980 Merge branch 'master' of https://github.com/boltdb/bolt into free-cache 2014-07-10 14:00:32 -06:00
Ben Johnson e903703e61 Fix Windows mmap sizing.
This commit fixes an issue on Windows where the database was doubling
when it was re-opened. This occurred because Windows has to truncate the
file to the mmap size and the mmap resizing code was doubling the size
whenever the DB size was at the next threshold. This has been changed so
that the DB size will double only when the DB size is above the next
threshold.
2014-07-10 07:11:01 -06:00
Ben Johnson def455554b Add freelist cache.
This commit adds a cache to the freelist which combines the available free pages and pending free pages in
a single map. This was added to improve performance where freelist.isFree() was consuming 70% of CPU time
for large freelists.
2014-06-30 08:01:41 -06:00
Martin Kobetic 8c386e72f3 Copy the free pages stats from the receiver 2014-06-27 17:38:06 +00:00
Ben Johnson d1a77a9c82 Minor fix. 2014-06-24 11:58:46 -06:00
Martin Kobetic bae0fbd290 review tweaks 2014-06-24 17:54:40 +00:00
Martin Kobetic ba79a0a355 drop the *s guard 2014-06-24 17:40:53 +00:00
Martin Kobetic 8dd18bd620 review tweaks 2014-06-24 17:19:50 +00:00
Martin Kobetic 32e22b3bb6 add some guards for nil pointers 2014-06-24 15:32:04 +00:00
Martin Kobetic bbee09da30 copy receiver stats in Stats.Sub() 2014-06-24 15:32:04 +00:00
Ben Johnson 642b104396 Add DefaultOptions variable.
This commit adds an explicit DefaultOptions variable for additional documentation.
Open() can still be passed a nil options which will cause options to be change to
the DefaultOptions variable. This change also allows options to be set globally for
an application if more than one database is being opened in a process.

This commit also moves all errors to errors.go so that the godoc groups them together.
2014-06-22 12:44:20 -06:00
Ben Johnson 00ee0da528 Add Open() options, flock timeout.
This commit changes Open() to provide an additional Options argument. The options
argument currently only has a Timeout which will cause the Open() to return
ErrTimeout if a file lock cannot be obtained in time.

Fixes #207.
2014-06-21 14:44:28 -06:00
Martin Kobetic 571f201672 split the freelist page count stats to free and pending 2014-06-20 14:53:25 +00:00
Ben Johnson b1dbd35da1 Fix merge-split regression.
This commit reverts merge-split and fixes the node.split() to do a multi-page split. This issue
caused problems with bulk loading because it would split into a small page and a very large page.
The very large page, in turn, would be an arbitrary size so when it was freed later it would be
difficult to reuse and would cause serious fragmentation issues.
2014-06-18 16:16:58 -06:00
Martin Kobetic 8a386756df fix up freelist stats naming and add FreeAlloc 2014-06-18 18:10:42 +00:00
Martin Kobetic 4918ce8301 drop mergeStats and move freelist stats update to Tx 2014-06-17 19:30:10 +00:00
Martin Kobetic c105316292 add freelist stats to db stats 2014-06-17 18:40:56 +00:00
Ben Johnson defdb743cd Fix deadlock on remmap.
This commit fixes a deadlock situation that can occur when Bolt's database size crosses a threshold
and requires remapping the mmap.
2014-06-13 12:07:37 -06:00
Ben Johnson 1c97a490dd Add Windows support.
This commit adds Windows support to Bolt. Windows memory maps return an address instead of a byte
slice so the DB.data field had to be refactored to be a pointer to a large byte array.
2014-06-12 09:23:30 -06:00
Ben Johnson c2577db1c2 Add Windows support. 2014-06-11 11:11:21 -06:00
Ben Johnson b789691976 Add streaming check.
This commit changes Tx.Check() to return a channel through which check errors are returned. This allows
errors to be found before checking the entire data file.
2014-05-28 10:31:22 -06:00
Ben Johnson 92a9f2e200 Remove DB.Check(). Allow read-only Tx.Check().
This commit removes the DB.Check() function and instead makes the user decide
whether a transaction should be writable or read-only. Tx.Check() is not safe
to use concurrently on a read-only transaction, however, it significantly
improves the performance of it.
2014-05-27 11:31:55 -06:00
Ben Johnson 7432bc341f Merge pull request #169 from benbjohnson/allocation
Fix freelist allocation direction.
2014-05-21 13:46:12 -06:00
Martin Kobetic 519d65228e move Copy and CopyFile from DB to Tx 2014-05-21 15:08:37 +00:00
Ben Johnson 782ead0dbf Fix freelist allocation direction.
This commit fixes the freelist so that it frees from the beginning of the data file
instead of the end. It also adds a fast path for pages which can be allocated from
the first free pages and it includes read transaction stats.
2014-05-19 12:08:33 -06:00
Ben Johnson 6840e4f3dc Change verbiage, fix node test. 2014-05-15 14:21:17 -06:00
Ben Johnson a1873dd6f6 Add option to adjust fill percentage.
This commit adds the ability to adjust the fill percentage for splitting nodes. This
works by setting a threshold that is a percentage of a total page size. When that
threshold is crossed during a split then a new node is created.

This is primarily beneficial for append-only workloads.

Fixes #163.
2014-05-15 14:04:57 -06:00
Ben Johnson 1f5fb0208b Add strict mode. 2014-05-14 18:08:55 -06:00
Martin Kobetic d279ea44ce add asserts for detecting pgid high watermark overflow 2014-05-09 13:35:00 +00:00
Ben Johnson 55e71b0902 Add inline bucket support.
This commit adds support for writing small buckets directly inline to their value in
their parent's leaf node. Previously, subbuckets would simply have a bucket header
stored in their parent bucket which pointed to the root page. This required that
every bucket use at least a single page. This has a high overhead for buckets with
only one or two small items.

Inline buckets checks subbuckets to see if they only have a small amount of data
(about 1kb) and no subbuckets. If these conditions are met then the bucket's root
node is written to a fake page which is simply a pointer to the end of the bucket's
header.

Fixes #124.
2014-05-05 16:39:55 -06:00
Ben Johnson c3903d38a1 Consolidate code for clarity.
This commit consolidates some of the smaller files into some of the larger files.
The smaller files cluttered the file tree and made it harder to see the logical
groupings of structs.
2014-05-05 07:56:54 -06:00
Steven Normore 32937280c3 wip 2014-04-16 15:00:26 +00:00
Steven Normore b178373351 build c/cursor and running tests 2014-04-16 13:29:52 +00:00
Ben Johnson 698b07b074 Add nested buckets.
This commit adds the ability to create buckets inside of other buckets.
It also replaces the buckets page with a root bucket.

Fixes #56.
2014-04-11 12:36:54 -06:00