Checkout
stefan2
committed
on 28 Aug 15
[Reverted in r1700797 and re-applied as part of r1700799.]
Introduce a stream wrapper object that adds mark/seek support to any
readable str… Show more
[Reverted in r1700797 and re-applied as part of r1700799.]

Introduce a stream wrapper object that adds mark/seek support to any

readable stream.  Use it on the stdin streams in our CL tools.

As it turns out, parsing data from a stdin byte-by-byte incurs a

massive overhead of 100% internal and 300% system load over a buffered

stream.  'svnadmin load-revprops' sees a 5 times speedup if all data

is in OS disc caches.  This is a realistic assumption in a "final sync

and switch over to new repository" scenario.

The other 2 uses of stdin either have less data to process (svnfsfs

load-index) or parse only a small fraction of the stream (svnadmin load).

To avoid any memory usage issue due to the added buffering, svnadmin

load will not use the stream wrapper - the loader might clean up some

of the pools only once per revision.

* subversion/include/svn_io.h

 (svn_stream_wrap_buffered_read): Declare the new stream constructor API.

* subversion/libsvn_subr/stream.c

 (buffering_stream_wrapper_baton,

  buffering_stream_wrapper_mark): New data structures describing the

                                  wrapper stream and marker states.

 (read_handler_buffering_wrapper,

  decrement_mark_count,

  mark_handler_buffering_wrapper,

  seek_handler_buffering_wrapper,

  data_available_handler_buffering_wrapper,

  is_buffered_handler_buffering_wrapper,

  assert_zero_mark_count): Internal logic of the new stream object.

 (svn_stream_wrap_buffered_read): New constructor implementation.

* subversion/svnadmin/svnadmin.c

 (subcommand_load_revprops): Wrap the stdin stream.

* subversion/svnfsfs/load-index-cmd.c

 (subcommand__load_index): Same.

* subversion/tests/libsvn_subr/stream-test.c

 (struct stream_baton_t,

  read_handler,

  data_available_handler,

  create_test_read_stream): New configurable test read stream.

 (expect_line_content,

  test_stream_buffered_wrapper): New test for the new wrapper stream.

 (test_funcs): Register the new test. Show less