gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated (05e52d4e -> 5e697450)


From: gnunet
Subject: [taler-wallet-core] branch master updated (05e52d4e -> 5e697450)
Date: Fri, 06 Aug 2021 17:17:16 +0200

This is an automated email from the git hooks/post-receive script.

dold pushed a change to branch master
in repository wallet-core.

    from 05e52d4e perf and logging improvements
     new 06db3764 perf: do bulk read
     new 5e697450 debian: bump version

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 debian/changelog                                   |  6 ++++
 .../src/crypto/workers/cryptoApi.ts                |  4 +--
 .../src/crypto/workers/cryptoImplementation.ts     | 38 ++++++++++++----------
 .../taler-wallet-core/src/operations/withdraw.ts   | 10 +-----
 packages/taler-wallet-core/src/util/query.ts       | 11 +++++++
 packages/taler-wallet-core/src/util/timer.ts       | 11 +++----
 6 files changed, 46 insertions(+), 34 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 5b8f09cf..5ff53587 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+taler-wallet-cli (0.0.1-5) unstable; urgency=low
+
+  * Performance improvements.
+
+ -- Florian Dold <dold@taler.net>  Fri, 06 Aug 2021 17:16:18 +0200
+
 taler-wallet-cli (0.0.1-4) unstable; urgency=low
 
   * Deployment linting improvements.
