Skip to content

[SharedCache] Introduce a SymbolInfo type#6402

Closed
bdash wants to merge 1 commit into
Vector35:devfrom
bdash:dsc-symbolinfo
Closed

[SharedCache] Introduce a SymbolInfo type#6402
bdash wants to merge 1 commit into
Vector35:devfrom
bdash:dsc-symbolinfo

Conversation

@bdash
Copy link
Copy Markdown
Contributor

@bdash bdash commented Feb 8, 2025

Previously SharedCache used a mixture of pair<uint64_t, pair<BNSymbolType, std::string>> and Ref<Symbol> to represent a symbol. The former is hard to understand due to the nesting and lack of names. The latter is expensive to create and its getters are expensive due to the multiple allocations + strlen calls performed when converting between core's string representation and std::string.

SymbolInfo wraps the same data that the nested pairs contained in a friendly struct with named fields. Beyond that it, it exposes an AsSymbol function to construct a Ref<Symbol> where that is what is required.

Code within SharedCache is updated to work with SymbolInfo until it needs to call into a core API that requires a Symbol.

This change is only a small performance improvement at the moment. It's more noticable once SharedCache no longer copies so much of its state (#6393).

Previously `SharedCache` used a mixture of `pair<uint64_t,
pair<BNSymbolType, std::string>>` and `Ref<Symbol>` to represent a
symbol. The former is hard to understand due to the nesting and lack of
names. The latter is expensive to create and its getters are expensive
due to the multiple allocations + `strlen` calls needed when converting
between core's string representation and `std::string`.

`SymbolInfo` wraps the same data the nested pairs contained into a
friendly struct with named fields. Beyond that it, it exposes an
`AsSymbol` function to construct a `Ref<Symbol>` where that is what
is required.

Code within `SharedCache` is updated to work with `SymbolInfo` until it
needs to call into a core API that requires a `Symbol`.

This change is only a small performance improvement at the moment. It's
more noticable once `SharedCache` no longer copies so much of its state
(Vector35#6393).
@bdash
Copy link
Copy Markdown
Contributor Author

bdash commented Feb 10, 2025

I'll have to look at whether this is still worth doing given #6197. It may not be necessary.

@bdash
Copy link
Copy Markdown
Contributor Author

bdash commented Feb 13, 2025

Constructing a Symbol is still a little more expensive than I'd like, but the changes on the test_api_string_ref branch make the Symbol getters significantly more efficient. That's a better path forward than introducing a custom type.

@bdash bdash closed this Feb 13, 2025
@bdash bdash deleted the dsc-symbolinfo branch February 13, 2025 17:48
@emesare emesare modified the milestone: Gallifrey Apr 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants