Skip to content

Commit

Permalink
Make RIM compile within memcache
Browse files Browse the repository at this point in the history
Summary:
In this approach, we create a weakly defined symbol in TargetHooks.cpp that is defined in the mcrouter-core target and conditionally checked and invoked in the gen utils visitor.

This approach minimizes the amount of changes we want to make as opposed to previous approaches (most of which required making changes to hundreds of target files).

Here we do a few things to make this work:
1. In rim's stats.cpp TARGET, we have to change the odsl library to use the "via_mcrouter" flavor of those targets. autodeps wants to change it back, but that will immediately trigger circular dependencies. For good measure I added, autodeps-skip nocodemods to that target.

2. stuclar taught me about nm and how I can dump the symbols that are compiled in the different modes (dev/opt). I dumped the symbols when building mcrouter_core in both dev and opt mode and I see that gRIMReport is NOT a weak symbol, which IIUC is what we desire.

	P1430729979, P1430693327 have the full pastes.

opt mode:
> 0000000000000000 W _ZN8facebook8memcache8mcrouter10gRIMReportERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS8_EERKSt13unordered_mapIS8_mSt4hashIS8_ESt8equal_toIS8_ESaISt4pairIKS8_mEEE
> 0000000000000000 b _ZZN8facebook8memcache8mcrouter10gRIMReportERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS8_EERKSt13unordered_mapIS8_mSt4hashIS8_ESt8equal_toIS8_ESaISt4pairIKS8_mEEEE14LOGGING_helper

dev mode:
> 00000000002055f0 W _ZN8facebook8memcache8mcrouter10gRIMReportERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS8_EERKSt13unordered_mapIS8_mSt4hashIS8_ESt8equal_toIS8_ESaISt4pairIKS8_mEEE
> _ZZN8facebook8memcache8mcrouter10gRIMReportERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS8_EERKSt13unordered_mapIS8_mSt4hashIS8_ESt8equal_toIS8_ESaISt4pairIKS8_mEEEE14LOGGING_helper

Edit on Version 6:
1. I've extracted productId and plumbed it to RIM.
2. Swayze Test: https://www.internalfb.com/intern/hhvm/automator/workflows/134338/

Another Swayze Test (with CD_MEMCACHE_ATTRIBUTION used):
https://www.internalfb.com/intern/hhvm/automator/workflows/140328/

Reviewed By: stuclar

Differential Revision: D57884193

fbshipit-source-id: 77f67f14b2db93018b668411a9cdc40c043ae4cf
  • Loading branch information
Vignesh Ananth authored and facebook-github-bot committed Jul 25, 2024
1 parent 805351f commit c18055d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mcrouter/TargetHooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ namespace facebook {
namespace memcache {
namespace mcrouter {

/**
* If linked, initializes and reports utilization to RIM.
*/
FOLLY_ATTR_WEAK bool gRIMReport(
const std::vector<std::string>& tenancyHierarchyPath,
const std::unordered_map<std::string, uint64_t>& resourceUsageMap);

/**
* SR factory init hook
*/
Expand Down
4 changes: 4 additions & 0 deletions mcrouter/stat_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,3 +414,7 @@ EXTERNAL_STAT(prefix_acl_concurrent_refresh_fail)
EXTERNAL_STAT(prefix_acl_refresh_success)
EXTERNAL_STAT(prefix_acl_refresh_timeout)
EXTERNAL_STAT(prefix_acl_refresh_error)

#define GROUP visitor_stats
STUI(rim_report_failed, 0, 1)
#undef GROUP
1 change: 1 addition & 0 deletions mcrouter/stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ enum stat_group_t {
suspect_server_stats = 0x40000,
external_stats = 0x80000,
unknown_stats = 0x10000000,
visitor_stats = 0x20000000,
};

/** defines a statistic: name, type, and data */
Expand Down

0 comments on commit c18055d

Please sign in to comment.