Andreas Kling
b0b022507b
LibJS: Reduce AST memory usage by shrink-wrapping source range info
...
Before this change, each AST node had a 64-byte SourceRange member.
This SourceRange had the following layout:
filename: StringView (16 bytes)
start: Position (24 bytes)
end: Position (24 bytes)
The Position structs have { line, column, offset }, all members size_t.
To reduce memory consumption, AST nodes now only store the following:
source_code: NonnullRefPtr<SourceCode> (8 bytes)
start_offset: u32 (4 bytes)
end_offset: u32 (4 bytes)
SourceCode is a new ref-counted data structure that keeps the filename
and original parsed source code in a single location, and all AST nodes
have a pointer to it.
The start_offset and end_offset can be turned into (line, column) when
necessary by calling SourceCode::range_from_offsets(). This will walk
the source code string and compute line/column numbers on the fly, so
it's not necessarily fast, but it should be rare since this information
is primarily used for diagnostics and exception stack traces.
With this, ASTNode shrinks from 80 bytes to 32 bytes. This gives us a
~23% reduction in memory usage when loading twitter.com/awesomekling
(330 MiB before, 253 MiB after!) :^)
2022-11-22 21:13:35 +01:00
..
2022-10-01 21:05:32 +01:00
2022-11-15 21:48:19 +00:00
2022-11-16 17:23:56 +00:00
2022-11-21 10:12:07 +01:00
2022-11-22 21:13:35 +01:00
2022-09-07 20:30:31 +02:00
2022-11-10 17:02:11 +00:00
2022-11-13 16:37:09 -07:00
2022-11-19 14:37:31 +00:00
2022-11-15 21:48:19 +00:00
2022-11-07 14:10:41 +01:00
2022-11-04 10:38:00 +01:00
2022-10-20 15:16:23 +02:00
2022-10-20 15:16:23 +02:00
2022-10-01 21:05:32 +01:00
2022-10-01 21:05:32 +01:00
2022-11-19 14:37:31 +00:00
2022-10-01 21:05:32 +01:00
2022-10-01 21:05:32 +01:00
2022-10-01 21:05:32 +01:00
2022-10-09 10:14:57 +02:00
2022-10-31 14:12:44 +00:00
2022-10-01 21:05:32 +01:00
2022-10-09 10:14:57 +02:00
2022-10-31 14:12:44 +00:00
2022-10-10 20:22:50 +02:00
2022-10-01 21:05:32 +01:00
2022-10-01 21:05:32 +01:00
2022-10-01 21:05:32 +01:00
2022-09-24 19:31:39 +01:00
2022-09-20 10:32:13 +02:00
2022-11-07 14:10:41 +01:00
2022-11-07 14:10:41 +01:00
2022-11-19 14:37:31 +00:00
2022-09-24 19:31:39 +01:00
2022-09-24 19:31:39 +01:00
2022-10-14 16:01:35 +02:00
2022-10-14 16:01:35 +02:00
2022-10-14 16:01:35 +02:00
2022-09-20 10:32:12 +02:00
2022-11-07 14:10:41 +01:00
2022-11-07 14:10:41 +01:00
2022-10-09 10:14:57 +02:00
2022-11-07 14:10:41 +01:00
2022-11-07 14:10:41 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-11-05 00:30:10 +01:00
2022-11-05 00:30:10 +01:00
2022-10-09 10:14:57 +02:00
2022-09-07 20:30:31 +02:00
2022-09-21 21:12:24 +01:00
2022-11-13 16:53:22 -07:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-20 15:16:23 +02:00
2022-10-20 15:16:23 +02:00
2022-10-09 10:14:57 +02:00
2022-11-07 14:10:41 +01:00
2022-11-07 14:10:41 +01:00
2022-10-09 10:14:57 +02:00
2022-10-31 14:12:44 +00:00
2022-10-20 15:16:23 +02:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-11-13 16:37:09 -07:00
2022-11-13 16:37:09 -07:00
2022-11-13 16:37:09 -07:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-30 18:05:48 +02:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-16 02:06:29 +03:30
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-11-07 14:10:41 +01:00
2022-11-07 14:10:41 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-11-19 14:37:31 +00:00
2022-11-07 14:10:41 +01:00
2022-11-07 14:10:41 +01:00
2022-11-04 10:38:00 +01:00
2022-10-31 14:12:44 +00:00
2022-10-20 15:16:23 +02:00
2022-10-09 10:14:57 +02:00
2022-11-19 14:37:31 +00:00
2022-11-07 14:10:41 +01:00
2022-10-09 10:14:57 +02:00
2022-10-20 15:16:23 +02:00
2022-10-20 15:16:23 +02:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-02 21:32:49 +02:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-28 16:17:08 +01:00
2022-10-28 16:17:08 +01:00
2022-10-28 16:17:08 +01:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-11-07 14:10:41 +01:00
2022-11-07 14:10:41 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-31 14:12:44 +00:00
2022-09-30 18:05:48 +02:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-25 19:13:31 +01:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-31 14:12:44 +00:00
2022-10-20 15:16:23 +02:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-11-21 10:08:50 +01:00
2022-11-21 10:08:50 +01:00
2022-10-09 10:14:57 +02:00
2022-11-07 14:10:41 +01:00
2022-11-07 14:10:41 +01:00
2022-11-07 14:10:41 +01:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-31 14:12:44 +00:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-31 14:12:44 +00:00
2022-09-25 19:13:31 +01:00
2022-10-09 10:14:57 +02:00
2022-11-07 14:10:41 +01:00
2022-11-07 14:10:41 +01:00
2022-11-07 14:10:41 +01:00
2022-10-31 14:12:44 +00:00
2022-09-25 19:13:31 +01:00
2022-10-09 10:14:57 +02:00
2022-10-31 14:12:44 +00:00
2022-10-29 15:16:57 +02:00
2022-10-09 10:14:57 +02:00
2022-11-07 14:10:41 +01:00
2022-11-07 14:10:41 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-10-01 21:05:32 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-10-01 21:05:32 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-10-01 21:05:32 +01:00
2022-10-09 10:14:57 +02:00
2022-11-19 14:37:31 +00:00
2022-10-01 21:05:32 +01:00
2022-10-09 10:14:57 +02:00
2022-10-30 11:30:23 +00:00
2022-10-13 11:14:45 +02:00
2022-10-13 11:14:45 +02:00
2022-10-13 11:14:45 +02:00
2022-10-09 10:14:57 +02:00
2022-10-09 10:14:57 +02:00
2022-10-09 10:14:57 +02:00
2022-11-09 16:00:32 +00:00
2022-10-09 10:14:57 +02:00
2022-10-09 10:14:57 +02:00
2022-10-13 14:42:14 +02:00
2022-10-09 10:14:57 +02:00
2022-10-09 10:14:57 +02:00
2022-11-06 10:25:08 -07:00
2022-10-01 21:05:32 +01:00
2022-10-01 21:05:32 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-10-01 21:05:32 +01:00
2022-10-24 22:58:37 +01:00
2022-10-01 21:05:32 +01:00
2022-10-01 21:05:32 +01:00
2022-09-06 00:27:09 +02:00
2022-09-18 13:27:24 -04:00
2022-10-20 15:16:23 +02:00
2022-10-01 21:05:32 +01:00
2022-10-01 21:05:32 +01:00
2022-10-01 21:05:32 +01:00
2022-10-01 21:05:32 +01:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-10-01 21:05:32 +01:00
2022-10-09 10:14:57 +02:00
2022-09-07 20:30:31 +02:00
2022-09-07 20:30:31 +02:00
2022-09-20 10:32:14 +02:00
2022-11-19 14:37:31 +00:00
2022-11-15 21:48:19 +00:00
2022-09-24 19:31:39 +01:00
2022-09-24 19:31:39 +01:00
2022-10-20 15:16:23 +02:00
2022-10-20 15:16:23 +02:00
2022-11-19 14:37:31 +00:00
2022-10-09 10:14:57 +02:00
2022-10-01 21:05:32 +01:00
2022-10-09 10:14:57 +02:00
2022-09-06 00:27:09 +02:00
2022-09-21 21:12:24 +01:00
2022-10-09 10:14:57 +02:00
2022-10-09 10:14:57 +02:00
2022-10-09 10:14:57 +02:00