Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
02f54b0c
Commit
02f54b0c
authored
Apr 01, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Docs written, need review.
parent
1590c336
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
127 additions
and
18 deletions
+127
-18
README.md
README.md
+6
-1
page.html
doc/_layouts/page.html
+1
-0
cxx.md
doc/cxx.md
+0
-0
encoding.md
doc/encoding.md
+55
-0
groups-logo.png
doc/images/groups-logo.png
+0
-0
install.md
doc/install.md
+23
-5
language.md
doc/language.md
+1
-11
rpc.md
doc/rpc.md
+9
-0
stylesheet.css
doc/stylesheets/stylesheet.css
+32
-1
No files found.
README.md
View file @
02f54b0c
TODO: Documentation
<img
src=
'http://kentonv.github.com/capnproto/images/infinity-times-faster.png'
style=
'width:334px; height:306px; float: right;'
>
Cap'n Proto is an insanely fast data interchange format and capability-based RPC system. Think
JSON, except binary. Or think
[
Protocol Buffers
](
http://protobuf.googlecode.com
)
, except faster.
In fact, in benchmarks, Cap'n Proto is INFINITY TIMES faster than Protocol Buffers.
[
Read more...
](
http://kentonv.github.com/capnproto/
)
doc/_layouts/page.html
View file @
02f54b0c
...
...
@@ -16,6 +16,7 @@
<!-- HEADER -->
<div
id=
"header_wrap"
class=
"outer"
>
<header
class=
"inner"
>
<a
id=
"discuss_banner"
href=
"https://groups.google.com/group/capnproto"
>
Discuss on Groups
</a>
<a
id=
"forkme_banner"
href=
"https://github.com/kentonv/capnproto"
>
View on GitHub
</a>
<h1
id=
"project_title"
>
Cap'n Proto
</h1>
...
...
doc/cxx.md
0 → 100644
View file @
02f54b0c
This diff is collapsed.
Click to expand it.
doc/encoding.md
View file @
02f54b0c
...
...
@@ -222,3 +222,58 @@ to an object in a segment that is full. If you can't allocate even one word in
the target resides, then you will need to allocate a landing pad in some other segment, and use
this double-far approach. This should be exceedingly rare in practice since pointers are normally
set to point to _new_ objects.
## Serialization Over a Stream
When transmitting a message, the segments must be framed in some way, i.e. to communicate the
number of segments and their sizes before communicating the actual data. The best framing approach
may differ depending on the medium -- for example, messages read via
`mmap`
or shared memory may
call for different approach than messages sent over a socket or a pipe. Cap'n Proto does not
attempt to specify a framing format for every situation. However, since byte streams are by far
the most common transmission medium, Cap'n Proto does define and implement a recommended framing
format for them.
When transmitting over a stream, the following should be sent. All integers are unsigned and
little-endian.
*
(4 bytes) The number of segments, minus one (since there is always at least one segment).
*
(N
*
4 bytes) The size of each segment, in words.
*
(0 or 4 bytes) Padding up to a multiple of words.
*
The content of each segment, in order.
## Packing
For cases where bandwidth usage matters, Cap'n Proto defines a simple compression scheme called
"packing". This scheme is based on the observation that Cap'n Proto messages contain lots of
zero bytes: padding bytes, unset fields, and high-order bytes of small-valued integers.
In packed format, each word of the message is reduced to a tag byte followed by zero to eight
content bytes. The bits of the tag byte correspond to the bytes of the unpacked word, with the
least-significant bit corresponding to the first byte. Each zero bit indicates that the
corresponding byte is zero. The non-zero bytes are packed following the tag.
For example, here is some typical Cap'n Proto data (a struct pointer (offset = 2, data size = 3,
pointer count = 2) followed by a text pointer (offset = 6, length = 53)) and its packed form:
unpacked (hex): 08 00 00 00 03 00 02 00 19 00 00 00 aa 01 00 00
packed (hex): 51 08 03 02 31 19 aa 01
In addition to the above, there are two tag values which are treated specially: 0x00 and 0xff.
*
0x00: The tag is followed by a single byte which indicates a count of consecutive zero-valued
words, minus 1. E.g. if the tag 0x00 is followed by 0x05, the sequence unpacks to 6 words of
zero.
*
0xff: The tag is followed by the bytes of the word as described above, but after those bytes is
another byte with value N. Following that byte is N unpacked words that should be copied
directly. These unpacked words may or may not contain zeros -- it is up to the compressor to
decide when to end the unpacked span and return to packing each word. The purpose of this rule
is to minimize the impact of packing on data that doesn't contain any zeros -- in particular,
long text blobs. Because of this rule, the worst-case space overhead of packing is 2 bytes per
2 KiB of input (256 words = 2KiB).
## Compression
When Cap'n Proto messages may contain repetitive data (especially, large text blobs), it makes sense
to apply a standard compression algorithm in addition to packing. When CPU time is also still
important, we recommend Google's
[
Snappy
](
https://code.google.com/p/snappy/
)
. Otherwise,
[
zlib
](
http://www.zlib.net
)
is probably a good choice.
doc/images/groups-logo.png
0 → 100644
View file @
02f54b0c
1.45 KB
doc/install.md
View file @
02f54b0c
...
...
@@ -4,7 +4,10 @@ layout: page
# Installation
## Cap'n Proto IS NOT READY
## Cap'n Proto is not ready yet
<a class="prominent_link" style="color: #fff"
href="https://groups.google.com/group/capnproto-announce">Sign Up for Updates
</a>
As of this writing, Cap'n Proto is in the very early stages of development. It is still missing
many essential features:
...
...
@@ -20,10 +23,13 @@ many essential features:
end-to-end benchmarks by, like, 2x-5x. We can do better.
*
**RPC:**
The RPC protocol has not yet been specified, much less implemented.
*
**Support for languages other than C++:**
Hasn't been started yet.
*
Many other little things.
Therefore, these instructions are for those that would like to hack on Cap'n Proto. If that's you,
you should join the
[
discussion group
](
https://groups.google.com/group/capnproto
)
!
Therefore, you should only be installing Cap'n Proto at this time if you just want to play around
with it or help develop it. If so, great! Please report your findings to the
[
discussion group
](
https://groups.google.com/group/capnproto
)
.
Or, if you just want to know when it's ready, add yourself to the
[
announce list
](
https://groups.google.com/group/capnproto-announce
)
.
## Installing the Cap'n Proto Compiler
...
...
@@ -58,7 +64,8 @@ changes (via inotify) and immediately rebuilds as necessary. Instant feedback i
productivity, so I really like using Ekam.
Unfortunately it's very much unfinished. It works (for me), but it is quirky and rough around the
edges. It only works on Linux, and is best used together with Eclipse.
edges. It only works on Linux, and is best used together with Eclipse. If you find it
unacceptable, scroll down to the Automake instructions, below.
The Cap'n Proto repo includes a script which will attempt to set up Ekam for you.
...
...
@@ -74,6 +81,14 @@ Once Ekam is installed, you can do:
make -f Makefile.ekam continuous
This will build everything it can and run tests. If successful, the benchmarks will be built
and saved in
`tmp/capnproto/benchmark`
. Try running
`tmp/capnproto/benchmark/runner`
.
Note that Ekam will fail to build some things and output a bunch of error messages. You should
be able to ignore any errors that originate outside of the
`capnproto`
directory -- these are just
parts of other packages like Google Test that Ekam doesn't fully know how to build, but aren't
needed by Cap'n Proto anyway.
If you use Eclipse, you should use the Ekam Eclipse plugin to get build results fed back into your
editor. Build the plugin like so:
...
...
@@ -113,3 +128,6 @@ If setting up Ekam is too much work for you, you can also build with Automake.
autoreconf -i
./configure
make check
sudo make install
This will install libcapnproto.a in /usr/local/lib and headers in /usr/local/include/capnproto.
doc/language.md
View file @
02f54b0c
...
...
@@ -54,7 +54,7 @@ Some notes:
### Comments
Comments are indicated by hash signs and extend to the end of the line
;
Comments are indicated by hash signs and extend to the end of the line
:
{% highlight capnp %}
# This is a comment.
...
...
@@ -310,13 +310,3 @@ A protocol can be changed in the following ways without breaking backwards-compa
Any other change should be assumed NOT to be safe. Also, these rules only apply to the Cap'n Proto
native encoding. It is sometimes useful to transcode Cap'n Proto types to other formats, like
JSON, which may have different rules (e.g., field names cannot change in JSON).
## Running the Compiler
Simply run:
capnpc person.capnp
This will create
`person.capnp.h`
and
`person.capnp.c++`
in the same directory as
`person.capnp`
.
_TODO: This will become more complicated later as we add support for more languages and such._
doc/rpc.md
View file @
02f54b0c
...
...
@@ -14,3 +14,12 @@ Here are some misc planned / hoped-for features:
file descriptor across the socket. Once messages are being allocated in shared memory, RPCs
can be initiated by merely signaling a
[
futex
](
http://man7.org/linux/man-pages/man2/futex.2.html
)
(on Linux, at least), which ought to be ridiculously fast.
*
**Promise Pipelining:**
When an RPC will return a reference to a new remote object, the client
will be able to initiate calls to the returned object before the initial RPC has actually
completed. Essentially, the client says to the server: "Call method
`foo`
of the object to be
returned by RPC id N." Obviously, if the original RPC fails, the dependent call also fails.
Otherwise, the server can start executing the dependent call as soon as the original call
completes, without the need for a network round-trip. In the object-capability programming
language
<a
href=
"http://en.wikipedia.org/wiki/E_(programming_language)"
>
E
</a>
this is known as
[
promise pipelining
](
http://en.wikipedia.org/wiki/Futures_and_promises#Promise_pipelining
)
.
doc/stylesheets/stylesheet.css
View file @
02f54b0c
...
...
@@ -277,7 +277,7 @@ Full-Width Styles
margin
:
0
auto
;
}
#
forkme
_banner
{
#
discuss
_banner
{
display
:
block
;
position
:
absolute
;
top
:
0
;
...
...
@@ -285,6 +285,21 @@ Full-Width Styles
z-index
:
10
;
padding
:
10px
50px
10px
10px
;
color
:
#fff
;
background
:
url('../images/groups-logo.png')
#0090ff
no-repeat
95%
50%
;
font-weight
:
700
;
box-shadow
:
0
0
10px
rgba
(
0
,
0
,
0
,
.5
);
border-bottom-left-radius
:
2px
;
border-bottom-right-radius
:
2px
;
}
#forkme_banner
{
display
:
block
;
position
:
absolute
;
top
:
0
;
right
:
230px
;
z-index
:
10
;
padding
:
10px
50px
10px
10px
;
color
:
#fff
;
background
:
url('../images/blacktocat.png')
#0090ff
no-repeat
95%
50%
;
font-weight
:
700
;
box-shadow
:
0
0
10px
rgba
(
0
,
0
,
0
,
.5
);
...
...
@@ -292,6 +307,22 @@ Full-Width Styles
border-bottom-right-radius
:
2px
;
}
.prominent_link
{
display
:
block
;
float
:
right
;
z-index
:
10
;
padding
:
10px
50px
10px
10px
;
color
:
#fff
;
background
:
url('../images/groups-logo.png')
#0090ff
no-repeat
95%
50%
;
background-color
:
#0090ff
;
font-weight
:
700
;
box-shadow
:
0
0
10px
rgba
(
0
,
0
,
0
,
.5
);
border-top-left-radius
:
2px
;
border-top-right-radius
:
2px
;
border-bottom-left-radius
:
2px
;
border-bottom-right-radius
:
2px
;
}
#header_wrap
{
background
:
#212121
;
background
:
-moz-linear-gradient
(
top
,
#373737
,
#212121
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment