Служба спасения студентов
Служба спасения для студентов

Protobuf Guided Static Field Stripping and Profiling

Стоимость
550 руб.
Содержание
Теория
Объем
28 лист.
Год написания

Описание работы

Работа пользователя Beskonechno
Добрый день! Уважаемые студенты, Вашему вниманию представляется курсовая работа на тему: «Protobuf Guided Static Field Stripping and Profiling»
 
Оригинальность работы 93%
 
Аннотация
Protocol Buffers – протокол сериализации структурированных данных. На сегодняшний день, это один из самых оптимальных методов сериализации и десериализации, который признан и используется многими компаниями и корпорациями. Несмотря на свою популярность, Protocol Buffers может быть оптимизирован для некоторых задач. Структуры, используемые высоконагруженными большими сервисами, растут достаточно быстро. Это приводит к тому, что некоторые поля не используются, при этом protoc компилятор генерирует все их методы. Избавление от неиспользуемого кода положительно влияет на производительность сервисов и нагрузку на серверы. В данной работе подробно описывается эта проблема, рассматриваются различные подходу к удалению “мертвого” кода и предлагается решение, основанное на двухэтапной компиляции. Реализованный алгоритм показал значительные результаты: увеличение производительности трех больших сервисов компании Google до 0.64%.
Abstract
Protocol Buffers is a language-neutral, extensible mechanism for serializing structured data. Today it is one of the most efficient data serialization techniques and is used by many companies in almost every big project. Despite its popularity, it is still not as efficient as it could be for some tasks. In high-loaded systems, proto schemes grow extremely fast, and not all parts of it are used. At the same time, protoc compiler generates all the field methods, even if it is not used. That leads to the arising of dead code. This thesis illuminates the optimization gap in the protoc compiler, describes different approaches applicable to that problem, and proposes the solution based on two-step compilation. The implemented algorithm showed positive results: the performance of three big Google services was measured, and the performance improved up to 0.64%.
Keywords: Protocol Buffers, dead code elimination, compiler optimization, protoc
 
Contents1Introduction5

1.1Relevance and Significance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5

1.2Problem Overview and Results  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6
2Literature Review7

2.1Mark-Sweep Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7

2.2Post-Link Optimization  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8

2.3FDO................................................8
3Protocol Buffers. Key terms9

3.1Proto Schema . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9

3.2Fields  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10

3.3protoc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10

3.4Generated code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11

3.5Protobuf Usage Pipeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12
4C++ Compilation Process12

4.1Preprocessing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13

4.2Compilation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13

4.3Linkage  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14
5Problem Statement14
6Proposed Solution15

6.1Main ideas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15

6.2Programs, Compiler Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16


6.2.1static  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16


6.2.2volatile  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16


6.2.3-fdata-sections -ffunction-sections . . . . . . . . . . . . . . . . . . . . . . . . . . . .17


6.2.4-g -Wl, --gc-sections  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17


6.2.5objdump . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17


6.2.6c++filt  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18


6.2.7__builtin_trap() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18
 
3
 

6.3Profiling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18

6.4Stripping  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21

6.5Problems Encountered . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22

6.6Other Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23

6.7Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23
7Evaluation23
8Future work24
9Conclusion25
10References26


 
  1. Introduction
Serialization is the process of translating an object to a stream format. An object might be a data structure, a file, a state of some entity, or anything else that is wanted to be stored or transferred through the net. This process always assumes an the existence of an opposite process – deserialization, that recreates the same object from the serialized state.
There are two main groups of serialization techniques for structured data:
  • Text format (JSON, XML, SGML, YAML)
  • Binary format (Protocol Buffers, Apache Avro, Thrift, Msgpack)
Each group has its advantages and disadvantages. Text format most likely will be chosen when human-readability is essential, while the binary format is usually used by high load systems, where the efficiency is crucial.
Protocol Buffers (protobuf) [2] is one of the most popular languages for serial-izing and deserializing structured data. This mechanism was developed by Google and became open-source in 2008 [3]. Google’s reputation and universality of the method played a role, and Protocol Buffers became one of the most popular serial-ization protocols and still stays there. Backward compatibility and workability with all popular programming languages made Protocol Buffers a widely used method as well.
What differentiates Protocol Buffers from current binary analogs is that it does not require any RPC (remote procedure call) implementation. It is convenient to use with gRPC – the RPC implemented by Google, but Protocol Buffers is an independent serialization protocol [2].
1.1    Relevance and Significance
The list of companies that are using protobuf is vast. Some of them are Twitter, OpenStreetMap, Microsoft, medium.com, and, of course, Google [4].
 
5

