Skip to content

Commit

Permalink
Change default cache size for sequential_writer to a non zero value (#…
Browse files Browse the repository at this point in the history
…533)

* Change default value for max-cache-size to 1MB

Signed-off-by: Jaison Titus <[email protected]>
  • Loading branch information
jaisontj authored and Emerson Knapp committed Feb 17, 2021
1 parent b124188 commit 39c2f21
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
8 changes: 5 additions & 3 deletions ros2bag/ros2bag/verb/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ def add_arguments(self, parser, cli_name): # noqa: D102
'the bag will split at whichever threshold is reached first.'
)
parser.add_argument(
'--max-cache-size', type=int, default=0,
help='maximum amount of messages to hold in cache before writing to disk. '
'Default it is zero, writing every message directly to disk.'
'--max-cache-size', type=int, default=1024*1024,
help='maximum size (in bytes) of messages to hold in cache before writing to disk. '
'Default is 1 mebibyte, everytime the cache size equals or exceeds 1MB, '
'it will be written to disk. If the value specified is 0, then every message is'
'directly written to disk.'
)
parser.add_argument(
'--compression-mode', type=str, default='none',
Expand Down
2 changes: 1 addition & 1 deletion rosbag2_cpp/include/rosbag2_cpp/storage_options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct StorageOptions

// The cache size indiciates how many messages can maximally be hold in cache
// before these being written to disk.
// Defaults to 0, and effectively disables the caching.
// A value of 0 disables caching and every write happens directly to disk.
uint64_t max_cache_size = 0;
};

Expand Down
2 changes: 0 additions & 2 deletions rosbag2_cpp/src/rosbag2_cpp/reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ void Reader::open(const std::string & uri)
rosbag2_cpp::StorageOptions storage_options;
storage_options.uri = uri;
storage_options.storage_id = "sqlite3";
storage_options.max_bagfile_size = 0; // default
storage_options.max_cache_size = 0; // default

rosbag2_cpp::ConverterOptions converter_options{};
return open(storage_options, converter_options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ TEST_F(RecordFixture, record_end_to_end_test_with_zstd_file_compression) {
cmd << "ros2 bag record" <<
" --compression-mode file" <<
" --compression-format zstd" <<
" --max-cache-size 0" <<
" --output " << root_bag_path_.string() <<
" " << topic_name;

Expand Down Expand Up @@ -118,7 +119,7 @@ TEST_F(RecordFixture, record_end_to_end_test) {
wrong_message->string_value = "wrong_content";

auto process_handle = start_execution(
"ros2 bag record --output " + root_bag_path_.string() + " /test_topic");
"ros2 bag record --max-cache-size 0 --output " + root_bag_path_.string() + " /test_topic");
wait_for_db();

pub_man_.add_publisher("/test_topic", message, expected_test_messages);
Expand Down

0 comments on commit 39c2f21

Please sign in to comment.