Skip to content

Conversation

Techatrix
Copy link
Member

I've applied the same optimization that I did on folding ranges in #954 to document symbols.
Generating document symbols for Sema.zig with a ReleaseFast build went from 415ms to 5.3ms which is a 98.7% reduction.
The information on some document symbol should also be slightly improved.

One step towards resolving #1046

@Techatrix Techatrix added the pr:fuzz Attach to a PR to start fuzzing / continually fuzz (please do this before merging!) label Mar 11, 2023
@SuperAuguste
Copy link
Member

New crash here: https://fuzzing.zigtools.org/group/2e68a9b93841dc6558c591dc227c0dd9

Here's an extract:

thread 2521 panic: reached unreachable code
/home/runner/work/zls/zls/zls/src/document_symbol.zig:101:29: 0x58287d in callback (zls)
                    else => unreachable,
                            ^
/home/runner/work/zls/zls/zls/src/ast.zig:1311:29: 0x4fe662 in iterateChildren__anon_39628 (zls)
                try callback(context, tree, child);
                            ^
/home/runner/work/zls/zls/zls/src/document_symbol.zig:133:28: 0x582bda in callback (zls)
    try ast.iterateChildren(tree, node, &new_ctx, error{OutOfMemory}, callback);
                           ^
/home/runner/work/zls/zls/zls/src/ast.zig:1293:56: 0x4fe453 in iterateChildren__anon_39628 (zls)
            try callback(context, tree, node_data[node].rhs);
                                                       ^
/home/runner/work/zls/zls/zls/src/document_symbol.zig:133:28: 0x582bda in callback (zls)
    try ast.iterateChildren(tree, node, &new_ctx, error{OutOfMemory}, callback);
                           ^
/home/runner/work/zls/zls/zls/src/ast.zig:1311:29: 0x4fe662 in iterateChildren__anon_39628 (zls)
                try callback(context, tree, child);
                            ^
/home/runner/work/zls/zls/zls/src/document_symbol.zig:237:28: 0x477a0b in getDocumentSymbols (zls)
    try ast.iterateChildren(tree, 0, &ctx, error{OutOfMemory}, callback);
                           ^
/home/runner/work/zls/zls/zls/src/Server.zig:2502:96: 0x3f2f71 in documentSymbolsHandler (zls)
    return try document_symbol.getDocumentSymbols(server.arena.allocator(), handle.tree, server.offset_encoding);
                                                                                               ^
/home/runner/work/zls/zls/zls/src/Server.zig:3165:37: 0x3adfef in processMessage (zls)
            const response = handler(server, params) catch |err| {
                                    ^
/home/runner/work/zls/zls/zls/src/Server.zig:3028:26: 0x3592fa in processJsonRpc (zls)
    server.processMessage(message) catch |err| switch (message) {
                         ^
/home/runner/work/zls/zls/zls/src/main.zig:80:30: 0x358a8b in loop (zls)
        server.processJsonRpc(json_message);
                             ^
/home/runner/work/zls/zls/zls/src/main.zig:395:13: 0x359e88 in main (zls)
    try loop(server, record_file, replay_file);
            ^
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.11.0-dev.1928+3169f0529/x64/lib/std/start.zig:617:37: 0x3423de in posixCallMainAndExit (zls)
            const result = root.main() catch |err| {
                                    ^
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.11.0-dev.1928+3169f0529/x64/lib/std/start.zig:376:5: 0x341e41 in _start (zls)
    @call(.never_inline, posixCallMainAndExit, .{});
    ^

Copy link
Member

@SuperAuguste SuperAuguste left a comment

Choose a reason for hiding this comment

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

New errors unrelated to this PR; LGTM!

@SuperAuguste SuperAuguste merged commit ab23ff3 into zigtools:master Mar 12, 2023
@Techatrix Techatrix deleted the optimize-document-symbols branch May 5, 2023 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:fuzz Attach to a PR to start fuzzing / continually fuzz (please do this before merging!)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants