Skip to content

AST IdentifierExpression represents 21% in memory of all bumpalo allocations. #585

@nbp

Description

@nbp

When testing the parsers without the bytecode emitter using smoosh_tools bench, Valgrind DHat tool reports that:

  │   ├─▼ AP 1.1.1/10 (14 children) {
  │   │     Total:     3,758,158,224 bytes (71.35%, 92,593.22/Minstr) in 13,082 blocks (0.57%, 0.32/Minstr), avg size 287,277.04 bytes, avg lifetime 12,769,758.74 instrs (0.03% of program duration)
  │   │     At t-gmax: 67,107,456 bytes (35.46%) in 16 blocks (0.02%), avg size 4,194,216 bytes
  │   │     At t-end:  0 bytes (0%) in 0 blocks (0%), avg size 0 bytes
  │   │     Reads:     1,498,861,944 bytes (15.11%, 36,928.85/Minstr), 0.4/byte
  │   │     Writes:    2,070,236,280 bytes (24.92%, 51,006.33/Minstr), 0.55/byte
  │   │     Allocated at {
  │   │       ^1: 0x4834733: malloc (in /nix/store/vd16mm3drx7fkmq456kzr5f8bzi2qjj4-valgrind-3.16.1/lib/valgrind/vgpreload_dhat-amd64-linux.so)
  │   │       #2: 0xF6B2A7: UnknownInlinedFun (src/libstd/sys/unix/alloc.rs:14)
  │   │       #3: 0xF6B2A7: UnknownInlinedFun (src/libstd/alloc.rs:304)
  │   │       #4: 0xF6B2A7: alloc (alloc.rs:80)
  │   │       #5: 0xF6B2A7: new_chunk (lib.rs:472)
  │   │       #6: 0xF6B2A7: bumpalo::Bump::alloc_layout_slow (lib.rs:967)
  │   │     }
  │   │   }
  │   │   ├─▶ AP 1.1.1.1/14 (2 children) {
  │   │   │     Total:     814,760,392 bytes (15.47%, 20,074.01/Minstr) in 1,773 blocks (0.08%, 0.04/Minstr), avg size 459,537.73 bytes, avg lifetime 14,073,163.3 instrs (0.03% of program duration)
  │   │   │     At t-gmax: 8,454,096 bytes (4.47%) in 2 blocks (0%), avg size 4,227,048 bytes
  │   │   │     At t-end:  0 bytes (0%) in 0 blocks (0%), avg size 0 bytes
  │   │   │     Reads:     333,027,938 bytes (3.36%, 8,205.12/Minstr), 0.41/byte
  │   │   │     Writes:    455,750,720 bytes (5.49%, 11,228.75/Minstr), 0.56/byte
  │   │   │     Allocated at {
  │   │   │       ^1: 0x4834733: malloc (in /nix/store/vd16mm3drx7fkmq456kzr5f8bzi2qjj4-valgrind-3.16.1/lib/valgrind/vgpreload_dhat-amd64-linux.so)
  │   │   │       ^2: 0xF6B2A7: UnknownInlinedFun (src/libstd/sys/unix/alloc.rs:14)
  │   │   │       ^3: 0xF6B2A7: UnknownInlinedFun (src/libstd/alloc.rs:304)
  │   │   │       ^4: 0xF6B2A7: alloc (alloc.rs:80)
  │   │   │       ^5: 0xF6B2A7: new_chunk (lib.rs:472)
  │   │   │       ^6: 0xF6B2A7: bumpalo::Bump::alloc_layout_slow (lib.rs:967)
  │   │   │       #7: 0x10B01FB: UnknownInlinedFun (lib.rs:907)
  │   │   │       #8: 0x10B01FB: UnknownInlinedFun (lib.rs:893)
  │   │   │       #9: 0x10B01FB: UnknownInlinedFun (lib.rs:648)
  │   │   │       #10: 0x10B01FB: UnknownInlinedFun (arena.rs:68)
  │   │   │       #11: 0x10B01FB: UnknownInlinedFun (/home/nicolas/mozilla/jsparagus/crates/generated_parser/src/ast_builder.rs:53)
  │   │   │       #12: 0x10B01FB: UnknownInlinedFun (/home/nicolas/mozilla/jsparagus/crates/generated_parser/src/ast_builder.rs:169)
  │   │   │       #13: 0x10B01FB: jsparagus_generated_parser::parser_tables_generated::full_actions_675 (parser_tables_generated.rs:5359)
  │   │   │     }
  │   │   │   }

One idea would be to not allocate an IdentifierExpression but either reuse the Identifier as-is or annotate it with a flag to validate that this is an IdentifierExpression.

Metadata

Metadata

Assignees

No one assigned

    Labels

    optimizationWould improve performance.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions