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

perf(semantic)!: remove SymbolTable::spans field #4473

Closed

Conversation

overlookmotel
Copy link
Contributor

@overlookmotel overlookmotel commented Jul 25, 2024

Remove spans field from SymbolTable. It's unnecessary because you can get the Span from the AstNodeId, and these lookups only happen in the linter when generating diagnostics (i.e. cold path).

Lots of tests failing. I believe this isn't due to this PR being incorrect, but that it's surfacing existing bugs where AstNodeId for a lot of symbols is set incorrectly.

@DonIsaac Are these the same bugs you've found already? Or new ones?

@DonIsaac
Copy link
Contributor

DonIsaac commented Jul 25, 2024

I need this API for no no-unused-vars for reporting the locations of unused symbols. I believe other rules rely on it as well. It provides a much higher-quality Span then the one provided by the declaration AstNode. Please do not remove it.

Copy link

codspeed-hq bot commented Jul 25, 2024

CodSpeed Performance Report

Merging #4473 will not alter performance

Comparing 07-25-perf_semantic_remove_symboltable_spans_field (16c2ec4) with main (81384f5)

Summary

✅ 32 untouched benchmarks

@overlookmotel
Copy link
Contributor Author

overlookmotel commented Jul 25, 2024

@DonIsaac Shouldn't the AST node that a symbol's AstNodeId points to be the BindingIdentifier? In which case, the 2 spans should be equivalent. Intent here was not to remove any functionality or information, just to use a more efficient means of storing/accessing that information.

You can still get the Span of a symbol via semantic.symbol_span(symbol_id) (previously semantic.symbols. get_span(symbol_id)).

I had assumed the problem here causing the test failures was that the AstNodeIds set for symbols were incorrect, and that if that was fixed, nothing would change. Have I misunderstood?

@Boshen Boshen force-pushed the 07-25-perf_linter_no_shadow_restricted_names_only_look_up_name_in_hashmap_once branch from f08b812 to f6ea0b1 Compare July 26, 2024 00:21
@overlookmotel overlookmotel force-pushed the 07-25-perf_linter_no_shadow_restricted_names_only_look_up_name_in_hashmap_once branch from f6ea0b1 to b60bdf1 Compare July 26, 2024 00:31
@overlookmotel overlookmotel force-pushed the 07-25-perf_semantic_remove_symboltable_spans_field branch from ad13d44 to 16c2ec4 Compare July 26, 2024 00:31
@Boshen Boshen changed the base branch from 07-25-perf_linter_no_shadow_restricted_names_only_look_up_name_in_hashmap_once to main July 26, 2024 00:53
@DonIsaac
Copy link
Contributor

DonIsaac commented Jul 26, 2024

@overlookmotel I'm not sure, I just trust getting spans from AST node declarations less than symbol spans. There's some funkiness going on with getting declaration nodes for function expressions. Mind if we wait until #4445 is merged first, then see how this PR affects spans it reports?

@Dunqing
Copy link
Member

Dunqing commented Jul 26, 2024

Same as #4464 (comment)

@Boshen
Copy link
Member

Boshen commented Aug 8, 2024

Closing due to unsure if this is going to complicate other features. And the benchmark shows no performance improvement.

@Boshen Boshen closed this Aug 8, 2024
@overlookmotel
Copy link
Contributor Author

overlookmotel commented Aug 9, 2024

Well 1-2% improvement on semantic benchmarks isn't nothing. But, yes, I agree we should close for now.

@Boshen can you answer one question though? What AST nodes are SymbolTable::declarations meant to point to? The BindingIdentifier for the binding? Or its parent? Currently it appears to be the latter, and I was assuming that's a bug that's crept in (and is what caused all the test failures on this PR).

@overlookmotel
Copy link
Contributor Author

Ignore that question. #4739 explains the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linter Area - Linter A-semantic Area - Semantic A-transformer Area - Transformer / Transpiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants