@blinklabs/dingo 0.18.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,13 @@ Store blockchain data (blocks, transactions, etc.). Examples:
14
14
  - `gcs` - Google Cloud Storage
15
15
  - `s3` - AWS S3
16
16
 
17
+ #### Iterator lifetime note
18
+ Blob plugins expose iterators via `NewIterator(txn, opts)`. Items returned by the
19
+ iterator's `Item()` must only be accessed while the transaction used to create
20
+ the iterator is still active — implementations may validate transaction state at
21
+ access time and will return errors if the transaction has been committed or
22
+ rolled back. See `database/types/types.go` `BlobIterator` for details.
23
+
17
24
  ### Metadata Storage Plugins
18
25
  Store metadata and indexes. Examples:
19
26
  - `sqlite` - SQLite relational database
@@ -134,17 +134,20 @@ parse_benchmark() {
134
134
  echo "$formatted_name|$ops_sec|$time_op|$mem_op|$allocs_op"
135
135
  }
136
136
 
137
- # Parse current results into associative array
138
- declare -A current_results
137
+ # Parse current results into temporary file
138
+ CURRENT_RESULTS_FILE=$(mktemp "${TMPDIR:-/tmp}/dingo_bench_XXXXXX")
139
139
  while IFS= read -r line; do
140
140
  if [[ "$line" =~ ^Benchmark ]]; then
141
141
  parsed=$(parse_benchmark "$line")
142
142
  name=$(echo "$parsed" | cut -d'|' -f1)
143
143
  data=$(echo "$parsed" | cut -d'|' -f2-)
144
- current_results["$name"]="$data"
144
+ echo "$name|$data" >> "$CURRENT_RESULTS_FILE"
145
145
  fi
146
146
  done <<< "$BENCHMARK_OUTPUT"
147
147
 
148
+ # Deduplicate benchmark names
149
+ sort -t'|' -k1,1 -u "$CURRENT_RESULTS_FILE" > "$CURRENT_RESULTS_FILE.tmp" && mv "$CURRENT_RESULTS_FILE.tmp" "$CURRENT_RESULTS_FILE"
150
+
148
151
  # Display current results summary
149
152
  echo "Current Benchmark Summary"
150
153
  echo "-------------------------"
@@ -172,7 +175,8 @@ echo "$BENCHMARK_OUTPUT" | grep "^Benchmark" | sort -k5 -nr | head -3 | while re
172
175
  done
173
176
 
174
177
  # Read previous results if file exists and we're comparing
175
- declare -A previous_results
178
+ PREVIOUS_RESULTS_FILE=$(mktemp "${TMPDIR:-/tmp}/dingo_bench_XXXXXX")
179
+ trap 'rm -f "$CURRENT_RESULTS_FILE" "$PREVIOUS_RESULTS_FILE"' EXIT
176
180
  previous_date=""
177
181
  MAJOR_CHANGES=false
178
182
 
@@ -201,7 +205,7 @@ if [[ -f "$OUTPUT_FILE" && "$WRITE_TO_FILE" == "true" ]]; then
201
205
  mem_op=$(echo "$line" | sed 's/^| //' | cut -d'|' -f4 | sed 's/ //g')
202
206
  allocs_op=$(echo "$line" | sed 's/^| //' | cut -d'|' -f5 | sed 's/ //g')
203
207
  if [[ -n "$benchmark" && -n "$ops_sec" ]]; then
204
- previous_results["$benchmark"]="$ops_sec|$time_op|$mem_op|$allocs_op"
208
+ echo "$benchmark|$ops_sec|$time_op|$mem_op|$allocs_op" >> "$PREVIOUS_RESULTS_FILE"
205
209
  fi
206
210
  fi
207
211
  if [[ "$in_table" == true && "$line" == "" ]]; then
@@ -210,20 +214,42 @@ if [[ -f "$OUTPUT_FILE" && "$WRITE_TO_FILE" == "true" ]]; then
210
214
  done < "$OUTPUT_FILE"
211
215
  fi
212
216
 
