Skip to content

Instantly share code, notes, and snippets.

@theicfire
Created December 20, 2021 23:06
Show Gist options
  • Save theicfire/7125cc814d8904dd169fb981c770010a to your computer and use it in GitHub Desktop.
Save theicfire/7125cc814d8904dd169fb981c770010a to your computer and use it in GitHub Desktop.
❯ lldb ./benchmark
(lldb) target create "./benchmark"
Current executable set to '/Users/chase/code/examples/slow_proto/benchmark' (arm64).
(lldb) b be
Available completions:
benchmark.cc
beforeForkPrepareDlopen()
(lldb) b benchmark.cc:20
Breakpoint 1: where = benchmark`testProto() + 16 at benchmark.cc:20:26, address = 0x0000000100003d9c
(lldb) run
Process 85505 launched: '/Users/chase/code/examples/slow_proto/benchmark' (arm64)
Proto time: 2ms
Process 85505 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x0000000100003d9c benchmark`testProto() at benchmark.cc:20:26
17 uint8_t memcpy_dest[BUFFER_LEN];
18
19 void testProto() {
-> 20 demo::Person* person = new demo::Person();
21 person->set_data(data, BUFFER_LEN);
22 }
23
Target 0: (benchmark) stopped.
(lldb) n
Process 85505 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x0000000100003db0 benchmark`testProto() at benchmark.cc:21:3
18
19 void testProto() {
20 demo::Person* person = new demo::Person();
-> 21 person->set_data(data, BUFFER_LEN);
22 }
23
24 void testMemcpy() {
Target 0: (benchmark) stopped.
(lldb) s
Process 85505 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step in
frame #0: 0x0000000100003dd0 benchmark`testProto() [inlined] void demo::Person::set_data<unsigned char (&) [10000], int>(this=0x0000600000252420, arg0=<no value available>, args=10000) [10000], int) at demo.pb.h:233:2
230 inline PROTOBUF_ALWAYS_INLINE
231 void Person::set_data(ArgT0&& arg0, ArgT... args) {
232
-> 233 data_.SetBytes(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
234 // @@protoc_insertion_point(field_set:demo.Person.data)
235 }
236 inline std::string* Person::mutable_data() {
Target 0: (benchmark) stopped.
(lldb) s
Process 85505 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step in
frame #0: 0x000000010000423c benchmark`google::protobuf::MessageLite::GetArenaForAllocation(this=0x0000600000252420) const at message_lite.h:490:49
487
488 // Returns the arena, used for allocating internal objects(e.g., child
489 // messages, etc), or owning incoming objects (e.g., set allocated).
-> 490 Arena* GetArenaForAllocation() const { return _internal_metadata_.arena(); }
491
492 internal::InternalMetadata _internal_metadata_;
493
Target 0: (benchmark) stopped.
(lldb) finish
Process 85505 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step out
Return value: (google::protobuf::Arena *) $0 = nullptr
frame #0: 0x0000000100003df0 benchmark`testProto() [inlined] void demo::Person::set_data<unsigned char (&) [10000], int>(this=0x0000600000252420, arg0=<no value available>, args=10000) [10000], int) at demo.pb.h:233:122
230 inline PROTOBUF_ALWAYS_INLINE
231 void Person::set_data(ArgT0&& arg0, ArgT... args) {
232
-> 233 data_.SetBytes(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
234 // @@protoc_insertion_point(field_set:demo.Person.data)
235 }
236 inline std::string* Person::mutable_data() {
Target 0: (benchmark) stopped.
(lldb) s
Process 85505 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step in
frame #0: 0x00000001000041cc benchmark`void google::protobuf::internal::ArenaStringPtr::SetBytes<google::protobuf::internal::ArenaStringPtr::EmptyDefault>(this=0x0000600000252430, p1=EmptyDefault @ 0x000000016fdff1af, str=0x000000010000c080, size=10000, arena=0x0000000000000000) at arenastring.h:223:50
220 void SetBytes(FirstParam p1, const void* str, size_t size,
221 ::google::protobuf::Arena* arena) {
222 // must work whether ConstStringParam is string_view or `const string &`
-> 223 ConstStringParam sp{static_cast<const char*>(str), size};
224 Set(p1, sp, arena);
225 }
226
Target 0: (benchmark) stopped.
(lldb) n
Process 85505 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x00000001000041ec benchmark`void google::protobuf::internal::ArenaStringPtr::SetBytes<google::protobuf::internal::ArenaStringPtr::EmptyDefault>(this=0x0000600000252430, p1=EmptyDefault @ 0x000000016fdff1af, str=0x000000010000c080, size=10000, arena=0x0000000000000000) at arenastring.h:224:13
221 ::google::protobuf::Arena* arena) {
222 // must work whether ConstStringParam is string_view or `const string &`
223 ConstStringParam sp{static_cast<const char*>(str), size};
-> 224 Set(p1, sp, arena);
225 }
226
227 // Basic accessors.
Target 0: (benchmark) stopped.
(lldb) s
Process 85505 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step in
frame #0: 0x00000001000041fc benchmark`void google::protobuf::internal::ArenaStringPtr::SetBytes<google::protobuf::internal::ArenaStringPtr::EmptyDefault>(this=0x0000600000252430, p1=EmptyDefault @ 0x000000016fdff1af, str=0x000000010000c080, size=10000, arena=0x0000000000000000) at arenastring.h:225:3
222 // must work whether ConstStringParam is string_view or `const string &`
223 ConstStringParam sp{static_cast<const char*>(str), size};
224 Set(p1, sp, arena);
-> 225 }
226
227 // Basic accessors.
228 PROTOBUF_NDEBUG_INLINE const std::string& Get() const {
Target 0: (benchmark) stopped.
(lldb) s
Process 85505 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step in
frame #0: 0x0000000100004208 benchmark`void google::protobuf::internal::ArenaStringPtr::SetBytes<google::protobuf::internal::ArenaStringPtr::EmptyDefault>(this=0x000000010000c080, p1=EmptyDefault @ 0x000000016fdff20f, str=0x0000271099f8bd4c, size=105553118700576, arena=0x00000001000d4060) at arenastring.h:225:3
222 // must work whether ConstStringParam is string_view or `const string &`
223 ConstStringParam sp{static_cast<const char*>(str), size};
224 Set(p1, sp, arena);
-> 225 }
226
227 // Basic accessors.
228 PROTOBUF_NDEBUG_INLINE const std::string& Get() const {
Target 0: (benchmark) stopped.
(lldb) f
frame #0: 0x0000000100004208 benchmark`void google::protobuf::internal::ArenaStringPtr::SetBytes<google::protobuf::internal::ArenaStringPtr::EmptyDefault>(this=0x000000010000c080, p1=EmptyDefault @ 0x000000016fdff20f, str=0x0000271099f8bd4c, size=105553118700576, arena=0x00000001000d4060) at arenastring.h:225:3
222 // must work whether ConstStringParam is string_view or `const string &`
223 ConstStringParam sp{static_cast<const char*>(str), size};
224 Set(p1, sp, arena);
-> 225 }
226
227 // Basic accessors.
228 PROTOBUF_NDEBUG_INLINE const std::string& Get() const {
(lldb) s
Process 85505 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step in
frame #0: 0x0000000100003e04 benchmark`testProto() at benchmark.cc:22:1
19 void testProto() {
20 demo::Person* person = new demo::Person();
21 person->set_data(data, BUFFER_LEN);
-> 22 }
23
24 void testMemcpy() {
25 demo::Person* person = new demo::Person();
Target 0: (benchmark) stopped.
(lldb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment