All Projects → intel-go → Bytebuf

intel-go / Bytebuf

Licence: bsd-3-clause
Example of how CL133375 can be utilized to mitigate Go escape analysis limitations.

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Bytebuf

Listpool
Optimized allocation free implementation of IList using ArrayPool.
Stars: ✭ 25 (-94.94%)
Mutual labels:  buffer, performance
Pydis
A redis clone in Python 3 to disprove some falsehoods about performance.
Stars: ✭ 623 (+26.11%)
Mutual labels:  experiment, performance
Trixi
Manage your machine learning experiments with trixi - modular, reproducible, high fashion. An experiment infrastructure optimized for PyTorch, but flexible enough to work for your framework and your tastes.
Stars: ✭ 211 (-57.29%)
Mutual labels:  example, experiment
Bytebuffercpp
An implementation of ByteBuffer in C++
Stars: ✭ 55 (-88.87%)
Mutual labels:  buffer, bytes
Bytearray.js
An equivalent to Actionscript 3's ByteArray for Javascript with AMF0 and AMF3 support.
Stars: ✭ 100 (-79.76%)
Mutual labels:  buffer, bytes
biguint-format
Node.js module to format big uint numbers from a byte array or a Buffer
Stars: ✭ 16 (-96.76%)
Mutual labels:  buffer, bytes
Flake Idgen
Flake ID generator yields k-ordered, conflict-free ids in a distributed environment in Node.js
Stars: ✭ 196 (-60.32%)
Mutual labels:  buffer, bytes
Hisocket
It is a lightweight client socket solution, you can used it in C# project or Unity3d
Stars: ✭ 275 (-44.33%)
Mutual labels:  buffer, bytes
Graphql Crunch
Reduces the size of GraphQL responses by consolidating duplicate values
Stars: ✭ 472 (-4.45%)
Mutual labels:  performance
Bundle Wizard
Magically easy insight into the JavaScript loaded by a web app
Stars: ✭ 479 (-3.04%)
Mutual labels:  performance
Trace Nodejs
Trace is a visualised distributed tracing platform designed for microservices.
Stars: ✭ 471 (-4.66%)
Mutual labels:  performance
Processhacker
A free, powerful, multi-purpose tool that helps you monitor system resources, debug software and detect malware.
Stars: ✭ 6,285 (+1172.27%)
Mutual labels:  performance
Maghead
The fastest pure PHP database framework with a powerful static code generator, supports horizontal scale up, designed for PHP7
Stars: ✭ 483 (-2.23%)
Mutual labels:  performance
Scandir
Better directory iterator and faster os.walk(), now in the Python 3.5 stdlib
Stars: ✭ 471 (-4.66%)
Mutual labels:  performance
Flutter For Android Developers
Compilation of Flutter materials for Android developers
Stars: ✭ 488 (-1.21%)
Mutual labels:  example
Ionic3 Chat
ionic3 chat example
Stars: ✭ 465 (-5.87%)
Mutual labels:  example
Gearbox
Gearbox ⚙️ is a web framework written in Go with a focus on high performance
Stars: ✭ 455 (-7.89%)
Mutual labels:  performance
Cassowary
🚀 Modern cross-platform HTTP load-testing tool written in Go
Stars: ✭ 488 (-1.21%)
Mutual labels:  performance
Laravel Pjax
A pjax middleware for Laravel
Stars: ✭ 487 (-1.42%)
Mutual labels:  performance
Ios Nfc Example
📱 Example showing how to use the Core NFC API in iOS
Stars: ✭ 480 (-2.83%)
Mutual labels:  example

bytebuf

UPDATE: This implementation is deprecated as the patch is merged to the Go mainline (https://golang.org/cl/133715)

Example of how CL133375 cmd/compile/internal/gc: handle array slice self-assign in esc.go can be utilized to mitigate Go escape analysis limitations.

It shows how to fix problem described in cmd/compile, bytes: bootstrap array causes bytes.Buffer to always be heap-allocated using brand new escape analysis pattern.

Implementation difference

The whole implementation difference can be described as:

type Buffer struct {
	buf       []byte   // contents are the bytes buf[off : len(buf)]
	off       int      // read at &buf[off], write at &buf[len(buf)]
- 	bootstrap [64]byte // memory to hold first slice; helps small buffers avoid allocation.
+ 	bootstrap *[64]byte // memory to hold first slice; helps small buffers avoid allocation.
	lastRead  readOp   // last read operation, so that Unread* can work correctly.
}

With updated escape analysis, it's possible to actually take benefits of bootstrap array, but only if it's not "inlined" into Buffer object. So, we need a pointer to array instead of normal array.

This makes it impossible to use zero value though, hence New function.

Performance comparison before bytes.Buffer optimization in CL133715

These results provided only for historical reference.

Given this code:

buf.Write(s)
globalString = buf.String()

Where s is:

Label Data
empty empty string
5 5-byte string
64 64-byte string
128 128-byte string
1024 1024-byte string
name            old time/op    new time/op    delta
String/empty-8     138ns ±13%      24ns ± 0%   -82.94%  (p=0.000 n=10+8)
String/5-8         186ns ±11%      60ns ± 1%   -67.82%  (p=0.000 n=10+10)
String/64-8        225ns ±10%     108ns ± 6%   -52.26%  (p=0.000 n=10+10)
String/1024-8      889ns ± 0%     740ns ± 1%   -16.78%  (p=0.000 n=9+10)

name            old alloc/op   new alloc/op   delta
String/empty-8      112B ± 0%        0B       -100.00%  (p=0.000 n=10+10)
String/5-8          117B ± 0%        5B ± 0%   -95.73%  (p=0.000 n=10+10)
String/64-8         176B ± 0%       64B ± 0%   -63.64%  (p=0.000 n=10+10)
String/1024-8     2.16kB ± 0%    2.05kB ± 0%    -5.19%  (p=0.000 n=10+10)

name            old allocs/op  new allocs/op  delta
String/empty-8      1.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)
String/5-8          2.00 ± 0%      1.00 ± 0%   -50.00%  (p=0.000 n=10+10)
String/64-8         2.00 ± 0%      1.00 ± 0%   -50.00%  (p=0.000 n=10+10)
String/1024-8       3.00 ± 0%      2.00 ± 0%   -33.33%  (p=0.000 n=10+10)

Performance comparison after bytes.Buffer optimization in CL133715

After improvements to bytes.Buffer from the standard library and updated tests that do bytes.NewBuffer(make([]byte, 0, 64)), results are mostly in favor of bytes.Buffer.

Also note that bytes.Buffer makes it possible to have a custom size stack-allocated slice as a bootstrap storage, so it's overall a better choice.

name            old time/op    new time/op    delta
String/empty-8    23.8ns ± 0%    25.7ns ± 0%   +8.04%  (p=0.000 n=8+8)
String/5-8        59.6ns ± 1%    53.4ns ± 1%  -10.32%  (p=0.000 n=10+10)
String/64-8        102ns ±12%      95ns ± 4%   -6.94%  (p=0.001 n=10+8)
String/1024-8      745ns ± 0%     768ns ± 1%   +3.08%  (p=0.000 n=9+8)

name            old alloc/op   new alloc/op   delta
String/empty-8     0.00B          0.00B          ~     (all equal)
String/5-8         5.00B ± 0%     5.00B ± 0%     ~     (all equal)
String/64-8        64.0B ± 0%     64.0B ± 0%     ~     (all equal)
String/1024-8     2.05kB ± 0%    2.18kB ± 0%   +6.25%  (p=0.000 n=10+10)

name            old allocs/op  new allocs/op  delta
String/empty-8      0.00           0.00          ~     (all equal)
String/5-8          1.00 ± 0%      1.00 ± 0%     ~     (all equal)
String/64-8         1.00 ± 0%      1.00 ± 0%     ~     (all equal)
String/1024-8       2.00 ± 0%      2.00 ± 0%     ~     (all equal)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].