I started to look at PMP and perf profiles while running ann-benchmarks and when ef_search is large I see much time in memory allocation functions, most from VisitedSet code, during search_layer.
I am curious about two things:
1) Why is such a large value for est_size passed to the VisitedSet ctor here? This creates huge bloom filters as each uses about 2*est_size bytes, and with ef_search=400 (see example below) that is ~32MB. Such large alloc / dealloc cycles are slow when frequent.
2) Why does "bv" use longlong which is 8 bytes while (see here) while the num_blocks math (see here) appears to assume the bv vector is 4 bytes per entry. For one example:
- n = 15,044,334
- m = 143,931,441 (~= 10 * n)
- log_num_blocks = 22
- num_blocks = 4,194,304
- bv.resize(4194304) is called, which provides about 33,554,432 bits
The est_size variable is: est_heuristic * (ef ^ ef_power), from here. This ends up creating huge bloom filters when used by the VisitedSet ctor.
All of these are from queries with LIMIT 10
With ef_search=120 the math is: 39.x * (120 ^ 2) = 1135647 and visited.count is <= 2000 at the end of search_layer
With ef_search=200 the math is: 39.x * (200 ^ 2) = 3398947 and visited.count is <= 2000 at the end of search_layer()
With ef_search=300 the math is: 39.x * (300 ^ 2) = 8114222 and visited.count is <= 3000 at the end of search_layer()
With ef_search=400 the math is: 39.x * (400 ^ 2) = 15044334 and visited.count is <= 3000 at the end of search_layer()
- is duplicated by
-
MDEV-36338
vector search with Cosine Distance is slow
-
-
Closed
{"report":{"fcp":863.5,"ttfb":265.2999999523163,"pageVisibility":"visible","entityId":132478,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"21c64498-696e-482c-b6f2-4a74437644cb","navigationType":0,"readyForUser":912.1999998092651,"redirectCount":0,"resourceLoadedEnd":1157.5,"resourceLoadedStart":283.5,"resourceTiming":[{"duration":147.59999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":283.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":283.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":431.09999990463257,"responseStart":0,"secureConnectionStart":0},{"duration":147.29999995231628,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":283.7999999523163,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":283.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":431.09999990463257,"responseStart":0,"secureConnectionStart":0},{"duration":156.89999985694885,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":283.7999999523163,"connectEnd":283.7999999523163,"connectStart":283.7999999523163,"domainLookupEnd":283.7999999523163,"domainLookupStart":283.7999999523163,"fetchStart":283.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":283.7999999523163,"responseEnd":440.69999980926514,"responseStart":440.69999980926514,"secureConnectionStart":283.7999999523163},{"duration":226.90000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/099b33461394b8015fc36c0a4b96e19f-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":283.89999985694885,"connectEnd":283.89999985694885,"connectStart":283.89999985694885,"domainLookupEnd":283.89999985694885,"domainLookupStart":283.89999985694885,"fetchStart":283.89999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":283.89999985694885,"responseEnd":510.7999999523163,"responseStart":510.7999999523163,"secureConnectionStart":283.89999985694885},{"duration":230.59999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/94c15bff32baef80f4096a08aceae8bc-CDN/lu2bu7/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":284.09999990463257,"connectEnd":284.09999990463257,"connectStart":284.09999990463257,"domainLookupEnd":284.09999990463257,"domainLookupStart":284.09999990463257,"fetchStart":284.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":284.09999990463257,"responseEnd":514.6999998092651,"responseStart":514.6999998092651,"secureConnectionStart":284.09999990463257},{"duration":231.09999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":284.09999990463257,"connectEnd":284.09999990463257,"connectStart":284.09999990463257,"domainLookupEnd":284.09999990463257,"domainLookupStart":284.09999990463257,"fetchStart":284.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":284.09999990463257,"responseEnd":515.1999998092651,"responseStart":515.1999998092651,"secureConnectionStart":284.09999990463257},{"duration":231.60000014305115,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":284.19999980926514,"connectEnd":284.19999980926514,"connectStart":284.19999980926514,"domainLookupEnd":284.19999980926514,"domainLookupStart":284.19999980926514,"fetchStart":284.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":284.19999980926514,"responseEnd":515.7999999523163,"responseStart":515.7999999523163,"secureConnectionStart":284.19999980926514},{"duration":232,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bu7/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":284.2999999523163,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":284.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":516.2999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":231.79999995231628,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":284.5,"connectEnd":284.5,"connectStart":284.5,"domainLookupEnd":284.5,"domainLookupStart":284.5,"fetchStart":284.5,"redirectEnd":0,"redirectStart":0,"requestStart":284.5,"responseEnd":516.2999999523163,"responseStart":516.2999999523163,"secureConnectionStart":284.5},{"duration":232.20000004768372,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bu7/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":284.59999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":284.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":516.7999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":232.30000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/3339d87fa2538a859872f2df449bf8d0-CDN/lu2bu7/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":284.69999980926514,"connectEnd":284.69999980926514,"connectStart":284.69999980926514,"domainLookupEnd":284.69999980926514,"domainLookupStart":284.69999980926514,"fetchStart":284.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":284.69999980926514,"responseEnd":517,"responseStart":517,"secureConnectionStart":284.69999980926514},{"duration":413.2999999523163,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":285.39999985694885,"connectEnd":285.39999985694885,"connectStart":285.39999985694885,"domainLookupEnd":285.39999985694885,"domainLookupStart":285.39999985694885,"fetchStart":285.39999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":285.39999985694885,"responseEnd":698.6999998092651,"responseStart":698.6999998092651,"secureConnectionStart":285.39999985694885},{"duration":871.9000000953674,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":285.59999990463257,"connectEnd":285.59999990463257,"connectStart":285.59999990463257,"domainLookupEnd":285.59999990463257,"domainLookupStart":285.59999990463257,"fetchStart":285.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":285.59999990463257,"responseEnd":1157.5,"responseStart":1157.5,"secureConnectionStart":285.59999990463257},{"duration":488.59999990463257,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":667.5,"connectEnd":667.5,"connectStart":667.5,"domainLookupEnd":667.5,"domainLookupStart":667.5,"fetchStart":667.5,"redirectEnd":0,"redirectStart":0,"requestStart":667.5,"responseEnd":1156.0999999046326,"responseStart":1156.0999999046326,"secureConnectionStart":667.5},{"duration":319.5,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":839.6999998092651,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":839.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1159.1999998092651,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":144,"responseStart":265,"responseEnd":267,"domLoading":281,"domInteractive":1181,"domContentLoadedEventStart":1181,"domContentLoadedEventEnd":1216,"domComplete":2181,"loadEventStart":2181,"loadEventEnd":2183,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1166},{"name":"bigPipe.sidebar-id.end","time":1166.6999998092651},{"name":"bigPipe.activity-panel-pipe-id.start","time":1166.8999998569489},{"name":"bigPipe.activity-panel-pipe-id.end","time":1169.1999998092651},{"name":"activityTabFullyLoaded","time":1221.5999999046326}],"measures":[],"correlationId":"796536da50fa3a","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":74,"dbReadsTimeInMs":10,"dbConnsTimeInMs":16,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}