Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nbp opened this issue Jul 7, 2020 · 1 comment
Labels
optimization Would improve performance.

Comments

@nbp
Copy link
Collaborator

nbp commented Jul 7, 2020

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.

@nbp nbp added the optimization Would improve performance. label Jul 7, 2020
@nbp
Copy link
Collaborator Author

nbp commented Jul 7, 2020

One note, is that the allocated blocks are the bump-allocator blocks which are allocated when a new block is needed.
This reports might be an artifact of the first block allocation being caused by the allocation of an IdentifierExpression and not really accounting for the fact that IdentifierExpression represents that many allocations.

This could be verified by replacing the bump allocator implementation by an ordinary allocation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
optimization Would improve performance.
Development

No branches or pull requests

1 participant