Skip to content

Optimize storage for IcuLocaleData data #45129

Closed

Description

@marek-safar

The massive string which is declared in

is cost close to 10kb on the disc. It should be possible to optimize this to reduce the size as the data are in a very narrow range (low case ASCII only).

@eerhardt

Activity

  1. tarekgh commented on Nov 23, 2020

    @tarekgh
    Member

    [edited comment]

    @marek-safar do you suggest we compress it and expand it at runtime? I think we can store it as ASCII encoding or store it as compressed binary and expand it at runtime.

  2. removed
    untriagedNew issue has not been triaged by the area owner
    on Nov 23, 2020
  3. added this to the 6.0.0 milestone on Nov 23, 2020
  4. krwq commented on Nov 24, 2020

    @krwq
    Member

    @tarekgh I think suggestion might be to use UTF-8 or ASCII rather than UTF-16, that should remove almost half of the bytes

  5. marek-safar commented on Nov 24, 2020

    @marek-safar
    ContributorAuthor

    do you suggest we compress it and expand it at runtime

    Yeah, story it more efficiently so we don't have a massive string in metadata and on a whole copy of it on the heap. Most apps will use a few lcid strings only anyway. There are numerous way how to do it one of them could be to replace s_lcids, s_localeNamesIndices arrays with something like

    static ReadOnlySpan<byte>values => new byte[] {
       // "az" or "az-cyrl" or "az-cyrl-az" 
       (byte)'a', (byte)'z', (byte)'-', (byte)'c', (byte)'y', (byte)'r', (byte)'l', (byte)'-', (byte)'a', (byte)'z', 
    };
    
    // LCID values don't match the real ones in this example
    static readonly int[] s_lcids = new int[]
    {
       // 16bit LCID | index into string values | string value length
       0x10 | 0 << 12 | 7 << 4, // az-cyrl
       0xbb | 0 << 12 | 2 << 4, // az
    };

    There is a dependency from c_localeNames but that could be improved as well

  6. added a commit that references this issue on Nov 28, 2020
    a9ea6e3
  7. added a commit that references this issue on Nov 30, 2020
    e039b92
  8. ghost locked as resolved and limited conversation to collaborators on Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions