Commit 4abe3ff
UTF8 caching for v0.4 (#9434)
* UTF8 caching for v0.4
This change adds UTF-8 encoding caching to optimize v0.4 payload construction.
Since String#getBytes is intrinsified these caches actually perform worse throughput wise than an uncached conversion. However, the caches are useful in reducing allocation from UTF-8 conversions.
For tags, a "simple" cache is used. The simple cache is a single level cache -- that uses hashing combined with linear probing. To avoid, cache churn and unnecessary allocation of a CacheEntry, the simple cache uses a first request marking scheme that typically avoids creating a CacheEntry for values that are requested only once. Eviction from the "simple" cache is done based on LFU policy.
For tag values, a more complicated generational cache is used. The generational cache combines the delayed CacheEntry logic of the simple cache with a 2nd-level for resilience.
Frequently used entries are "promoted" to the higher level cache. The 1st level of the generational cache uses a LFU eviction policy. The 2nd level of the generational cache uses a LRU eviction policy.
For the value use cache, the generational policy provided 2x increase in hit rate over the simple cache.
* spotless
* Tweaking comments
* Tweaking comments
* Comparing results with caching off
* Fixing silly oversight when cache is disabled
* Adding comments about benchmark data being used
* Misc improvements
- implementing review feedback
- experimenting with exact hash based marking scheme
- fixed issue with not updating entry after hit in simple cache
- re-enabling cache by default for benchmarking
- spotless
* Tweaking the cache heuristics
- altered marking strategy to use a bloom filter of previously requested values, once a new entry hits the filter the filter is reset to zero
- tweaking cache sizes
* spotless
* Clean-up & tweaking
- clean-up based on review feedback
- making naming consistent - some vestiges of prior names for second level cache updated
- tweaked generational cache to check tenured entries first
-
* Tweaking settings to be good at multiple memory levels
- switching generational cache to use different probe lengths for eden vs tenured generation
- these settings are neutral or better throughput wise for petclinic for 64m, 80m, 96m, and 128m heaps
* Fixing oversight from marking change
Should be using adjHash not value.hashCode
* Fixing bug introduced with different probes lengths for eden & tenured
* More clean-up
- more explanatory comments
- more naming updates: local -> eden
* Misc fixes
- adding protections against storing large strings in cache
- fixed errant use of CacheEntry.utf8(String) instead of entry.utf8()
- removed unnecessary lookupTimeMs variable
* Fixing benchmarks brought over from standalone prototype
* test & benchmark clean-up
Added tests to verify that big strings are not cached
* Added some explanatory comments
* Update dd-trace-core/src/jmh/java/datadog/trace/common/writer/ddagent/Utf8Benchmark.java
Co-authored-by: Brice Dutheil <brice.dutheil@gmail.com>
* Making cache more configurable & clean-up
- added ability to configure cache size - for both tag names & values
- factored shared code into Caching static utility class
- added tests for Caching class & size determination logic
* fix: small compilation fix
---------
Co-authored-by: Brice Dutheil <brice.dutheil@gmail.com>1 parent cb08250 commit 4abe3ff
File tree
10 files changed
+1379
-14
lines changed- dd-trace-api/src/main/java/datadog/trace/api/config
- dd-trace-core/src
- jmh/java/datadog/trace/common/writer/ddagent
- main/java/datadog/trace/common/writer/ddagent
- test/java/datadog/trace/common/writer/ddagent
- internal-api/src/main/java/datadog/trace/api
10 files changed
+1379
-14
lines changedLines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
| 109 | + | |
108 | 110 | | |
109 | 111 | | |
110 | 112 | | |
| |||
Lines changed: 147 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
Lines changed: 81 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
0 commit comments