217
+ # Deduplicate previous benchmark names
218
+ sort -t'|' -k1,1 -u "$PREVIOUS_RESULTS_FILE" > "$PREVIOUS_RESULTS_FILE.tmp" && mv "$PREVIOUS_RESULTS_FILE.tmp" "$PREVIOUS_RESULTS_FILE"
219
+
220
+ # Helper functions to get data from temp files
221
+ get_current_data() {
222
+ local benchmark="$1"
223
+ awk -F'|' '$1 == "'"$benchmark"'" {print substr($0, index($0, "|")+1)}' "$CURRENT_RESULTS_FILE"
224
+ }
225
+
226
+ get_previous_data() {
227
+ local benchmark="$1"
228
+ awk -F'|' '$1 == "'"$benchmark"'" {print substr($0, index($0, "|")+1)}' "$PREVIOUS_RESULTS_FILE"
229
+ }
230
+
231
+ list_current_benchmarks() {
232
+ awk -F'|' '!seen[$1]++ {print $1}' "$CURRENT_RESULTS_FILE"
233
+ }
234
+
235
+ list_previous_benchmarks() {
236
+ awk -F'|' '!seen[$1]++ {print $1}' "$PREVIOUS_RESULTS_FILE"
237
+ }
238
+
213
239
  # Generate performance comparison if we have previous results
214
240
  if [[ -n "$previous_date" && "$WRITE_TO_FILE" == "true" ]]; then
215
241
  # Track changes
216
- declare -a faster_benchmarks
217
- declare -a slower_benchmarks
218
- declare -a new_benchmarks
219
- declare -a removed_benchmarks
242
+ faster_benchmarks=""
243
+ slower_benchmarks=""
244
+ new_benchmarks=""
245
+ removed_benchmarks=""
220
246
 
221
247
  # Compare results
222
- for benchmark in "${!current_results[@]}"; do
223
- if [[ -n "${previous_results[$benchmark]}" ]]; then
248
+ while IFS= read -r benchmark; do
249
+ if [[ -n "$(get_previous_data "$benchmark")" ]]; then
224
250
  # Benchmark exists in both
225
- current_data="${current_results[$benchmark]}"
226
- previous_data="${previous_results[$benchmark]}"
251
+ current_data=$(get_current_data "$benchmark")
252
+ previous_data=$(get_previous_data "$benchmark")
227
253
 
228
254
  current_ops=$(echo "$current_data" | cut -d'|' -f1)
229
255
  previous_ops=$(echo "$previous_data" | cut -d'|' -f1)
@@ -231,31 +257,41 @@ if [[ -n "$previous_date" && "$WRITE_TO_FILE" == "true" ]]; then
231
257
  if [[ "$current_ops" =~ ^[0-9]+$ && "$previous_ops" =~ ^[0-9]+$ && $previous_ops -gt 0 ]]; then
232
258
  change=$(( (current_ops - previous_ops) * 100 / previous_ops ))
233
259
  if [[ $change -gt 10 ]]; then
234
- faster_benchmarks+=("$benchmark (+${change}%)")
260
+ faster_benchmarks="$faster_benchmarks
261
+ $benchmark (+${change}%)"
235
262
  elif [[ $change -lt -10 ]]; then
236
263
  change_abs=$(( (previous_ops - current_ops) * 100 / previous_ops ))
237
- slower_benchmarks+=("$benchmark (-${change_abs}%)")
264
+ slower_benchmarks="$slower_benchmarks
265
+ $benchmark (-${change_abs}%)"
238
266
  MAJOR_CHANGES=true
239
267
  fi
240
268
  fi
241
269
  else
242
- new_benchmarks+=("$benchmark")
270
+ new_benchmarks="$new_benchmarks
271
+ $benchmark"
243
272
  fi
244
- done
273
+ done < <(list_current_benchmarks)
245
274
 
246
275
  # Check for removed benchmarks
247
- for benchmark in "${!previous_results[@]}"; do
248
- if [[ -z "${current_results[$benchmark]}" ]]; then
249
- removed_benchmarks+=("$benchmark")
276
+ while IFS= read -r benchmark; do
277
+ if [[ -z "$(get_current_data "$benchmark")" ]]; then
278
+ removed_benchmarks="$removed_benchmarks
279
+ $benchmark"
250
280
  fi
251
- done
281
+ done < <(list_previous_benchmarks)
282
+
283
+ # Count items (remove empty lines and count)
284
+ faster_count=$(echo "$faster_benchmarks" | grep -c "^." || echo "0")
285
+ slower_count=$(echo "$slower_benchmarks" | grep -c "^." || echo "0")
286
+ new_count=$(echo "$new_benchmarks" | grep -c "^." || echo "0")
287
+ removed_count=$(echo "$removed_benchmarks" | grep -c "^." || echo "0")
252
288
 
253
289
  echo ""
254
290
  echo "Performance Changes Summary:"
