You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/10/18 14:15:16 UTC

[GitHub] [nifi-minifi-cpp] szaszm commented on a diff in pull request #1429: MINIFICPP-1950 - Disable in-memory buffering for FileSystemRepository

szaszm commented on code in PR #1429:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1429#discussion_r996847250


##########
libminifi/src/core/ProcessSession.cpp:
##########
@@ -296,7 +296,7 @@ void ProcessSession::append(const std::shared_ptr<core::FlowFile> &flow, const i
     size_t stream_size_before_callback = stream->size();
     // this prevents an issue if we write, above, with zero length.
     if (stream_size_before_callback > 0)
-      stream->seek(stream_size_before_callback + 1);
+      stream->seek(stream_size_before_callback);

Review Comment:
   Was this a bug?



##########
libminifi/test/unit/FileSystemRepositoryTests.cpp:
##########
@@ -0,0 +1,53 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// loading extensions increases the baseline memory usage
+// as we measure the absolute memory usage that would fail this test
+#define EXTENSION_LIST ""
+
+#include <cstring>
+
+#include "utils/gsl.h"
+#include "utils/OsUtils.h"
+#include "../TestBase.h"
+#include "../Catch.h"
+#include "utils/Literals.h"
+#include "core/repository/FileSystemRepository.h"
+
+TEST_CASE("Test Physical memory usage", "[testphysicalmemoryusage]") {
+  TestController controller;
+  auto dir = controller.createTempDirectory();
+  auto fs_repo = std::make_shared<minifi::core::repository::FileSystemRepository>();
+  auto config = std::make_shared<minifi::Configure>();
+  config->set(minifi::Configure::nifi_dbcontent_repository_directory_default, dir);
+  REQUIRE(fs_repo->initialize(config));
+  const auto start_memory = utils::OsUtils::getCurrentProcessPhysicalMemoryUsage();
+
+  auto content_session = fs_repo->createSession();
+  auto resource_id = content_session->create();
+  auto stream = content_session->write(resource_id);
+  size_t file_size = 20_MB;
+  gsl::span<const char> fragment = "well, hello there";
+  for (size_t i = 0; i < file_size / fragment.size() + 1; ++i) {
+    stream->write(fragment.as_span<const std::byte>());
+  }
+
+  const auto end_memory = utils::OsUtils::getCurrentProcessPhysicalMemoryUsage();

Review Comment:
   Would it make sense to test with commit as well? It doesn't make too much of a difference now, but maybe it can catch something in the future. What do you think?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org