Reducing the protobuf generated size of code leads to the direct reduction of the final binary executable file. Why is it crucial to make this binary file as small as possible? During the execution, the entire program code uploads to the RAM (see more in C++ Compilation Process section). So, big executable files lead to poor CPU performance due to pressure on several important hardware structures, such as CPU caches, branch predictors. This optimization reduces the usage of resources. Google engineers shared [2] that almost every product in their company uses Protocol Buffers. At the same time, Alphabet Inc. spends billions of dollars for production equipment each year [5], so careful management of computational resources usage improves the performance and saves a lot of money for big compa-nies.

 
10       References
  1. Protocol Buffers documentation. Accessed: Feb. 22 2021 [Online]. Available: https://developers.google.com/protocol-buffers
  1. Github fork of Protobuf repository with the implemented project. Accessed: May 3 2021 [Online]. Available: https://github.com/khasanovaa/protobuf
  1. Popi´c S. et al. Performance evaluation of using Protocol Buffers in the Internet of Things communication //2016 InternationalConference on Smart Systems and Technologies (SST). – IEEE, 2016. – С. 261-265.
  1. Wikipedia: Protocol Buffers. Accessed Feb. 2 2021 [Online]. Available: https://en.wikipedia.org/wiki/Protocol_Buffers
  1. Alphabet investor relations. Accessed: Feb. 22 2021 [Online]. Available: https://abc.xyz/investor/
  1. Protocol Buffers implementation. Accessed: Feb. 22 2021 [Online]. Available: https://github.com/protocolbuffers/protobuf
  1. Cooper K., Torczon L. Engineering a compiler. – Elsevier, 2011.
  1. Endo T., Taura K., Yonezawa A. A scalable mark-sweep garbage collector on large-scale shared-memory machines //SC’97: Proceedings of the 1997 ACM/IEEE Conference on Supercomputing. – IEEE, 1997. – С. 48-48.
  1. Garner R., Blackburn S. M., Frampton D. Effective prefetch for mark-sweep garbage collection //Proceedings of the 6th international symposium on Memory management. – 2007. – С. 43-54.
  1. Armstrong J., Virding R. One pass real-time generational mark-sweep garbage collection //International Workshop on Memory Management. – Springer, Berlin, Heidelberg, 1995. – С. 313-322.
 
26
 
  1. Panchenko M. et al. Bolt: a practical binary optimizer for data centers and beyond //2019 IEEE/ACM International Symposium on Code Generation and Optimization (CGO). – IEEE, 2019. – С. 2-14.
  1. Smith M. D. Overcoming the challenges to feedback-directed optimization (keynote talk) //Proceedings of the ACM SIGPLAN workshop on Dynamic and adaptive compilation and optimization. – 2000. – С. 1-11.
  1. Chen D., Moseley T., Li D. X. AutoFDO: Automatic feedback-directed op-timization for warehouse-scale applications //2016 IEEE/ACM International Symposium on Code Generation and Optimization (CGO). – IEEE, 2016. – С. 12-23.
  1. Wikipedia: Data segment. Accessed May 5 2021 [Online]. Available:
https://en.wikipedia.org/wiki/Data_segment
  1. De Sutter B., De Bus B., De Bosschere K. Link-time binary rewriting techniques for program compaction //ACM Transactions on Programming Languages and Systems (TOPLAS). – 2005. – Т. 27. – №. 5. – С. 882-945.
  1. Static keyword documentation, cppreference. Accessed: May 3 2021 [Online]. Available:
https://en.cppreference.com/w/cpp/keyword/static
  1. Volatile type qualifier documentation, cppreference. Accessed: May 2 2021 [On-line]. Available:
https://en.cppreference.com/w/cpp/language/cv
  1. Reducing Size of Executables with Unused Subprogram/Data Elimination, GCC GNU documentation. Accessed: May 2 2021 [Online]. Available:
https://gcc.gnu.org/onlinedocs/gnat_ugn/Reducing-Size-of-Executables-wi
002fData-Elimination.html
  1. Clang command line argument reference, Clang documentation. Accessed: May
2 2021 [Online]. Available:
https://clang.llvm.org/docs/ClangCommandLineReference.html
 
27

[20] MAN documentation – objdump. Accessed: May 3 2021 [Online]. Available:
https://man7.org/linux/man-pages/man1/objdump.1.html
[21] MAN documentation – c++filt. Accessed: May 3 2021 [Online]. Available:
https://man7.org/linux/man-pages/man1/c++filt.1.html
  1. GCC GNU documentation – Other Built-in Functions Provided by GCC. Ac-cessed: May 4 2021 [Online]. Available:
https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
[23] AST Matcher Reference. Accessed: May 5 2021 [Online]. Available:
https://clang.llvm.org/docs/LibASTMatchersReference.html
  1. Verma, Abhishek, et al. "Large-scale cluster management at Google with Borg." Proceedings of the Tenth European Conference on Computer Systems. 2015.

или напишите нам прямо сейчас:

Написать в WhatsApp Написать в Telegram
Заявка на расчет