Skip to content

Use smol_str for identifiers #565

Closed
Closed

Description

@Razican

Currently, we use a partially optimised version of String for identifiers and function names parsing and lexing. While it's OK, we could greatly benefit from using small strings that will usually be stored inline.

The smol_str crate was made for this, and it's being used on rust-analyzer, for example. It will store up to 22-bytes (ASCII characters) inline, in the stack, and then do some optimisations for whitespace strings. It will then store bigger strings in Rc'd heap allocations. It uses immutable strings, though, but identifiers don't change.

A nice review on this and other crates was done by Amos here.

This should especially help with minified code, that we will be benchmarking in #564.

This is waiting for #564 and #559.

Activity

  1. added
    A-Enhancement
    A-Performance
    A-Memory
    on Jul 15, 2020
  2. added this to the v0.10.0 milestone on Jul 15, 2020
  3. added
    Blocked
    on Jul 15, 2020
  4. neeldug commented on Jul 15, 2020

    @neeldug
    Contributor

    After looking into lasso's usage, specifically for node identifiers, at which scope would you want the cache to be kept at?

  5. Razican commented on Jul 15, 2020

    @Razican
    MemberAuthor

    After looking into lasso's usage, specifically for node identifiers, at which scope would you want the cache to be kept at?

    lasso would be an interner (related to #279). In any case, I think the lexer should have the interner, and then, once the parser finishes parsing, it shoulg return that interner for the interpreter to use.

    But in fact, this might be easier if this was a property of a Boa structure, that would have the lexer, the parser and the interpreter too.

  6. neeldug commented on Jul 15, 2020

    @neeldug
    Contributor

    After looking into lasso's usage, specifically for node identifiers, at which scope would you want the cache to be kept at?

    lasso would be an interner (related to #279). In any case, I think the lexer should have the interner, and then, once the parser finishes parsing, it shoulg return that interner for the interpreter to use.

    But in fact, this might be easier if this was a property of a Boa structure, that would have the lexer, the parser and the interpreter too.

    Was looking into the property of a Boa structure, in doing so would the constructor have to call the constructor of the lexer, the parser and the interpreter, or would those be passed into the constructor to hold as a pointer. I also was trying to make the structure for the interner less convoluted by generating its own method, but can't access the Key type as it's private, if you have any suggestions to get around this, it would be much appreciated.

  7. neeldug commented on Aug 27, 2020

    @neeldug
    Contributor

    @Razican this can be unblocked now right? As both changes have now landed.

  8. removed
    Blocked
    on Aug 27, 2020
  9. neeldug commented on Sep 8, 2020

    @neeldug
    Contributor

    Also @Razican currently the type being used is RcString for tokens correct?

  10. modified the milestones: v0.10.0, v0.11.0 on Sep 29, 2020
  11. modified the milestones: v0.11.0, v0.12.0 on Jan 11, 2021
  12. modified the milestones: v0.12.0, v0.13.0 on May 22, 2021
  13. modified the milestones: v0.13.0, v0.14.0 on Sep 25, 2021
  14. Razican commented on Jan 31, 2022

    @Razican
    MemberAuthor

    This will no longer be implemented, as interned strings will be used instead.

  15. removed this from the v0.14.0 milestone on Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-EnhancementA-MemoryA-Performance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions