diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /toolkit/components/translations/bergamot-translator/patches | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/translations/bergamot-translator/patches')
-rw-r--r-- | toolkit/components/translations/bergamot-translator/patches/allocation-bergamot.patch | 26 | ||||
-rw-r--r-- | toolkit/components/translations/bergamot-translator/patches/allocation-marian.patch | 25 |
2 files changed, 51 insertions, 0 deletions
diff --git a/toolkit/components/translations/bergamot-translator/patches/allocation-bergamot.patch b/toolkit/components/translations/bergamot-translator/patches/allocation-bergamot.patch new file mode 100644 index 0000000000..a8dca5b7e1 --- /dev/null +++ b/toolkit/components/translations/bergamot-translator/patches/allocation-bergamot.patch @@ -0,0 +1,26 @@ +commit dfa705777729fd084f0187a90f9712eb76ea9209 +parent 05a87784973b6e1cc591f1f1a9a05c5873d9971e +Author: Greg Tatum <tatum.creative@gmail.com> +Date: Tue Nov 7 10:57:07 2023 -0600 + + Change allocation strategy + + This fixes an issue where the memory would grow to 500mb by pre-allocating large + workspaces. For some reason the "workspace" configuration for the Wasm build wasn't + fixing this, but hard-coding the value does. Perhaps the configuration file in Bergamot + is not working correctly, or it was just a mistake on the author's part. Empirically + this value keeps memory from growing too rapidly, and does not degrade Wasm performance. + +diff --git a/src/translator/translation_model.cpp b/src/translator/translation_model.cpp +index 3f91ebb..61a299f 100644 +--- a/src/translator/translation_model.cpp ++++ b/src/translator/translation_model.cpp +@@ -59,7 +59,7 @@ void TranslationModel::loadBackend(size_t idx) { + graph->setDefaultElementType(typeFromString(prec[0])); + graph->setDevice(device_); + graph->getBackend()->configureDevice(options_); +- graph->reserveWorkspaceMB(options_->get<size_t>("workspace")); ++ graph->reserveWorkspaceMB(5); + + // Marian Model: Load from memoryBundle or shortList + if (memory_.model.size() > 0 && diff --git a/toolkit/components/translations/bergamot-translator/patches/allocation-marian.patch b/toolkit/components/translations/bergamot-translator/patches/allocation-marian.patch new file mode 100644 index 0000000000..4fe2616d07 --- /dev/null +++ b/toolkit/components/translations/bergamot-translator/patches/allocation-marian.patch @@ -0,0 +1,25 @@ +commit 31a05b47381a5b22b57fe9af7805fa40a5c5e384 +parent 11c6ae7c46be21ef96ed10c60f28022fa968939f +Author: Greg Tatum <tatum.creative@gmail.com> +Date: Mon Nov 6 14:01:32 2023 -0600 + + Change allocation strategy for tensors + + When tensors grow, they would pre-emptively allocate large amounts of memory, and + would allocate ~500mb of memory for a single translation. Adjusting this value + down appears to fix this issue. Empirically this value keeps memory from growing too + rapidly, and does not degrade Wasm performance. + +diff --git a/src/tensors/tensor_allocator.h b/src/tensors/tensor_allocator.h +index e3bc79f9..66f8e44d 100644 +--- a/src/tensors/tensor_allocator.h ++++ b/src/tensors/tensor_allocator.h +@@ -13,7 +13,7 @@ class TensorAllocator { + private: + const size_t CHUNK = 128; + const size_t MBYTE = 1024 * 1024; +- const size_t GROW = CHUNK * MBYTE; ++ const size_t GROW = MBYTE; + const size_t ALIGN = 256; + + Ptr<Backend> backend_; |