Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DB-26-3] Open scavenged chunks quickly. Build midpoints later on demand #4214

Merged
merged 1 commit into from
May 20, 2024

Conversation

timothycoleman
Copy link
Contributor

@timothycoleman timothycoleman commented Mar 28, 2024

Changed: Open the database faster by building the midpoints for scavenged chunks later on demand

Otherwise opening a database with thousands scavenged chunks can become too slow

Copy link

linear bot commented Mar 28, 2024

@sakno
Copy link
Contributor

sakno commented Mar 28, 2024

I have no questions about functional aspects of the proposed changes. From non-functional point of view, there are two improvements possible:

  • If lock contention is rare (this is mentioned in the comments inside of the code), the same can be done in lock-free fashion
  • RequestCaching might start calculation of midpoints in the background task for each chunk (minimal changes are required) and synchronize at its result only on demand.

@timothycoleman timothycoleman marked this pull request as ready for review April 15, 2024 13:52
@hayley-jean hayley-jean changed the title [DB-733] Open scavenged chunks quickly. Build midpoints later on demand [DB-26-3] Open scavenged chunks quickly. Build midpoints later on demand Apr 22, 2024
Copy link
Member

@shaan1337 shaan1337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch 👍 changes look good to me, i've just added a couple of minor comments (and
i also need to do a quick test)

@shaan1337
Copy link
Member

On my machine, basic performance tests show at least a 10x improvement in the opening speed of scavenged chunks at startup.
Previously, it was taking roughly 40ms, now it takes around 1-4ms !

Otherwise opening a database with lots of scavenged chunks is very slow
@timothycoleman timothycoleman force-pushed the timothycoleman/open-scavenged-chunks-faster branch from d177cae to 05508d1 Compare May 20, 2024 14:06
@timothycoleman timothycoleman merged commit bff059d into master May 20, 2024
8 checks passed
@timothycoleman timothycoleman deleted the timothycoleman/open-scavenged-chunks-faster branch May 20, 2024 14:29
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 @timothycoleman Failed to create cherry Pick PR due to error:

RequestError [HttpError]: Merge conflict
   at /home/runner/work/_actions/EventStore/Automations/master/cherry-pick-pr-for-label/node_modules/@octokit/request/dist-node/index.js:66:23
   at processTicksAndRejections (node:internal/process/task_queues:96:5) {
 status: 409,
 headers: {
   'access-control-allow-origin': '*',
   'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset',
   connection: 'close',
   'content-length': '112',
   'content-security-policy': "default-src 'none'",
   'content-type': 'application/json; charset=utf-8',
   date: 'Mon, 20 May 2024 14:29:36 GMT',
   'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
   server: 'GitHub.com',
   'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
   vary: 'Accept-Encoding, Accept, X-Requested-With',
   'x-accepted-github-permissions': 'contents=write',
   'x-content-type-options': 'nosniff',
   'x-frame-options': 'deny',
   'x-github-api-version-selected': '2022-11-28',
   'x-github-media-type': 'github.v3; format=json',
   'x-github-request-id': '3389:253A59:3A967:7399E:664B5E4F',
   'x-ratelimit-limit': '5000',
   'x-ratelimit-remaining': '4990',
   'x-ratelimit-reset': '1716218972',
   'x-ratelimit-resource': 'core',
   'x-ratelimit-used': '10',
   'x-xss-protection': '0'
 },
 request: {
   method: 'POST',
   url: 'https://api.github.com/repos/EventStore/EventStore/merges',
   headers: {
     accept: 'application/vnd.github.v3+json',
     'user-agent': 'octokit-core.js/3.3.2 Node.js/16.20.2 (linux; x64)',
     authorization: 'token [REDACTED]',
     'content-type': 'application/json; charset=utf-8'
   },
   body: '{"base":"cherry-pick-cherry-pick/4214/timothycoleman/open-scavenged-chunks-faster-release/oss-v22.10-df43d468-7c94-4015-bdc9-4957b622ae4b","commit_message":"Merge 05508d14a0fbf8dc76a22b6a3bfec1691e6e7baf into cherry-pick-cherry-pick/4214/timothycoleman/open-scavenged-chunks-faster-release/oss-v22.10-df43d468-7c94-4015-bdc9-4957b622ae4b [skip ci]\\n\\n\\nskip-checks: true\\n","head":"05508d14a0fbf8dc76a22b6a3bfec1691e6e7baf"}',
   request: { agent: [Agent], hook: [Function: bound bound register] }
 },
 documentation_url: 'https://docs.github.com/rest/branches/branches#merge-a-branch'
}

🚨👉 Check https://github.com/EventStore/EventStore/actions/runs/9160288944

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timothycoleman 👉 Created pull request targeting release/oss-v23.10: #4260

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timothycoleman 👉 Created pull request targeting release/oss-v24.2: #4261

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timothycoleman 👉 Created pull request targeting release/oss-v24.4: #4262

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants