Skip to content

Native PGO: more targets #67671

Open
Open

Description

@EgorBo

I noticed that the only two binaries we do Native PGO for are clrjit and coreclr (checked on Linux-x64) - I think it should make a difference if we add System.Native and System.Compression (brotli).

Also, I noticed that we don't do instrumentation and PGO consumption on macOS x64. And all arm64 targets but it's a know issue

category:implementation
theme:ready-to-run
skill-level:expert
cost:small
impact:medium

Activity

  1. added
    tenet-performance
    on Apr 6, 2022
  2. ghost added
    untriaged
    on Apr 6, 2022
  3. danmoseley commented on Apr 8, 2022

    @danmoseley
    Contributor

    @agocke which team owns this?

  4. EgorBo commented on Apr 8, 2022

    @EgorBo
    MemberAuthor

    I can take a look at this myself since I got familiar with how it works last week 🙂

  5. self-assigned this
    on Apr 8, 2022
  6. added
    area-CodeGen-coreclr
    and removed on Apr 9, 2022
  7. added this to the 7.0.0 milestone on Apr 9, 2022
  8. ghost removed
    untriaged
    on Apr 9, 2022
  9. EgorBo commented on Apr 10, 2022

    @EgorBo
    MemberAuthor

    I hacked this locally for libSystem.IO.Compression.Native.so and this:

    static byte[] CompressBytes(byte[] bytes)
    {
        using var outputStream = new MemoryStream();
        using var compressStream = new BrotliStream(outputStream, CompressionLevel.Optimal);
        compressStream.Write(bytes, 0, bytes.Length);
        return outputStream.ToArray();
    }
    
    static byte[] DecompressBytes(byte[] bytes)
    {
        using var inputStream = new MemoryStream(bytes);
        using var outputStream = new MemoryStream();
        using var decompressStream = new BrotliStream(inputStream, CompressionMode.Decompress);
        decompressStream.CopyTo(outputStream);
        return outputStream.ToArray();
    }
    
    public static void RunScenario()
    {
        var fileBytes = File.ReadAllBytes(@"somefile.txt"); // 300kb file
        Stopwatch sw = Stopwatch.StartNew();
        while (true)
        {
            sw.Restart();
            DecompressBytes(CompressBytes(fileBytes));
            sw.Stop();
            Console.WriteLine(sw.ElapsedMilliseconds);
        }
    }

    now compresses/decompresses code slightly faster ~4-7% (depending on the input size, smaller the input - higher the benefit) - I expected more but I guess brotli is already heavily optimized by hands

    However, I am not sure I did instrumentation correctly - I feel like it should be done on an unoptimzed code for better info, right? I've done it with -c Release

  10. ghost added
    in-pr
    on Apr 10, 2022
  11. jakobbotsch commented on Apr 11, 2022

    @jakobbotsch
    Member

    However, I am not sure I did instrumentation correctly - I feel like it should be done on an unoptimzed code for better info, right? I've done it with -c Release

    I would expect the profile generated with instrumentation to be the same regardless of optimizations enabled (the optimizations should not be changing the semantics of the probes inserted).

  12. EgorBo commented on Apr 11, 2022

    @EgorBo
    MemberAuthor

    However, I am not sure I did instrumentation correctly - I feel like it should be done on an unoptimzed code for better info, right? I've done it with -c Release

    I would expect the profile generated with instrumentation to be the same regardless of optimizations enabled (the optimizations should not be changing the semantics of the probes inserted).

    Yeah I tested both -O2 and -O0 and noticed zero difference

  13. ghost removed
    in-pr
    on May 28, 2022
  14. modified the milestones: 7.0.0, 8.0.0 on Jul 27, 2022
  15. modified the milestones: 8.0.0, Future on Apr 10, 2023
  16. removed their assignment
    on Dec 4, 2023
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

    area-CodeGen-coreclrtenet-performance

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions