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/06 08:20:19 UTC

[GitHub] [nifi-minifi-cpp] adamdebreceni opened a new pull request, #1429: MINIFICPP-1950 - Disable in-memory buffering for FileSystemRepository

adamdebreceni opened a new pull request, #1429:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1429

   Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [ ] Is there a JIRA ticket associated with this PR? Is it referenced
        in the commit message?
   
   - [ ] Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
   
   - [ ] Has your PR been rebased against the latest commit within the target branch (typically main)?
   
   - [ ] Is your initial contribution a single, squashed commit?
   
   ### For code changes:
   - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
   - [ ] If applicable, have you updated the LICENSE file?
   - [ ] If applicable, have you updated the NOTICE file?
   
   ### For documentation related changes:
   - [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
   
   ### Note:
   Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.
   


-- 
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


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

Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on code in PR #1429:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1429#discussion_r996791850


##########
libminifi/src/core/BufferedContentSession.cpp:
##########
@@ -16,58 +16,57 @@
  * limitations under the License.
  */
 
+#include "core/BufferedContentSession.h"
 #include <memory>
 #include "core/ContentRepository.h"
-#include "core/ContentSession.h"
 #include "ResourceClaim.h"
 #include "io/BaseStream.h"
 #include "Exception.h"
 #include "utils/gsl.h"
 
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace core {
+namespace org::apache::nifi::minifi::core {
 
-ContentSession::ContentSession(std::shared_ptr<ContentRepository> repository) : repository_(std::move(repository)) {}
+BufferedContentSession::BufferedContentSession(std::shared_ptr<ContentRepository> repository) : repository_(std::move(repository)) {}
 
-std::shared_ptr<ResourceClaim> ContentSession::create() {
+std::shared_ptr<ResourceClaim> BufferedContentSession::create() {
   std::shared_ptr<ResourceClaim> claim = std::make_shared<ResourceClaim>(repository_);
-  managedResources_[claim] = std::make_shared<io::BufferStream>();
+  managed_resources_[claim] = std::make_shared<io::BufferStream>();
   return claim;
 }
 
-std::shared_ptr<io::BaseStream> ContentSession::write(const std::shared_ptr<ResourceClaim>& resourceId, WriteMode mode) {
-  auto it = managedResources_.find(resourceId);
-  if (it == managedResources_.end()) {
-    if (mode == WriteMode::OVERWRITE) {
-      throw Exception(REPOSITORY_EXCEPTION, "Can only overwrite owned resource");
-    }
-    auto& extension = extendedResources_[resourceId];
+std::shared_ptr<io::BaseStream> BufferedContentSession::write(const std::shared_ptr<ResourceClaim>& resource_id) {
+  auto it = managed_resources_.find(resource_id);
+  if (it == managed_resources_.end()) {
+    throw Exception(REPOSITORY_EXCEPTION, "Can only overwrite owned resource");
+  }
+  it->second = std::make_shared<io::BufferStream>();
+  return it->second;
+}
+
+std::shared_ptr<io::BaseStream> BufferedContentSession::append(const std::shared_ptr<ResourceClaim>& resource_id) {
+  auto it = managed_resources_.find(resource_id);
+  if (it == managed_resources_.end()) {
+    auto& extension = extended_resources_[resource_id];
     if (!extension) {
       extension = std::make_shared<io::BufferStream>();
     }
     return extension;
   }

Review Comment:
   same here, changed it, but not exactly to the suggestion



-- 
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


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

Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on code in PR #1429:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1429#discussion_r1000200267


##########
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:
   yes it would make sense but it would require some further consideration so I would not add it to this PR



-- 
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


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

Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on code in PR #1429:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1429#discussion_r996789874


##########
libminifi/src/core/BufferedContentSession.cpp:
##########
@@ -16,58 +16,57 @@
  * limitations under the License.
  */
 
+#include "core/BufferedContentSession.h"
 #include <memory>
 #include "core/ContentRepository.h"
-#include "core/ContentSession.h"
 #include "ResourceClaim.h"
 #include "io/BaseStream.h"
 #include "Exception.h"
 #include "utils/gsl.h"

Review Comment:
   removed



-- 
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


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

Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on code in PR #1429:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1429#discussion_r996791299


##########
libminifi/src/core/BufferedContentSession.cpp:
##########
@@ -16,58 +16,57 @@
  * limitations under the License.
  */
 
+#include "core/BufferedContentSession.h"
 #include <memory>
 #include "core/ContentRepository.h"
-#include "core/ContentSession.h"
 #include "ResourceClaim.h"
 #include "io/BaseStream.h"
 #include "Exception.h"
 #include "utils/gsl.h"
 
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace core {
+namespace org::apache::nifi::minifi::core {
 
-ContentSession::ContentSession(std::shared_ptr<ContentRepository> repository) : repository_(std::move(repository)) {}
+BufferedContentSession::BufferedContentSession(std::shared_ptr<ContentRepository> repository) : repository_(std::move(repository)) {}
 
-std::shared_ptr<ResourceClaim> ContentSession::create() {
+std::shared_ptr<ResourceClaim> BufferedContentSession::create() {
   std::shared_ptr<ResourceClaim> claim = std::make_shared<ResourceClaim>(repository_);
-  managedResources_[claim] = std::make_shared<io::BufferStream>();
+  managed_resources_[claim] = std::make_shared<io::BufferStream>();
   return claim;
 }
 
-std::shared_ptr<io::BaseStream> ContentSession::write(const std::shared_ptr<ResourceClaim>& resourceId, WriteMode mode) {
-  auto it = managedResources_.find(resourceId);
-  if (it == managedResources_.end()) {
-    if (mode == WriteMode::OVERWRITE) {
-      throw Exception(REPOSITORY_EXCEPTION, "Can only overwrite owned resource");
-    }
-    auto& extension = extendedResources_[resourceId];
+std::shared_ptr<io::BaseStream> BufferedContentSession::write(const std::shared_ptr<ResourceClaim>& resource_id) {
+  auto it = managed_resources_.find(resource_id);
+  if (it == managed_resources_.end()) {
+    throw Exception(REPOSITORY_EXCEPTION, "Can only overwrite owned resource");
+  }
+  it->second = std::make_shared<io::BufferStream>();
+  return it->second;

Review Comment:
   changed it but not exactly like this, do you agree with the new version



-- 
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


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

Posted by GitBox <gi...@apache.org>.
martinzink commented on code in PR #1429:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1429#discussion_r995625105


##########
libminifi/src/core/ForwardingContentSession.cpp:
##########
@@ -0,0 +1,62 @@
+/**
+ *
+ * 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.
+ */
+
+#include "core/ForwardingContentSession.h"
+
+#include <memory>
+
+#include "core/ContentRepository.h"
+#include "ResourceClaim.h"
+#include "io/BaseStream.h"
+#include "Exception.h"
+
+namespace org::apache::nifi::minifi::core {
+
+ForwardingContentSession::ForwardingContentSession(std::shared_ptr<ContentRepository> repository) : repository_(std::move(repository)) {}
+
+std::shared_ptr<ResourceClaim> ForwardingContentSession::create() {
+  auto claim = std::make_shared<ResourceClaim>(repository_);
+  created_claims_.insert(claim);
+  return claim;
+}
+
+std::shared_ptr<io::BaseStream> ForwardingContentSession::write(const std::shared_ptr<ResourceClaim>& resource_id) {
+  if (created_claims_.find(resource_id) == created_claims_.end()) {

Review Comment:
   ```suggestion
     if (!created_claims_.contains(resource_id)) {
   ```



##########
libminifi/src/core/BufferedContentSession.cpp:
##########
@@ -16,58 +16,57 @@
  * limitations under the License.
  */
 
+#include "core/BufferedContentSession.h"
 #include <memory>
 #include "core/ContentRepository.h"
-#include "core/ContentSession.h"
 #include "ResourceClaim.h"
 #include "io/BaseStream.h"
 #include "Exception.h"
 #include "utils/gsl.h"

Review Comment:
   I think this `#include "utils/gsl.h"` is unused



##########
libminifi/src/core/BufferedContentSession.cpp:
##########
@@ -16,58 +16,57 @@
  * limitations under the License.
  */
 
+#include "core/BufferedContentSession.h"
 #include <memory>
 #include "core/ContentRepository.h"
-#include "core/ContentSession.h"
 #include "ResourceClaim.h"
 #include "io/BaseStream.h"
 #include "Exception.h"
 #include "utils/gsl.h"
 
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace core {
+namespace org::apache::nifi::minifi::core {
 
-ContentSession::ContentSession(std::shared_ptr<ContentRepository> repository) : repository_(std::move(repository)) {}
+BufferedContentSession::BufferedContentSession(std::shared_ptr<ContentRepository> repository) : repository_(std::move(repository)) {}
 
-std::shared_ptr<ResourceClaim> ContentSession::create() {
+std::shared_ptr<ResourceClaim> BufferedContentSession::create() {
   std::shared_ptr<ResourceClaim> claim = std::make_shared<ResourceClaim>(repository_);
-  managedResources_[claim] = std::make_shared<io::BufferStream>();
+  managed_resources_[claim] = std::make_shared<io::BufferStream>();
   return claim;
 }
 
-std::shared_ptr<io::BaseStream> ContentSession::write(const std::shared_ptr<ResourceClaim>& resourceId, WriteMode mode) {
-  auto it = managedResources_.find(resourceId);
-  if (it == managedResources_.end()) {
-    if (mode == WriteMode::OVERWRITE) {
-      throw Exception(REPOSITORY_EXCEPTION, "Can only overwrite owned resource");
-    }
-    auto& extension = extendedResources_[resourceId];
+std::shared_ptr<io::BaseStream> BufferedContentSession::write(const std::shared_ptr<ResourceClaim>& resource_id) {
+  auto it = managed_resources_.find(resource_id);
+  if (it == managed_resources_.end()) {
+    throw Exception(REPOSITORY_EXCEPTION, "Can only overwrite owned resource");
+  }
+  it->second = std::make_shared<io::BufferStream>();
+  return it->second;

Review Comment:
   ```suggestion
     if (!managed_resources_.contains(resource_id))
       throw Exception(REPOSITORY_EXCEPTION, "Can only overwrite owned resource");
     return managed_resources_.at(resource_id) = std::make_shared<io::BufferStream>();
   ```



##########
libminifi/src/core/BufferedContentSession.cpp:
##########
@@ -16,58 +16,57 @@
  * limitations under the License.
  */
 
+#include "core/BufferedContentSession.h"
 #include <memory>
 #include "core/ContentRepository.h"
-#include "core/ContentSession.h"
 #include "ResourceClaim.h"
 #include "io/BaseStream.h"
 #include "Exception.h"
 #include "utils/gsl.h"
 
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace core {
+namespace org::apache::nifi::minifi::core {
 
-ContentSession::ContentSession(std::shared_ptr<ContentRepository> repository) : repository_(std::move(repository)) {}
+BufferedContentSession::BufferedContentSession(std::shared_ptr<ContentRepository> repository) : repository_(std::move(repository)) {}
 
-std::shared_ptr<ResourceClaim> ContentSession::create() {
+std::shared_ptr<ResourceClaim> BufferedContentSession::create() {
   std::shared_ptr<ResourceClaim> claim = std::make_shared<ResourceClaim>(repository_);
-  managedResources_[claim] = std::make_shared<io::BufferStream>();
+  managed_resources_[claim] = std::make_shared<io::BufferStream>();
   return claim;
 }
 
-std::shared_ptr<io::BaseStream> ContentSession::write(const std::shared_ptr<ResourceClaim>& resourceId, WriteMode mode) {
-  auto it = managedResources_.find(resourceId);
-  if (it == managedResources_.end()) {
-    if (mode == WriteMode::OVERWRITE) {
-      throw Exception(REPOSITORY_EXCEPTION, "Can only overwrite owned resource");
-    }
-    auto& extension = extendedResources_[resourceId];
+std::shared_ptr<io::BaseStream> BufferedContentSession::write(const std::shared_ptr<ResourceClaim>& resource_id) {
+  auto it = managed_resources_.find(resource_id);
+  if (it == managed_resources_.end()) {
+    throw Exception(REPOSITORY_EXCEPTION, "Can only overwrite owned resource");
+  }
+  it->second = std::make_shared<io::BufferStream>();
+  return it->second;
+}
+
+std::shared_ptr<io::BaseStream> BufferedContentSession::append(const std::shared_ptr<ResourceClaim>& resource_id) {
+  auto it = managed_resources_.find(resource_id);
+  if (it == managed_resources_.end()) {
+    auto& extension = extended_resources_[resource_id];
     if (!extension) {
       extension = std::make_shared<io::BufferStream>();
     }
     return extension;
   }
-  if (mode == WriteMode::OVERWRITE) {
-    it->second = std::make_shared<io::BufferStream>();
-  }
   return it->second;
 }
 
-std::shared_ptr<io::BaseStream> ContentSession::read(const std::shared_ptr<ResourceClaim>& resourceId) {
+std::shared_ptr<io::BaseStream> BufferedContentSession::read(const std::shared_ptr<ResourceClaim>& resource_id) {
   // TODO(adebreceni):
   //  after the stream refactor is merged we should be able to share the underlying buffer
   //  between multiple InputStreams, moreover create a ConcatInputStream
-  if (managedResources_.find(resourceId) != managedResources_.end() || extendedResources_.find(resourceId) != extendedResources_.end()) {
+  if (managed_resources_.find(resource_id) != managed_resources_.end() || extended_resources_.find(resource_id) != extended_resources_.end()) {

Review Comment:
   ```suggestion
     if (managed_resources_.contains(resource_id) || extended_resources_.contains(resource_id)) {
   ```



##########
libminifi/src/core/BufferedContentSession.cpp:
##########
@@ -16,58 +16,57 @@
  * limitations under the License.
  */
 
+#include "core/BufferedContentSession.h"
 #include <memory>
 #include "core/ContentRepository.h"
-#include "core/ContentSession.h"
 #include "ResourceClaim.h"
 #include "io/BaseStream.h"
 #include "Exception.h"
 #include "utils/gsl.h"
 
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace core {
+namespace org::apache::nifi::minifi::core {
 
-ContentSession::ContentSession(std::shared_ptr<ContentRepository> repository) : repository_(std::move(repository)) {}
+BufferedContentSession::BufferedContentSession(std::shared_ptr<ContentRepository> repository) : repository_(std::move(repository)) {}
 
-std::shared_ptr<ResourceClaim> ContentSession::create() {
+std::shared_ptr<ResourceClaim> BufferedContentSession::create() {
   std::shared_ptr<ResourceClaim> claim = std::make_shared<ResourceClaim>(repository_);
-  managedResources_[claim] = std::make_shared<io::BufferStream>();
+  managed_resources_[claim] = std::make_shared<io::BufferStream>();
   return claim;
 }
 
-std::shared_ptr<io::BaseStream> ContentSession::write(const std::shared_ptr<ResourceClaim>& resourceId, WriteMode mode) {
-  auto it = managedResources_.find(resourceId);
-  if (it == managedResources_.end()) {
-    if (mode == WriteMode::OVERWRITE) {
-      throw Exception(REPOSITORY_EXCEPTION, "Can only overwrite owned resource");
-    }
-    auto& extension = extendedResources_[resourceId];
+std::shared_ptr<io::BaseStream> BufferedContentSession::write(const std::shared_ptr<ResourceClaim>& resource_id) {
+  auto it = managed_resources_.find(resource_id);
+  if (it == managed_resources_.end()) {
+    throw Exception(REPOSITORY_EXCEPTION, "Can only overwrite owned resource");
+  }
+  it->second = std::make_shared<io::BufferStream>();
+  return it->second;
+}
+
+std::shared_ptr<io::BaseStream> BufferedContentSession::append(const std::shared_ptr<ResourceClaim>& resource_id) {
+  auto it = managed_resources_.find(resource_id);
+  if (it == managed_resources_.end()) {
+    auto& extension = extended_resources_[resource_id];
     if (!extension) {
       extension = std::make_shared<io::BufferStream>();
     }
     return extension;
   }

Review Comment:
   ```suggestion
     if (managed_resources_.contains(resource_id))
       return managed_resources_.at(resource_id);
     auto& extension = extended_resources_[resource_id];
     if (!extension) {
       extension = std::make_shared<io::BufferStream>();
     }
     return extension;
   ```



-- 
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


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

Posted by GitBox <gi...@apache.org>.
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


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

Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on code in PR #1429:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1429#discussion_r1000197426


##########
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:
   yes, unclear why we seek to `size + 1` instead of `size`, but it has been like this since the beginning, since `BufferStream::seek` does not affect write only read it was basically noop while with `FileStream` this is a problem



-- 
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


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

Posted by GitBox <gi...@apache.org>.
szaszm closed pull request #1429: MINIFICPP-1950 - Disable in-memory buffering for FileSystemRepository
URL: https://github.com/apache/nifi-minifi-cpp/pull/1429


-- 
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