Compare commits

..

2 Commits

Author SHA1 Message Date
Jordi Baylina
3d5aa14cdc 0.5.27 2020-09-17 17:45:44 +02:00
Jordi Baylina
5dc54bb7d2 Optimize recursive constant dependency 2020-09-17 17:42:32 +02:00
3 changed files with 12 additions and 5 deletions

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{ {
"name": "circom", "name": "circom",
"version": "0.5.26", "version": "0.5.27",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "circom", "name": "circom",
"version": "0.5.26", "version": "0.5.27",
"description": "Language to generate logic circuits", "description": "Language to generate logic circuits",
"main": "index.js", "main": "index.js",
"directories": { "directories": {

View File

@@ -346,17 +346,24 @@ async function reduceConstrains(ctx) {
} else { } else {
nextPossibleConstraints = {}; nextPossibleConstraints = {};
} }
removedSignals = new BigArray(); removedSignals = {};
nRemoved = 0; nRemoved = 0;
lIdx = new BigArray(); lIdx = {};
for (let i=0;i<possibleConstraints.length;i++) { for (let i=0;i<possibleConstraints.length;i++) {
if ((ctx.verbose)&&(i%10000 == 0)) { if ((ctx.verbose)&&(i%10000 == 0)) {
await Promise.resolve(); await Promise.resolve();
console.log(`reducing constraints: ${i}/${possibleConstraints.length} reduced: ${nRemoved}`); console.log(`reducing constraints: ${i}/${possibleConstraints.length} reduced: ${nRemoved}`);
} }
const c = ctx.constraints[possibleConstraints[i]]; const c = ctx.constraints[possibleConstraints[i]];
if (!c) continue; if (!c) continue;
// Limit of number of lelements removed per step
if (nRemoved>100000) {
nextPossibleConstraints[possibleConstraints[i]] = true;
continue;
}
// Swap a and b if b has more variables. // Swap a and b if b has more variables.
if (Object.keys(c.b).length > Object.keys(c.a).length) { if (Object.keys(c.b).length > Object.keys(c.a).length) {
const aux = c.a; const aux = c.a;
@@ -434,7 +441,7 @@ async function reduceConstrains(ctx) {
} }
} }
const removedSignalsList = removedSignals.getKeys(); const removedSignalsList = Object.keys(removedSignals);
for (let i=0; i<removedSignalsList.length; i++) { for (let i=0; i<removedSignalsList.length; i++) {
if ((ctx.verbose )&&(i%100000 == 0)) console.log(`removing signals: ${i}/${removedSignalsList.length}`); if ((ctx.verbose )&&(i%100000 == 0)) console.log(`removing signals: ${i}/${removedSignalsList.length}`);