This is an archive of the discontinued LLVM Phabricator instance.

[XRay][compiler-rt] - Dedupe xray event type strings from different addresses.
Needs ReviewPublic

Authored by kpw on Apr 18 2018, 7:36 PM.

Details

Summary

An immutable, statically allocated Vector class keeps track of the strings.
Sanitizer dependencies are used to avoid linkage problems for users.

Event Timeline

kpw created this revision.Apr 18 2018, 7:36 PM
Herald added subscribers: Restricted Project, delcypher, mgorny. · View Herald TranscriptApr 18 2018, 7:36 PM
dberris added inline comments.Apr 18 2018, 8:48 PM
lib/xray/xray_interface.cc
71

Couple of things:

  • I don't think you need to use the fully qualified name for the type here, we're already in the __xray namespace.
  • I would have thought we can initialise this lazily, on the first call to the type registration function.
lib/xray/xray_unique_string_table.cc
21–24

I suspect you may not actually need these, if you're already in the __xray namespace.

38

Do we not have this yet in the sanitizer_common/... library? And do we actually need this?

99

Consider using __sanitizer::InternalAlloc(...) then placement-new. That's a bit more friendly than calling new directly and relying on the implementation's allocator, which may not be the same as the allocator being used by the sanitizer libraries.

lib/xray/xray_unique_string_table.h
29

Probably use the sanitizer-local typedefs for some of these values -- say u16 instead of uint16_t, etc.

36

Do you really need to use the pimpl idiom?

kpw added a comment.Apr 19 2018, 5:32 PM

Haven't made any changes yet. Thanks for the comments Dean.

lib/xray/xray_interface.cc
71
  1. Good catch.
  2. We can do it either way.
lib/xray/xray_unique_string_table.cc
38
  1. I saw a murmur 2 implementation, but it was part of an implementation file.
  2. I started out wanting to build a hashmap without resizing. Essentially it would grow up until a load factor with something layers like BlockLink. Collision would cause array-wrapped lookahead, and it grows by adding more layers. You can find a value in lookups ~= to the number of Block layers, and it would never have to resize. I decided this patch was "good enough" though.
99

Cool. Didn't know about that method until recently.

lib/xray/xray_unique_string_table.h
29

What's the difference between these? When and why should I prefer sanitizer types?

36

No, but the class must have a known size, which will uglify the header.

dberris added inline comments.Apr 19 2018, 6:49 PM
lib/xray/xray_unique_string_table.cc
38

We should be able to hoist out the existing implementation into a header in sanitizer_common/ if it's already in the sanitizer implementation(s). We can either do that in this change, or in a separate one which this will depend on.

I agree that for the purposes of implementing an efficient string intern table which only really gets looked up very infrequently (i.e. using registration of types) then we shouldn't be over-thinking this data structure/implementation for now.