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

ElementLocation optimisations #10029

Open
wants to merge 29 commits into
base: main
Choose a base branch
from

Commits on Apr 17, 2024

  1. Remove redundant GetHashCode calls

    For Int32, GetHashCode just returns the value directly.
    drewnoakes committed Apr 17, 2024
    Configuration menu
    Copy the full SHA
    776ec7a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    37def11 View commit details
    Browse the repository at this point in the history
  3. Update comment

    drewnoakes committed Apr 17, 2024
    Configuration menu
    Copy the full SHA
    cb6ec14 View commit details
    Browse the repository at this point in the history

Commits on Apr 18, 2024

  1. Configuration menu
    Copy the full SHA
    093bee7 View commit details
    Browse the repository at this point in the history
  2. Pack line and column values into four bytes

    The SmallElementLocation class exists because very few element locations require 32 bits to store the line/column values. It uses ushort (2 bytes) instead of int (4 bytes) for each value, in an attempt to reduce memory usage.
    
    However the CLR aligns ushort fields on classes at four-byte boundaries on most (all?) architectures, meaning the optimisation has no effect.
    
    This commit explicitly packs the two values into four bytes to ensure that four bytes is saved per instance.
    drewnoakes committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    65ed4dd View commit details
    Browse the repository at this point in the history
  3. Remove redundant validation

    The caller performs this validation already, and no other code can call this. Avoid some indirection and branching.
    drewnoakes committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    bb30e4f View commit details
    Browse the repository at this point in the history
  4. Simplify LocationString construction

    The compiler will generate slightly better code from this switch statement, in cases where either line or column is zero.
    drewnoakes committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    57e0d5b View commit details
    Browse the repository at this point in the history
  5. Consolidate validation

    There was inconsistent handling of validation between implementations. This moves it all into the `Create` method so that it can be handled in one place, consistently.
    drewnoakes committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    80c1ea2 View commit details
    Browse the repository at this point in the history
  6. Simplify names (IDE0001)

    drewnoakes committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    3ea9a86 View commit details
    Browse the repository at this point in the history
  7. Use auto properties

    drewnoakes committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    075ce08 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    2f1c078 View commit details
    Browse the repository at this point in the history
  9. Make field readonly

    drewnoakes committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    28cfb19 View commit details
    Browse the repository at this point in the history
  10. Use constants

    drewnoakes committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    2acc628 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    596c574 View commit details
    Browse the repository at this point in the history
  12. Use pattern matching

    drewnoakes committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    d461522 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    5ef2a4b View commit details
    Browse the repository at this point in the history
  14. Use primary constructor

    drewnoakes committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    2b81d60 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    fc82d47 View commit details
    Browse the repository at this point in the history
  16. Improve hash function

    drewnoakes committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    be277f6 View commit details
    Browse the repository at this point in the history
  17. Revert field packing

    The CLR does in fact pack these fields adjacent to one another, so we don't have to do this in code ourselves.
    drewnoakes committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    2653348 View commit details
    Browse the repository at this point in the history

Commits on Apr 19, 2024

  1. Inline field

    drewnoakes committed Apr 19, 2024
    Configuration menu
    Copy the full SHA
    efb2f9a View commit details
    Browse the repository at this point in the history

Commits on Apr 22, 2024

  1. Pack ElementLocation more efficiently on 64-bit architectures

    Adds new subtypes for `ElementLocation` that pack to multiples of eight bytes, to avoid wasting space at runtime on padding between instances of this class in memory.
    
    The primary gain here comes from being able to use a smaller value for the `File` value. With this change, there's a lock-free cache of file paths which are then stored by index. When the index is small, as it usually will be, it can be packed for efficiently (e.g. in 2 bytes) than a string reference (8 bytes on 64-bit architectures).
    
    See code comment for more details.
    
    Also remove file IO from unit tests so they run faster.
    drewnoakes committed Apr 22, 2024
    Configuration menu
    Copy the full SHA
    4d4a4ee View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e5ab818 View commit details
    Browse the repository at this point in the history
  3. Simplify test a bit

    drewnoakes committed Apr 22, 2024
    Configuration menu
    Copy the full SHA
    c47008b View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    be049a8 View commit details
    Browse the repository at this point in the history
  5. Add comment

    drewnoakes committed Apr 22, 2024
    Configuration menu
    Copy the full SHA
    3fb49a8 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    c3de378 View commit details
    Browse the repository at this point in the history
  7. Fix assertion

    drewnoakes committed Apr 22, 2024
    Configuration menu
    Copy the full SHA
    a3af7bf View commit details
    Browse the repository at this point in the history
  8. Update test code

    drewnoakes committed Apr 22, 2024
    Configuration menu
    Copy the full SHA
    eeed871 View commit details
    Browse the repository at this point in the history