Removed bergamot translator's wormhole artifacts (#353)

- Use only non-wormhole artifacts
This commit is contained in:
Abhishek Aggarwal 2022-06-07 12:03:54 +02:00 коммит произвёл GitHub
Родитель 0cc9b61d85
Коммит effe595994
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
12 изменённых файлов: 12 добавлений и 3021 удалений

Просмотреть файл

@ -10,7 +10,6 @@ module.exports = {
},
"ignorePatterns": [
"extension/controller/translation/bergamot-translator-worker.js",
"extension/controller/translation/bergamot-translator-worker-without-wormhole.js",
"extension/controller/languageDetection/fasttext.js",
"extension/controller/languageDetection/fasttext_wasm.js",
"extension/model/static/DOMPurify/purify.min.js",

Просмотреть файл

@ -58,9 +58,7 @@ to regenerate JS telemetry schema.
Replace
- `extension/controller/translation/bergamot-translation-worker.js`
- `extension/controller/translation/bergamot-translator-worker-without-wormhole.js`
- `extension/model/static/translation/bergamot-translator-worker-with-wormhole.wasm`
- `extension/model/static/translation/bergamot-translator-worker-without-wormhole.wasm`
- `extension/model/static/translation/bergamot-translator-worker.wasm`
with the new artifacts and then execute:

Просмотреть файл

@ -64,7 +64,6 @@ let cachedEnvInfo = null;
let pingSender = new PingSender();
let modelFastText = null;
let modelFastTextReadyPromise = null;
let platformInfo = null;
let telemetryByTab = new Map();
let pingByTab = new Set();
@ -77,7 +76,6 @@ const CACHE_NAME = "fxtranslations";
const init = () => {
Sentry.wrap(async () => {
platformInfo = await browser.runtime.getPlatformInfo();
cachedEnvInfo = await browser.experiments.telemetryEnvironment.getFxTelemetryMetrics();
telemetryByTab.forEach(t => t.environment(cachedEnvInfo));
});
@ -165,7 +163,7 @@ const messageListener = function(message, sender) {
if (!await isFrameLoaded(sender.tab.id, sender.frameId)) return;
browser.tabs.sendMessage(
sender.tab.id,
{ command: "responseMonitorTabLoad", tabId: sender.tab.id, platformInfo },
{ command: "responseMonitorTabLoad", tabId: sender.tab.id },
{ frameId: sender.frameId }
).catch(onError);
// loading of other frames may be delayed

Просмотреть файл

@ -48,7 +48,6 @@ const translationNotificationManagers = new Map();
setBoolPref("browser.translation.ui.show", false);
setBoolPref("extensions.translations.disabled", false);
setBoolPref("browser.translation.detectLanguage", false);
setBoolPref("javascript.options.wasm_simd_wormhole", true);
}
onShutdown(isAppShutdown) {

Просмотреть файл

@ -17,13 +17,8 @@ class Translation {
this.htmlRegex = new RegExp("<(.*)>.*?|<(.*) />", "gi");
let engineScriptLocalPath = null;
let engineWasmLocalPath = null;
if (this.mediator.platformInfo.arch === "x86-32" || (this.mediator.platformInfo.arch === "x86-64")) {
engineScriptLocalPath = browser.runtime.getURL("controller/translation/bergamot-translator-worker.js");
engineWasmLocalPath = browser.runtime.getURL("model/static/translation/bergamot-translator-worker-with-wormhole.wasm");
} else {
engineScriptLocalPath = browser.runtime.getURL("controller/translation/bergamot-translator-worker-without-wormhole.js");
engineWasmLocalPath = browser.runtime.getURL("model/static/translation/bergamot-translator-worker-without-wormhole.wasm");
}
engineScriptLocalPath = browser.runtime.getURL("controller/translation/bergamot-translator-worker.js");
engineWasmLocalPath = browser.runtime.getURL("model/static/translation/bergamot-translator-worker.wasm");
const serializeErrorScript = browser.runtime.getURL("model/static/errorReporting/serializeError.js");
const version = browser.runtime.getManifest().version;
if (window.Worker) {

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -519,7 +519,7 @@ function loadEmscriptenGlueCode(Module) {
}
function instantiateArrayBuffer(receiver) {
return getBinaryPromise().then(function(binary) {
return WebAssembly.instantiate(binary, info, {simdWormhole:true});
return WebAssembly.instantiate(binary, info);
}).then(function(instance) {
return instance;
}).then(receiver, function(reason) {
@ -532,7 +532,7 @@ function loadEmscriptenGlueCode(Module) {
return fetch(wasmBinaryFile, {
credentials: "same-origin"
}).then(function(response) {
var result = WebAssembly.instantiateStreaming(response, info, {simdWormhole:true});
var result = WebAssembly.instantiateStreaming(response, info);
return result.then(receiveInstantiationResult, function(reason) {
err("wasm streaming compile failed: " + reason);
err("falling back to ArrayBuffer instantiation");

Просмотреть файл

@ -23,7 +23,6 @@ class Mediator {
this.isStarted = false;
browser.runtime.onMessage.addListener(this.bgScriptsMessageListener.bind(this));
this.translationBarDisplayed = false;
this.platformInfo = null;
this.statsMode = false;
this.isMainFrame = window.self === window.top;
}
@ -33,9 +32,8 @@ class Mediator {
}
// main entrypoint to handle the extension's load
start(tabId, platformInfo) {
start(tabId) {
this.tabId = tabId;
this.platformInfo = platformInfo;
if (!this.isStarted && this.isMainFrame) {
this.isStarted = true;
@ -300,7 +298,7 @@ class Mediator {
// eslint-disable-next-line max-lines-per-function
switch (message.command) {
case "responseMonitorTabLoad":
this.start(message.tabId, message.platformInfo);
this.start(message.tabId);
break;
case "responseDetectPageLanguage":
this.languageDetection.setPageLanguage(message.pageLanguage);

Двоичный файл не отображается.

Просмотреть файл

@ -14,5 +14,5 @@ support-files =
enes/lex.50.50.enes.s2t.bin
enes/vocab.esen.spm
enes/model.enes.intgemm.alphas.bin
bergamot-translator-worker-with-wormhole.wasm
bergamot-translator-worker-without-wormhole.wasm
bergamot-translator-worker.wasm

Просмотреть файл

@ -86,6 +86,7 @@ except CalledProcessError as cpe:
print(cpe.output)
sys.exit("Tests with faster gemm failed")
# build and run test for fallback gemm
def disable_faster_gemm(engine_js_artifact_name):
FASTER_GEMM = "mozIntGemm"
DISABLE_FASTER_GEMM = "DISABLE_" + FASTER_GEMM
@ -97,17 +98,7 @@ def disable_faster_gemm(engine_js_artifact_name):
x = x.replace(FASTER_GEMM, DISABLE_FASTER_GEMM)
f.write(x)
def enable_arm_platform():
PLATFORM_DETECTION_FILE = "gecko/browser/extensions/translations/extension/controller/backgroundScript.js"
with open(PLATFORM_DETECTION_FILE, "rt") as f:
x = f.read()
with open(PLATFORM_DETECTION_FILE, "wt") as f:
x = x.replace("platformInfo = await browser.runtime.getPlatformInfo();", "platformInfo = await browser.runtime.getPlatformInfo(); platformInfo.arch = \"arm\";")
f.write(x)
# build and run test for wormhole fallback gemm
print("****** Test with wormhole fallback gemm ******")
print("****** Test with fallback gemm ******")
print("Disabling faster gemm")
disable_faster_gemm("bergamot-translator-worker.js")
@ -120,20 +111,3 @@ try:
except CalledProcessError as cpe:
print(cpe.output)
sys.exit("Tests with fallback gemm failed")
# build and run test for non-wormhole fallback gemm
print("****** Test with non-wormhole fallback gemm ******")
print("Disabling faster gemm")
disable_faster_gemm("bergamot-translator-worker-without-wormhole.js")
print("Hardcoding platform detected as arm")
enable_arm_platform()
try:
print("Building gecko")
subprocess.check_output("./mach build", stderr=subprocess.STDOUT, shell=True, universal_newlines=True, cwd="gecko")
print("Running test with non-wormhole fallback gemm")
subprocess.check_output("./mach test --setpref=fxtranslations.running.mochitest=true browser/extensions/translations/test/browser/browser_translation_test.js", stderr=subprocess.STDOUT, shell=True, universal_newlines=True, cwd="gecko")
print("Test with non-wormhole fallback gemm Succeeded")
except CalledProcessError as cpe:
print(cpe.output)
sys.exit("Tests with non-wormhole fallback gemm failed")