Commit Graph

122 Commits

Author SHA1 Message Date
Chris Vest
0c40143f5f Fix license header years, and style updates 2020-12-04 18:48:06 +01:00
Chris Vest
80185abec4 Add a benchmark for Buf.send()
Motivation:
This will likely be a somewhat common operation, as buffers move between eventloop and worker threads, so it's important to have an understanding of how it performs.

Modification:
Add a benchmark that specifically targets the send() operation on buffers.

Result:
We got benchmark numbers that clearly show the cost of confinement transfer
2020-12-04 16:27:08 +01:00
Chris Vest
236097e081 Make it possible to extend composite buffers after creation
Motivation:
Composite buffers are uniquely positioned to be able to extend their underlying storage relatively cheaply.
This fact is relied upon in a couple of buffer use cases within Netty, that we wish to support.

Modification:
Add a static `extend` method to Allocator, so that the CompositeBuf class can remain internal.
The `extend` method inserts the extension buffer at the end of the composite buffer as if it had been included from the start.
This involves checking offsets and byte order invariants.
We also require that the composite buffer be in an owned state.

Result:
It's now possible to extend a composite buffer with a specific buffer, after the composite buffer has been created.
2020-12-03 17:48:28 +01:00
Chris Vest
6b7ea5f5cb Add benchmarks for ByteIterator
Motivation:
Capture the performance characteristics of this primitive for various buffer implementations.

Modification:
Add a benchmark that iterate 4KiB buffers forwards, and backwards, on various buffer implementations.

Result:
Another aspect of the implementation covered by benchmarks.
Turns out the composite iterators a somewhat slow.
2020-12-02 14:54:02 +01:00
Chris Vest
e3c7f9b632 Capture build artifacts for failed builds
Motivation:
When a build fails, it's desirable to have the build artifacts available
so the build failure can be inspected, investigated and hopefully fixed.

Modification:
Change the Makefile and CI workflow such that the build artifacts are
captured and uploaded when the build fails.

Result:
A "target.zip" file is now available for download on failed GitHub
Actions builds.
2020-12-01 14:38:09 +01:00
Chris Vest
4a409d2458 Add benchmark for closing pooled buffers
Motivation:
Pooled buffers are a very important use case, and they change the cost dynamics around shared memory segments, so it's worth looking into in detail.

Modification:
Add another explicit close of pooled direct buffers to MemorySegmentClosedByCleanerBenchmark

Result:
Explicitly closing of pooled buffers is even out-performing cleaner close on the "heavy" workload, so this is currently the fastest way to run that workload:

Benchmark                                                  (workload)  Mode  Cnt   Score   Error  Units
MemorySegmentClosedByCleanerBenchmark.cleanerClose              heavy  avgt  150  14,194 ± 0,558  us/op
MemorySegmentClosedByCleanerBenchmark.explicitClose             heavy  avgt  150  40,496 ± 0,414  us/op
MemorySegmentClosedByCleanerBenchmark.explicitPooledClose       heavy  avgt  150  12,723 ± 0,134  us/op
2020-12-01 11:15:44 +01:00
Chris Vest
a3f6ae6be8 Make Buf.send() faster
When send() a confined buffer, we had to first turn it into a shard buffer, so that it could be claimed by an arbitrary recipient thread.

As we've learned, however, closing shared segments is expensive.
We can speed up the send() call by simply leaving the segment shared.
This weakens the confinement of the received segment, though.
Currently no tests fails on that, but in the future we should re-implement confinement checking inside the Buf implementations themselves any, because pooled buffers also violate the confinement restriction, and we have a guiding principle that all buffers, regardless of implementation, should always behave the same.

The results of this change can be observed in the MemorySegmentClosedByCleanerBenchmark, with the heavy workload.
Explicitly closed segments now run the workload twice as fast, and the cleaner based closing is now 3 times faster.

Before:
Benchmark                                            (workload)  Mode  Cnt   Score   Error  Units
MemorySegmentClosedByCleanerBenchmark.cleanerClose        heavy  avgt  150  42,221 ± 0,943  us/op
MemorySegmentClosedByCleanerBenchmark.explicitClose       heavy  avgt  150  65,215 ± 0,761  us/op

After:
Benchmark                                            (workload)  Mode  Cnt   Score   Error  Units
MemorySegmentClosedByCleanerBenchmark.cleanerClose        heavy  avgt  150  13,871 ± 0,544  us/op
MemorySegmentClosedByCleanerBenchmark.explicitClose       heavy  avgt  150  37,516 ± 0,426  us/op
2020-11-26 11:31:23 +01:00
Chris Vest
6364c4d170 Add a benchmark for examining the performance difference between explicitly closing memory segments, versus having them closed by cleaners 2020-11-26 10:37:14 +01:00
Chris Vest
6078465721 Add a benchmark for opening and closing shared/confined native/heap memory segments 2020-11-24 10:56:22 +01:00
Chris Vest
92c178ceb9 The BufTest.pooledBuffersMustResetStateBeforeReuse should run for all allocators 2020-11-23 18:10:58 +01:00
Chris Vest
eb7717b00a Move benchmarks to their own directory 2020-11-23 18:10:27 +01:00
Chris Vest
1f9ab72a44 Add more examples 2020-11-20 22:22:01 +01:00
Chris Vest
f3e494bce3 Add first example on how to use the new buffer API 2020-11-20 16:07:52 +01:00
Chris Vest
023bb64a25 Update MemSegBuf with the latest panama-foreign API changes 2020-11-20 14:01:14 +01:00
Chris Vest
a4ecc1b184 Add toString methods to the buffer implementations 2020-11-20 12:44:09 +01:00
Chris Vest
53d2e4b955 Pooled buffers must reset their state before reuse
Motivation:
Buffers should always behave the same, regardless of their underlying implementation and how they are allocated.

Modification:
The SizeClassedMemoryPool did not properly reset the internal buffer state prior to reusing them.
The offsets, byte order, and contents are now cleared before a buffer is reused.

Result:
There is no way to observe externally whether a buffer was reused or not.
2020-11-20 11:53:26 +01:00
Chris Vest
59b564ddc8 Add a docker-based build
Motivation:
Because of the current dependency on snapshot versions of the Panama Foreign version of OpenJDK 16, this project is fairly involved to build.

Modification:
To make it easier for newcomers to build the binaries for this project, a docker-based build is added.
The docker image is constructed such that it contains a fresh snapshot build of the right fork of Java.
A make file has also been added, which encapsulates the common commands one would use for working with the docker build.

Result:
It is now easy for newcomers to make builds, and run tests, of this project, as long as they have a working docker installation.
2020-11-18 17:16:37 +01:00
Chris Vest
a1785e8161 Move the MemorySegment based Buf implementation to its own package, and break the remaining bits of tight coupling. 2020-11-17 15:53:40 +01:00
Chris Vest
3efa93841e Rename the 'b2' package to 'api' 2020-11-17 15:40:13 +01:00
Chris Vest
0ad7f648ae Get the benchmarks running again 2020-11-17 15:34:46 +01:00
Chris Vest
b3aff17f5a Fix checkstyle so the build passes 2020-11-17 15:26:58 +01:00
Chris Vest
84e992c2c9 Move all files into the incubator repo 2020-11-17 15:26:58 +01:00