255
- echo " Faster: ${#faster_benchmarks[@]} | Slower: ${#slower_benchmarks[@]} | New: ${#new_benchmarks[@]} | Removed: ${#removed_benchmarks[@]}"
291
+ echo " Faster: $faster_count | Slower: $slower_count | New: $new_count | Removed: $removed_count"
256
292
 
257
293
  # Report changes if any improvements, regressions, or new benchmarks detected
258
- if [[ ${#faster_benchmarks[@]} -gt 0 || ${#slower_benchmarks[@]} -gt 0 || ${#new_benchmarks[@]} -gt 0 ]]; then
294
+ if [[ $faster_count -gt 0 || $slower_count -gt 0 || $new_count -gt 0 ]]; then
259
295
  MAJOR_CHANGES=true
260
296
  fi
261
297
  fi
@@ -285,17 +321,17 @@ if [[ "$WRITE_TO_FILE" == "true" ]]; then
285
321
  echo ""
286
322
 
287
323
  # Track changes
288
- declare -a faster_benchmarks
289
- declare -a slower_benchmarks
290
- declare -a new_benchmarks
291
- declare -a removed_benchmarks
324
+ faster_benchmarks=""
325
+ slower_benchmarks=""
326
+ new_benchmarks=""
327
+ removed_benchmarks=""
292
328
 
293
329
  # Compare results
294
- for benchmark in "${!current_results[@]}"; do
295
- if [[ -n "${previous_results[$benchmark]}" ]]; then
330
+ while IFS= read -r benchmark; do
331
+ if [[ -n "$(get_previous_data "$benchmark")" ]]; then
296
332
  # Benchmark exists in both
297
- current_data="${current_results[$benchmark]}"
298
- previous_data="${previous_results[$benchmark]}"
333
+ current_data=$(get_current_data "$benchmark")
334
+ previous_data=$(get_previous_data "$benchmark")
299
335
 
300
336
  current_ops=$(echo "$current_data" | cut -d'|' -f1)
301
337
  previous_ops=$(echo "$previous_data" | cut -d'|' -f1)
@@ -303,52 +339,62 @@ if [[ "$WRITE_TO_FILE" == "true" ]]; then
303
339
  if [[ "$current_ops" =~ ^[0-9]+$ && "$previous_ops" =~ ^[0-9]+$ && $previous_ops -gt 0 ]]; then
304
340
  if [[ $current_ops -gt $previous_ops ]]; then
305
341
  change=$(( (current_ops - previous_ops) * 100 / previous_ops ))
306
- faster_benchmarks+=("$benchmark (+${change}%)")
342
+ faster_benchmarks="$faster_benchmarks
343
+ $benchmark (+${change}%)"
307
344
  elif [[ $current_ops -lt $previous_ops ]]; then
308
345
  change=$(( (previous_ops - current_ops) * 100 / previous_ops ))
309
- slower_benchmarks+=("$benchmark (-${change}%)")
346
+ slower_benchmarks="$slower_benchmarks
347
+ $benchmark (-${change}%)"
310
348
  fi
311
349
  fi
312
350
  else
313
- new_benchmarks+=("$benchmark")
351
+ new_benchmarks="$new_benchmarks
352
+ $benchmark"
314
353
  fi
315
- done
354
+ done < <(list_current_benchmarks)
316
355
 
317
356
  # Check for removed benchmarks
318
- for benchmark in "${!previous_results[@]}"; do
319
- if [[ -z "${current_results[$benchmark]}" ]]; then
320
- removed_benchmarks+=("$benchmark")
357
+ while IFS= read -r benchmark; do
358
+ if [[ -z "$(get_current_data "$benchmark")" ]]; then
359
+ removed_benchmarks="$removed_benchmarks
360
+ $benchmark"
321
361
  fi
322
- done
362
+ done < <(list_previous_benchmarks)
363
+
364
+ # Count items
365
+ faster_count=$(echo "$faster_benchmarks" | grep -c "^." || echo "0")
366
+ slower_count=$(echo "$slower_benchmarks" | grep -c "^." || echo "0")
367
+ new_count=$(echo "$new_benchmarks" | grep -c "^." || echo "0")
368
+ removed_count=$(echo "$removed_benchmarks" | grep -c "^." || echo "0")
323
369
 
324
370
  echo "### Summary"
325
- echo "- **Faster benchmarks**: ${#faster_benchmarks[@]}"
326
- echo "- **Slower benchmarks**: ${#slower_benchmarks[@]}"
327
- echo "- **New benchmarks**: ${#new_benchmarks[@]}"
328
- echo "- **Removed benchmarks**: ${#removed_benchmarks[@]}"
371
+ echo "- **Faster benchmarks**: $faster_count"
372
+ echo "- **Slower benchmarks**: $slower_count"
373
+ echo "- **New benchmarks**: $new_count"
374
+ echo "- **Removed benchmarks**: $removed_count"
329
375
  echo ""
330
376
 
331
- if [[ ${#faster_benchmarks[@]} -gt 0 ]]; then
377
+ if [[ $faster_count -gt 0 ]]; then
332
378
  echo "### Top Improvements"
333
- printf '%s\n' "${faster_benchmarks[@]}" | sort -t'(' -k2 -nr | head -5 | sed 's/^/- /'
379
+ echo "$faster_benchmarks" | grep "^." | sort -t'(' -k2 -nr | head -5 | sed 's/^/- /'
334
380
  echo ""
335
381
  fi
336
382
 
337
- if [[ ${#slower_benchmarks[@]} -gt 0 ]]; then
383
+ if [[ $slower_count -gt 0 ]]; then
338
384
  echo "### Performance Regressions"
339
- printf '%s\n' "${slower_benchmarks[@]}" | sort -t'(' -k2 -nr | head -5 | sed 's/^/- /'
385
+ echo "$slower_benchmarks" | grep "^." | sort -t'(' -k2 -nr | head -5 | sed 's/^/- /'
340
386
  echo ""
341
387
  fi
342
388
 
343
- if [[ ${#new_benchmarks[@]} -gt 0 ]]; then
389
+ if [[ $new_count -gt 0 ]]; then
344
390
  echo "### New Benchmarks Added"
345
- printf '%s\n' "${new_benchmarks[@]}" | sed 's/^/- /'
391
+ echo "$new_benchmarks" | grep "^." | sed 's/^/- /'
346
392
  echo ""
347
393
  fi
348
394
 
349
- if [[ ${#removed_benchmarks[@]} -gt 0 ]]; then
395
+ if [[ $removed_count -gt 0 ]]; then
350
396
  echo "### Benchmarks Removed"
351
- printf '%s\n' "${removed_benchmarks[@]}" | sed 's/^/- /'
397
+ echo "$removed_benchmarks" | grep "^." | sed 's/^/- /'
352
398
  echo ""
353
399
  fi
354
400
  }
@@ -376,14 +422,14 @@ All benchmarks run with \`-benchmem\` flag showing memory allocations and operat
376
422
  EOF
377
423
 
378
424
  # Add current results to table
379
- for benchmark in "${!current_results[@]}"; do
380
- data="${current_results[$benchmark]}"
425
+ while IFS= read -r benchmark; do
426
+ data=$(get_current_data "$benchmark")
381
427
  ops_sec=$(echo "$data" | cut -d'|' -f1)
382
428
  time_op=$(echo "$data" | cut -d'|' -f2)
383
429
  mem_op=$(echo "$data" | cut -d'|' -f3)
384
430
  allocs_op=$(echo "$data" | cut -d'|' -f4)
385
431
  echo "| $benchmark | $ops_sec | $time_op | $mem_op | $allocs_op |" >> "$OUTPUT_FILE.tmp"
386
- done
432
+ done < <(list_current_benchmarks)
387
433
 
388
434
  # Add comparison section
389
435
  generate_comparison >> "$OUTPUT_FILE.tmp"
@@ -399,14 +445,14 @@ EOF
399
445
  echo "|-----------|----------------|---------|-----------|-----------|" >> "$OUTPUT_FILE.tmp"
400
446
 
401
447
  # Add previous results
402
- for benchmark in "${!previous_results[@]}"; do
403
- data="${previous_results[$benchmark]}"
448
+ while IFS= read -r benchmark; do
449
+ data=$(get_previous_data "$benchmark")
404
450
  ops_sec=$(echo "$data" | cut -d'|' -f1)
405
451
  time_op=$(echo "$data" | cut -d'|' -f2)
406
452
  mem_op=$(echo "$data" | cut -d'|' -f3)
407
453
  allocs_op=$(echo "$data" | cut -d'|' -f4)
408
454
  echo "| $benchmark | $ops_sec | $time_op | $mem_op | $allocs_op |" >> "$OUTPUT_FILE.tmp"
409
- done
455
+ done < <(list_previous_benchmarks)
410
456
  fi
411
457
 
412
458
  # Move temp file to final location
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blinklabs/dingo",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "description": "Dingo is a Cardano blockchain data node",
5
5
  "main": "index.js",
6
6
  "bin": {