All of lore.kernel.org
 help / color / mirror / Atom feed
* wip-denc
@ 2016-09-13 21:17 Sage Weil
  2016-09-13 23:45 ` wip-denc Mark Nelson
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Sage Weil @ 2016-09-13 21:17 UTC (permalink / raw)
  To: ceph-devel

Hi everyone,

Okay, I have a new wip-denc branch working and ready for some review:

	https://github.com/ceph/ceph/pull/11027

Highlights:

- This includes appender/iterator changes to buffer* to speed up 
encoding and decoding (fewer bounds checks, simpler structures).

- Accordingly, classes/types using the new-style have different arguments 
types for encode/decode.  There is also a new bound_encode() method that 
is used to calculate how big of a buffer to preallocate.

- Most of the important helpers for doing types have new versions that 
work with the new framework (e.g., the ENCODE_START macro has a 
new DENC_START counterpart).

- There is also a mechanism that lets you define the bound_encode, 
encode, and decode methods all in one go using some template magic.  This 
only works for pretty simple types, but it is handy.  It looks like so:

  struct foo_t {
    uint32_t a, b;
    ...
    DENC(foo_t, v, p) {
      DENC_START(1, 1, p);
      denc(v.a, p);
      denc(v.b, p);
      ...
      DENC_FINISH(p);
    }
  };
  WRITE_CLASS_DENC(foo_t)
  

- For new-style types, a new 'denc' function that is overload to do either 
bound_encode, encode, or decode (based on argument types) is defined.  
That means that

  ::denc(v, p);

will work for size_t& p, bufferptr::iterator& p, or 
bufferlist::contiguous_appender& p.  This facilitates the DENC definitions 
above.

- There is glue to invoke new-style encode/decode when old-style encode() 
and decode() are invoked, provided a denc_traits<T> is defined.

- Most of the common containers are there list, vector, set, map, pair, 
but others need to be converted.

- Currently, we're a bit aggressive about using the new-style over the 
old-style when we have the change.  For example, if you have 

  vector<int32_t> foo;
  ::encode(foo, bl);

it will see that it knows how to do int32_t new-style and invoke the 
new-style vector<> code.  I think this is going to be a net win, since 
we avoid doing bounds checks on append for every element (and the 
bound_encode is O(1) for thees base types).  On the other hand, it is 
currently smart enough to not use new-style for individual integer 
types, like so

  int32_t v;
  ::encode(v, bl);

although I suspect after the optimizer gets done with it the generated 
machine code is almost identical.

- Most of the key bluestore types are converted over so that we can do 
some benchmarking.

An overview is at the top of the new denc.h header here:

	https://github.com/liewegas/ceph/blob/wip-denc/src/include/denc.h#L55

I think I've captured the best of Allen's, Varada's, and Sam's various 
approaches, but we'll see how it behaves.  Let me know what you think!

Thanks-
sage


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2016-09-15  0:40 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-13 21:17 wip-denc Sage Weil
2016-09-13 23:45 ` wip-denc Mark Nelson
2016-09-14  0:29   ` wip-denc Somnath Roy
2016-09-14  2:41     ` wip-denc Mark Nelson
2016-09-14  4:05       ` wip-denc Somnath Roy
2016-09-14 11:06         ` wip-denc Mark Nelson
2016-09-14 14:10     ` wip-denc Sage Weil
2016-09-14 14:51       ` wip-denc Somnath Roy
2016-09-14 17:53       ` wip-denc Somnath Roy
2016-09-15  0:39     ` wip-denc Sage Weil
2016-09-14  0:47   ` wip-denc Allen Samuels
2016-09-14  1:18     ` wip-denc Mark Nelson
2016-09-14  9:12 ` wip-denc Joao Eduardo Luis
2016-09-14 13:27   ` wip-denc Sage Weil
2016-09-14 15:03     ` wip-denc Joao Eduardo Luis
2016-09-14 20:31 ` wip-denc Mark Nelson
2016-09-14 20:35   ` wip-denc Somnath Roy
2016-09-14 20:37     ` wip-denc Mark Nelson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.