Skip to content

Commit 51e6350

Browse files
authored
[DI] Improve internal caching algorithm resource overhead (#4864)
1 parent d9ffb78 commit 51e6350

4 files changed

Lines changed: 18 additions & 10 deletions

File tree

LICENSE-3rdparty.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ require,rfdc,MIT,Copyright 2019 David Mark Clements
3030
require,semver,ISC,Copyright Isaac Z. Schlueter and Contributors
3131
require,shell-quote,mit,Copyright (c) 2013 James Halliday
3232
require,source-map,BSD-3-Clause,Copyright (c) 2009-2011, Mozilla Foundation and contributors
33+
require,ttl-set,MIT,Copyright (c) 2024 Thomas Watson
3334
dev,@apollo/server,MIT,Copyright (c) 2016-2020 Apollo Graph, Inc. (Formerly Meteor Development Group, Inc.)
3435
dev,@types/node,MIT,Copyright Authors
3536
dev,@eslint/eslintrc,MIT,Copyright OpenJS Foundation and other contributors, <www.openjsf.org>

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@
111111
"semver": "^7.5.4",
112112
"shell-quote": "^1.8.1",
113113
"source-map": "^0.7.4",
114-
"tlhunter-sorted-set": "^0.1.0"
114+
"tlhunter-sorted-set": "^0.1.0",
115+
"ttl-set": "^1.0.0"
115116
},
116117
"devDependencies": {
117118
"@apollo/server": "^4.11.0",

packages/dd-trace/src/debugger/devtools_client/status.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
const LRUCache = require('lru-cache')
3+
const TTLSet = require('ttl-set')
44
const config = require('./config')
55
const JSONBuffer = require('./json-buffer')
66
const request = require('../../exporters/common/request')
@@ -18,13 +18,7 @@ const ddsource = 'dd_debugger'
1818
const service = config.service
1919
const runtimeId = config.runtimeId
2020

21-
const cache = new LRUCache({
22-
ttl: 1000 * 60 * 60, // 1 hour
23-
// Unfortunate requirement when using LRUCache:
24-
// It will emit a warning unless `ttlAutopurge`, `max`, or `maxSize` is set when using `ttl`.
25-
// TODO: Consider alternative as this is NOT performant :(
26-
ttlAutopurge: true
27-
})
21+
const cache = new TTLSet(60 * 60 * 1000) // 1 hour
2822

2923
const jsonBuffer = new JSONBuffer({ size: config.maxTotalPayloadSize, timeout: 1000, onFlush })
3024

@@ -120,5 +114,5 @@ function onlyUniqueUpdates (type, id, version, fn) {
120114
const key = `${type}-${id}-${version}`
121115
if (cache.has(key)) return
122116
fn()
123-
cache.set(key)
117+
cache.add(key)
124118
}

yarn.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2422,6 +2422,11 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
24222422
resolved "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz"
24232423
integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==
24242424

2425+
fast-fifo@^1.3.2:
2426+
version "1.3.2"
2427+
resolved "https://registry.yarnpkg.com/fast-fifo/-/fast-fifo-1.3.2.tgz#286e31de96eb96d38a97899815740ba2a4f3640c"
2428+
integrity sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==
2429+
24252430
fast-json-stable-stringify@^2.0.0:
24262431
version "2.1.0"
24272432
resolved "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz"
@@ -4887,6 +4892,13 @@ tslib@^2.4.0:
48874892
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.0.tgz#d124c86c3c05a40a91e6fdea4021bd31d377971b"
48884893
integrity sha512-jWVzBLplnCmoaTr13V9dYbiQ99wvZRd0vNWaDRg+aVYRcjDF3nDksxFDE/+fkXnKhpnUUkmx5pK/v8mCtLVqZA==
48894894

4895+
ttl-set@^1.0.0:
4896+
version "1.0.0"
4897+
resolved "https://registry.yarnpkg.com/ttl-set/-/ttl-set-1.0.0.tgz#e7895d946ad9cedfadcf6e3384ea97322a86dd3b"
4898+
integrity sha512-2fuHn/UR+8Z9HK49r97+p2Ru1b5Eewg2QqPrU14BVCQ9QoyU3+vLLZk2WEiyZ9sgJh6W8G1cZr9I2NBLywAHrA==
4899+
dependencies:
4900+
fast-fifo "^1.3.2"
4901+
48904902
type-check@^0.4.0, type-check@~0.4.0:
48914903
version "0.4.0"
48924904
resolved "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz"

0 commit comments

Comments
 (0)