diff --git a/packages/taler-wallet-core/src/crypto/workers/cryptoApi.ts 
b/packages/taler-wallet-core/src/crypto/workers/cryptoApi.ts
index 54609977..da92e83c 100644
--- a/packages/taler-wallet-core/src/crypto/workers/cryptoApi.ts
+++ b/packages/taler-wallet-core/src/crypto/workers/cryptoApi.ts
@@ -82,7 +82,7 @@ interface WorkItem {
   /**
    * Time when the work was submitted to a (non-busy) worker thread.
    */
-  startTime: number;
+  startTime: BigInt;
 }
 
 /**
@@ -291,7 +291,7 @@ export class CryptoApi {
         resolve,
         reject,
         rpcId,
-        startTime: 0,
+        startTime: BigInt(0),
       };
 
       if (this.numBusy === this.workers.length) {
diff --git 
a/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts 
b/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts
index f799fd6e..61134ef6 100644
--- a/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts
+++ b/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts
@@ -106,8 +106,8 @@ function amountToBuffer(amount: AmountJson): Uint8Array {
   if (typeof dvbuf.setBigUint64 !== "undefined") {
     dvbuf.setBigUint64(0, BigInt(amount.value));
   } else {
-    const arr = bigint(amount.value).toArray(2 ** 8).value
-    let offset = 8 - arr.length
+    const arr = bigint(amount.value).toArray(2 ** 8).value;
+    let offset = 8 - arr.length;
     for (let i = 0; i < arr.length; i++) {
       dvbuf.setUint8(offset++, arr[i]);
     }
@@ -126,9 +126,12 @@ function timestampRoundedToBuffer(ts: Timestamp): 
Uint8Array {
     const s = BigInt(tsRounded.t_ms) * BigInt(1000);
     v.setBigUint64(0, s);
   } else {
-    const s = (tsRounded.t_ms === "never" ? bigint.zero : 
bigint(tsRounded.t_ms).times(1000));
-    const arr = s.toArray(2 ** 8).value
-    let offset = 8 - arr.length
+    const s =
+      tsRounded.t_ms === "never"
+        ? bigint.zero
+        : bigint(tsRounded.t_ms).times(1000);
+    const arr = s.toArray(2 ** 8).value;
+    let offset = 8 - arr.length;
     for (let i = 0; i < arr.length; i++) {
       v.setUint8(offset++, arr[i]);
     }
@@ -139,7 +142,7 @@ function timestampRoundedToBuffer(ts: Timestamp): 
Uint8Array {
 class SignaturePurposeBuilder {
   private chunks: Uint8Array[] = [];
 
-  constructor(private purposeNum: number) { }
+  constructor(private purposeNum: number) {}
 
   put(bytes: Uint8Array): SignaturePurposeBuilder {
     this.chunks.push(Uint8Array.from(bytes));
@@ -317,7 +320,8 @@ export class CryptoImplementation {
       .build();
     const sig = decodeCrock(denom.masterSig);
     const pub = decodeCrock(masterPub);
-    return eddsaVerify(p, sig, pub);
+    const res = eddsaVerify(p, sig, pub);
+    return res;
   }
 
   isValidWireAccount(
@@ -550,14 +554,14 @@ export class CryptoImplementation {
   }
 
   benchmark(repetitions: number): BenchmarkResult {
-    let time_hash = 0;
+    let time_hash = BigInt(0);
     for (let i = 0; i < repetitions; i++) {
       const start = timer.performanceNow();
       this.hashString("hello world");
       time_hash += timer.performanceNow() - start;
     }
 
-    let time_hash_big = 0;
+    let time_hash_big = BigInt(0);
     for (let i = 0; i < repetitions; i++) {
       const ba = randomBytes(4096);
       const start = timer.performanceNow();
@@ -565,14 +569,14 @@ export class CryptoImplementation {
       time_hash_big += timer.performanceNow() - start;
     }
 
-    let time_eddsa_create = 0;
+    let time_eddsa_create = BigInt(0);
     for (let i = 0; i < repetitions; i++) {
       const start = timer.performanceNow();
       createEddsaKeyPair();
       time_eddsa_create += timer.performanceNow() - start;
     }
 
-    let time_eddsa_sign = 0;
+    let time_eddsa_sign = BigInt(0);
     const p = randomBytes(4096);
 
     const pair = createEddsaKeyPair();
@@ -585,7 +589,7 @@ export class CryptoImplementation {
 
     const sig = eddsaSign(p, pair.eddsaPriv);
 
-    let time_eddsa_verify = 0;
+    let time_eddsa_verify = BigInt(0);
     for (let i = 0; i < repetitions; i++) {
       const start = timer.performanceNow();
       eddsaVerify(p, sig, pair.eddsaPub);
@@ -595,11 +599,11 @@ export class CryptoImplementation {
     return {
       repetitions,
       time: {
-        hash_small: time_hash,
-        hash_big: time_hash_big,
-        eddsa_create: time_eddsa_create,
-        eddsa_sign: time_eddsa_sign,
-        eddsa_verify: time_eddsa_verify,
+        hash_small: Number(time_hash),
+        hash_big: Number(time_hash_big),
+        eddsa_create: Number(time_eddsa_create),
+        eddsa_sign: Number(time_eddsa_sign),
+        eddsa_verify: Number(time_eddsa_verify),
       },
     };
   }
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts 
b/packages/taler-wallet-core/src/operations/withdraw.ts
index 99d8d7d3..44e62611 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -306,15 +306,7 @@ export async function getCandidateWithdrawalDenoms(
   return await ws.db
     .mktx((x) => ({ denominations: x.denominations }))
     .runReadOnly(async (tx) => {
-      return tx.denominations.indexes.byExchangeBaseUrl
-        .iter(exchangeBaseUrl)
-        .filter((d) => {
-          return (
-            (d.status === DenominationStatus.Unverified ||
-              d.status === DenominationStatus.VerifiedGood) &&
-            !d.isRevoked
-          );
-        });
+      return 
tx.denominations.indexes.byExchangeBaseUrl.getAll(exchangeBaseUrl);
     });
 }
 
diff --git a/packages/taler-wallet-core/src/util/query.ts 
b/packages/taler-wallet-core/src/util/query.ts
index b76bf6b6..a95cbf1f 100644
--- a/packages/taler-wallet-core/src/util/query.ts
+++ b/packages/taler-wallet-core/src/util/query.ts
@@ -35,6 +35,7 @@ import {
   IDBKeyPath,
 } from "@gnu-taler/idb-bridge";
 import { Logger } from "@gnu-taler/taler-util";
+import { performanceNow } from "./timer.js";
 
 const logger = new Logger("query.ts");
 
@@ -298,6 +299,7 @@ export function describeIndex(
 interface IndexReadOnlyAccessor<RecordType> {
   iter(query?: IDBValidKey): ResultStream<RecordType>;
   get(query: IDBValidKey): Promise<RecordType | undefined>;
+  getAll(query: IDBValidKey, count?: number): Promise<RecordType[]>;
 }
 
 type GetIndexReadOnlyAccess<RecordType, IndexMap> = {
@@ -307,6 +309,7 @@ type GetIndexReadOnlyAccess<RecordType, IndexMap> = {
 interface IndexReadWriteAccessor<RecordType> {
   iter(query: IDBValidKey): ResultStream<RecordType>;
   get(query: IDBValidKey): Promise<RecordType | undefined>;
+  getAll(query: IDBValidKey, count?: number): Promise<RecordType[]>;
 }
 
 type GetIndexReadWriteAccess<RecordType, IndexMap> = {
@@ -484,6 +487,10 @@ function makeReadContext(
             .openCursor(query);
           return new ResultStream<any>(req);
         },
+        getAll(query, count) {
+          const req = tx.objectStore(storeName).index(indexName).getAll(query, 
count);
+          return requestToPromise(req);
+        }
       };
     }
     ctx[storeAlias] = {
@@ -526,6 +533,10 @@ function makeWriteContext(
             .openCursor(query);
           return new ResultStream<any>(req);
         },
+        getAll(query, count) {
+          const req = tx.objectStore(storeName).index(indexName).getAll(query, 
count);
+          return requestToPromise(req);
+        }
       };
     }
     ctx[storeAlias] = {
diff --git a/packages/taler-wallet-core/src/util/timer.ts 
b/packages/taler-wallet-core/src/util/timer.ts
index a7fe7dd7..7c849fbc 100644
--- a/packages/taler-wallet-core/src/util/timer.ts
+++ b/packages/taler-wallet-core/src/util/timer.ts
@@ -78,24 +78,23 @@ class TimeoutHandle {
 }
 
 /**
- * Get a performance counter in milliseconds.
+ * Get a performance counter in nanoseconds.
  */
-export const performanceNow: () => number = (() => {
+export const performanceNow: () => bigint = (() => {
   // @ts-ignore
   if (typeof process !== "undefined" && process.hrtime) {
     return () => {
-      const t = process.hrtime();
-      return t[0] * 1e9 + t[1];
+      return process.hrtime.bigint();
     };
   }
 
   // @ts-ignore
   if (typeof performance !== "undefined") {
     // @ts-ignore
-    return () => performance.now();
+    return () => BigInt(performance.now()) * BigInt(1000 * 1000);
   }
 
-  return () => 0;
+  return () => BigInt(0);
 })();
 
 /**

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]