当前位置:网站首页>4、 High performance go language release optimization and landing practice youth training camp notes

4、 High performance go language release optimization and landing practice youth training camp notes

2022-07-07 07:24:00 A low-key horse

High performance Go Language distribution optimization and implementation practice | Youth Camp notes

This is my participation 「 The third youth training camp - Back end field 」 The third part of note creation activities 4 Notes

Memory aspect

One 、 Automatic memory management

Concept :

  • Mutator: Business thread , Assign new objects , Modify the object pointing relationship ( Created goroutine)

  • Collector:GC Threads , Find the living object , Reclaim memory space of dead objects

  • Serial GC: only one collector

  • Parallel GC: Support multiple collectors Recycled at the same time GC Algorithm

  • Concurrent GC:mutator(s) and collector(s) It can be executed at the same time

    image-20220514194319723

    image-20220514194346802

GC:

  • GC Algorithm : Security 、 Throughput rate 、 Pause time 、 Memory overhead

  • Track garbage collection :

    • Tag root object
    • Mark reachable objects
    • Clean up unreachable objects
    • Use different marking and cleaning strategies according to the life cycle of the object
  • generational GC:

    • Age : experienced GC The number of times

    • Purpose : For young or old people of different ages , Develop different strategies GC Strategy , Reduce overall memory management overhead

      image-20220514195852135

  • Reference count :

    • Each object has the number of references associated with it , Greater than 0 It's survival
    • The disadvantage is that ring data structures cannot be recycled 、 Maintaining reference counts is expensive

Two 、Go Memory management and optimization

Memory allocation :

  • Block

  • cache

  • Management optimization

    go Memory allocation

    • Actual optimization plan :Balanced GC

Compiler optimization

One 、 Compiler and static analysis

Compiler structure :

Static analysis :

In process analysis 、 Interprocess analysis :

Two 、Go Compiler optimization

Function inlining :

Escape analysis :

Static analysis :

In process analysis 、 Interprocess analysis :

Two 、Go Compiler optimization

Function inlining :

Escape analysis :

Beast mode

原网站

版权声明
本文为[A low-key horse]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207070339543014.html