log warning if shrink fails
#include <vespa/vespalib/stllike/hash_map_equal.hpp>
#include <vespa/vespalib/util/array_equal.hpp>
+#include <vespa/log/log.h>
+LOG_SETUP(".eval.tensor.sparse.sparse_tensor");
+
using vespalib::eval::TensorSpec;
namespace vespalib::tensor {
@@ -107,11 +110,15 @@ Tensor::UP
SparseTensor::clone() const
{
size_t mem_use = _stash.get_memory_usage().usedBytes();
- if (mem_use < (SparseTensor::STASH_CHUNK_SIZE / 4)) {
- Stash stash_copy(mem_use);
+ if (mem_use < (STASH_CHUNK_SIZE / 4)) {
+ size_t aligned_size = (mem_use + 63) & ~(sizeof(char *) - 1);
+ Stash stash_copy(aligned_size);
Cells cells_copy;
copyCells(cells_copy, _cells, stash_copy);
- assert(stash_copy.get_memory_usage().allocatedBytes() < mem_use + 128);
+ if (stash_copy.get_memory_usage().allocatedBytes() * 2 > STASH_CHUNK_SIZE) {
+ LOG(warning, "shrink failed, %zu bytes -> chunksize %zu -> allocated %zu",
+ mem_use, aligned_size, stash_copy.get_memory_usage().allocatedBytes());
+ }
eval::ValueType type_copy = _type;
return std::make_unique<SparseTensor>(std::move(type_copy),
std::move(cells_copy),
