Skip to content

fix(crypto-ext): Remove lazy static#189

Merged
load1n9 merged 2 commits intotryandromeda:mainfrom
yossydev:fix/remove-lazy-static-ctypto-subtle-ext
Nov 11, 2025
Merged

fix(crypto-ext): Remove lazy static#189
load1n9 merged 2 commits intotryandromeda:mainfrom
yossydev:fix/remove-lazy-static-ctypto-subtle-ext

Conversation

@yossydev
Copy link
Member

i refactored, do not use lazy_static in crypto.

crypto example code result
enerated UUID: 5c03bc04-17cb-48d3-83a1-fc0ec94c4807
UUID length: 36
UUID has dashes at correct positions: true

Testing getRandomValues...
Buffer filled: { 0: 253, 1: 253, 2: 253, 3: 91, 4: 36, 5: 253, 6: 86, 7: 253, 8: 253, 9: 77, 10: 72, 11: 253, 12: 82, 13: 253, 14: 253, 15: 112 }
Returned same array: true
Buffer has non-zero values: true

Testing crypto.subtle.digest...

Testing crypto.subtle.generateKey...

Testing TextEncoder/TextDecoder...
Encoded bytes: { 0: 72, 1: 101, 2: 108, 3: 108, 4: 111, 5: 44, 6: 32, 7: 67, 8: 114, 9: 121, 10: 112, 11: 116, 12: 111, 13: 32, 14: 87, 15: 111, 16: 114, 17: 108, 18: 100, 19: 33, 20: 32, 21: 240, 22: 159, 23: 148, 24: 144 }
Decoded string: Hello, Crypto World! 🔐
Round-trip successful: true
Hex representation: 48656c6c6f2c2043727970746f20576f726c642120f09f9490
Back to bytes: { 0: 72, 1: 101, 2: 108, 3: 108, 4: 111, 5: 44, 6: 32, 7: 67, 8: 114, 9: 121, 10: 112, 11: 116, 12: 111, 13: 32, 14: 87, 15: 111, 16: 114, 17: 108, 18: 100, 19: 33, 20: 32, 21: 240, 22: 159, 23: 148, 24: 144 }
Hex round-trip successful: true

Testing digest with various messages...
SHA-256 hash: 7afd7566643167fdfdfd68fdfdfd5cfdfd0afd69fdfdfdfd7afd5867d4
Hash type: object
Generated key: { algorithm: "AesGcm { length: 256, iv: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], iv_length: Some(12), additional_data: None, tag_length: Some(16) }", extractable: true, keyId: 1, type: "secret", usages: ["encrypt", "decrypt"] }
Key type: object
Message: "Short message"
SHA-256: 2efdfdfdfd776efdfd1e543ffd7d61fdfdfdfdfd2e64fdfd6f3bfd3b79fd1ffd
Message: "A longer message with unicode: 你好 🌍"
SHA-256: 3268fdfd59fd09fd3d543972fd2cfdfdfdfd7d79fd63fd085b12707ffdfd24
Message: "Message with special chars: !@#$%^&*()_+-=[]{}|;':",./<>?"
SHA-256: 7f70fd6cfd7228fd1d0afdfd6bfd3630fdfd2afdfd49fd2d6bfd452616fdfd

@yossydev yossydev requested review from load1n9 and marc2332 November 11, 2025 15:43
@yossydev yossydev self-assigned this Nov 11, 2025
@yossydev yossydev marked this pull request as ready for review November 11, 2025 15:44
@github-actions
Copy link

github-actions bot commented Nov 11, 2025

Performance Comparison

Total Elapsed Time: 45.04ms → 44.47ms (-1.3%)

Profiling Mode: timing - Execution duration of functions.

+-------------------------------------+----------------------+--------------------------------+---------------------------------+----------------------------------+--------------------------------+--------------------------------+------------------------------+
| Function                            | Calls                | Avg                            | P50                             | P95                              | P99                            | Total                          | % Total                      |
+-------------------------------------+----------------------+--------------------------------+---------------------------------+----------------------------------+--------------------------------+--------------------------------+------------------------------+
| andromeda::main                     | 1 → 1 (+0.0%)        | 44.37ms → 43.81ms (-1.2%)      | 44.37ms → 43.84ms (-1.2%)       | 44.37ms → 43.84ms (-1.2%)        | 44.37ms → 43.84ms (-1.2%)      | 44.37ms → 43.81ms (-1.2%)      | 100.00% → 100.00% (+0.0%)    |
+-------------------------------------+----------------------+--------------------------------+---------------------------------+----------------------------------+--------------------------------+--------------------------------+------------------------------+
| andromeda::run_main                 | 1 → 1 (+0.0%)        | 44.35ms → 43.80ms (-1.2%)      | 44.37ms → 43.81ms (-1.3%)       | 44.37ms → 43.81ms (-1.3%)        | 44.37ms → 43.81ms (-1.3%)      | 44.35ms → 43.80ms (-1.2%)      | 99.95% → 99.96% (+0.0%)      |
+-------------------------------------+----------------------+--------------------------------+---------------------------------+----------------------------------+--------------------------------+--------------------------------+------------------------------+
| run::run                            | 1 → 1 (+0.0%)        | 43.90ms → 43.47ms (-1.0%)      | 43.91ms → 43.48ms (-1.0%)       | 43.91ms → 43.48ms (-1.0%)        | 43.91ms → 43.48ms (-1.0%)      | 43.90ms → 43.47ms (-1.0%)      | 98.94% → 99.22% (+0.3%)      |
+-------------------------------------+----------------------+--------------------------------+---------------------------------+----------------------------------+--------------------------------+--------------------------------+------------------------------+
| run::create_runtime_files           | 1 → 1 (+0.0%)        | 43.89ms → 43.47ms (-1.0%)      | 43.91ms → 43.48ms (-1.0%)       | 43.91ms → 43.48ms (-1.0%)        | 43.91ms → 43.48ms (-1.0%)      | 43.89ms → 43.47ms (-1.0%)      | 98.93% → 99.21% (+0.3%)      |
+-------------------------------------+----------------------+--------------------------------+---------------------------------+----------------------------------+--------------------------------+--------------------------------+------------------------------+
| runtime::run                        | 1 → 1 (+0.0%)        | 23.21ms → 23.65ms (+1.9%)      | 23.22ms → 23.66ms (+1.9%)       | 23.22ms → 23.66ms (+1.9%)        | 23.22ms → 23.66ms (+1.9%)      | 23.21ms → 23.65ms (+1.9%)      | 52.32% → 53.97% (+3.2%)      |
+-------------------------------------+----------------------+--------------------------------+---------------------------------+----------------------------------+--------------------------------+--------------------------------+------------------------------+
| runtime::new                        | 1 → 1 (+0.0%)        | 19.47ms → 18.59ms (-4.5%)      | 19.48ms → 18.60ms (-4.5%)       | 19.48ms → 18.60ms (-4.5%)        | 19.48ms → 18.60ms (-4.5%)      | 19.47ms → 18.59ms (-4.5%)      | 43.88% → 42.43% (-3.3%)      |
+-------------------------------------+----------------------+--------------------------------+---------------------------------+----------------------------------+--------------------------------+--------------------------------+------------------------------+
| extension::load                     | 22 → 22 (+0.0%)      | 850.18µs → 816.06µs (-4.0%)    | 324.35µs → 289.28µs (-10.8%)    | 2.99ms → 2.94ms (-1.5%)          | 5.59ms → 5.57ms (-0.3%)        | 18.70ms → 17.95ms (-4.0%)      | 42.15% → 40.97% (-2.8%)      |
+-------------------------------------+----------------------+--------------------------------+---------------------------------+----------------------------------+--------------------------------+--------------------------------+------------------------------+
| console::internal_print             | 180 → 180 (+0.0%)    | 3.50µs → 3.67µs (+4.9%)        | 3.67µs → 3.60µs (-1.9%)         | 4.55µs → 4.98µs (+9.4%)          | 10.00µs → 7.38µs (-26.2%) 🚀   | 629.85µs → 660.85µs (+4.9%)    | 1.41% → 1.50% (+6.4%)        |
+-------------------------------------+----------------------+--------------------------------+---------------------------------+----------------------------------+--------------------------------+--------------------------------+------------------------------+
| recommended::recommended_extensions | 1 → 1 (+0.0%)        | 57.35µs → 54.90µs (-4.3%)      | 57.38µs → 54.91µs (-4.3%)       | 57.38µs → 54.91µs (-4.3%)        | 57.38µs → 54.91µs (-4.3%)      | 57.35µs → 54.90µs (-4.3%)      | 0.12% → 0.12% (+0.0%)        |
+-------------------------------------+----------------------+--------------------------------+---------------------------------+----------------------------------+--------------------------------+--------------------------------+------------------------------+
| console::get_group_indent           | 180 → 180 (+0.0%)    | 121.00ns → 109.00ns (-9.9%)    | 110.00ns → 70.00ns (-36.4%) 🚀  | 210.00ns → 320.00ns (+52.4%) ⚠️  | 421.00ns → 431.00ns (+2.4%)    | 21.87µs → 19.69µs (-10.0%)     | 0.04% → 0.04% (+0.0%)        |
+-------------------------------------+----------------------+--------------------------------+---------------------------------+----------------------------------+--------------------------------+--------------------------------+------------------------------+

Generated with hotpath

📊 View Raw JSON Metrics

PR Metrics

{
  "hotpath_profiling_mode": "timing",
  "total_elapsed": 44473168,
  "description": "Execution duration of functions.",
  "caller_name": "andromeda::main",
  "output": {
    "extension::load": {
      "calls": 22,
      "avg": 816061,
      "p50": 289279,
      "p95": 2942975,
      "p99": 5570559,
      "total": 17953346,
      "percent_total": 4097
    },
    "andromeda::run_main": {
      "calls": 1,
      "avg": 43797538,
      "p50": 43810815,
      "p95": 43810815,
      "p99": 43810815,
      "total": 43797538,
      "percent_total": 9996
    },
    "andromeda::main": {
      "calls": 1,
      "avg": 43812537,
      "p50": 43843583,
      "p95": 43843583,
      "p99": 43843583,
      "total": 43812537,
      "percent_total": 10000
    },
    "runtime::new": {
      "calls": 1,
      "avg": 18592994,
      "p50": 18595839,
      "p95": 18595839,
      "p99": 18595839,
      "total": 18592994,
      "percent_total": 4243
    },
    "console::internal_print": {
      "calls": 180,
      "avg": 3671,
      "p50": 3597,
      "p95": 4979,
      "p99": 7383,
      "total": 660845,
      "percent_total": 150
    },
    "run::run": {
      "calls": 1,
      "avg": 43474158,
      "p50": 43483135,
      "p95": 43483135,
      "p99": 43483135,
      "total": 43474158,
      "percent_total": 9922
    },
    "runtime::run": {
      "calls": 1,
      "avg": 23646566,
      "p50": 23658495,
      "p95": 23658495,
      "p99": 23658495,
      "total": 23646566,
      "percent_total": 5397
    },
    "run::create_runtime_files": {
      "calls": 1,
      "avg": 43470120,
      "p50": 43483135,
      "p95": 43483135,
      "p99": 43483135,
      "total": 43470120,
      "percent_total": 9921
    },
    "recommended::recommended_extensions": {
      "calls": 1,
      "avg": 54902,
      "p50": 54911,
      "p95": 54911,
      "p99": 54911,
      "total": 54902,
      "percent_total": 12
    },
    "console::get_group_indent": {
      "calls": 180,
      "avg": 109,
      "p50": 70,
      "p95": 320,
      "p99": 431,
      "total": 19687,
      "percent_total": 4
    }
  }
}

Main Branch Metrics

{
  "hotpath_profiling_mode": "timing",
  "total_elapsed": 45036563,
  "description": "Execution duration of functions.",
  "caller_name": "andromeda::main",
  "output": {
    "runtime::run": {
      "calls": 1,
      "avg": 23214290,
      "p50": 23216127,
      "p95": 23216127,
      "p99": 23216127,
      "total": 23214290,
      "percent_total": 5232
    },
    "run::create_runtime_files": {
      "calls": 1,
      "avg": 43893944,
      "p50": 43909119,
      "p95": 43909119,
      "p99": 43909119,
      "total": 43893944,
      "percent_total": 9893
    },
    "recommended::recommended_extensions": {
      "calls": 1,
      "avg": 57347,
      "p50": 57375,
      "p95": 57375,
      "p99": 57375,
      "total": 57347,
      "percent_total": 12
    },
    "andromeda::run_main": {
      "calls": 1,
      "avg": 44346729,
      "p50": 44367871,
      "p95": 44367871,
      "p99": 44367871,
      "total": 44346729,
      "percent_total": 9995
    },
    "console::get_group_indent": {
      "calls": 180,
      "avg": 121,
      "p50": 110,
      "p95": 210,
      "p99": 421,
      "total": 21866,
      "percent_total": 4
    },
    "run::run": {
      "calls": 1,
      "avg": 43898392,
      "p50": 43909119,
      "p95": 43909119,
      "p99": 43909119,
      "total": 43898392,
      "percent_total": 9894
    },
    "runtime::new": {
      "calls": 1,
      "avg": 19467929,
      "p50": 19480575,
      "p95": 19480575,
      "p99": 19480575,
      "total": 19467929,
      "percent_total": 4388
    },
    "andromeda::main": {
      "calls": 1,
      "avg": 44365735,
      "p50": 44367871,
      "p95": 44367871,
      "p99": 44367871,
      "total": 44365735,
      "percent_total": 10000
    },
    "extension::load": {
      "calls": 22,
      "avg": 850180,
      "p50": 324351,
      "p95": 2988031,
      "p99": 5586943,
      "total": 18703966,
      "percent_total": 4215
    },
    "console::internal_print": {
      "calls": 180,
      "avg": 3499,
      "p50": 3667,
      "p95": 4551,
      "p99": 9999,
      "total": 629848,
      "percent_total": 141
    }
  }
}

@yossydev
Copy link
Member Author

ci will pass, if this pr merged

@marc2332
Copy link
Member

ci will pass, if this pr merged

Done

Copy link
Member

@load1n9 load1n9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@load1n9 load1n9 merged commit 0dbcc88 into tryandromeda:main Nov 11, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants