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

optimized filtering #21

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

nvdk
Copy link
Member

@nvdk nvdk commented Jan 23, 2025

builds on #20, but has some optimizations wrt to filtering:

  • by grouping services on match pattern: this means we only do detection and filtering once for a given match pattern (takes the pattern and options.sendMatchesOnly into account as a grouping key)
  • by doing pattern matching before origin filter, since the latter seems more costly

edit: can be tested using nvdk/mu-delta-notifier:feature-optimized-filtering. see https://github.com/lblod/app-lblod-harvester/pull/79/files for an example

this greatly reduces the size of delta messages in stacks with large data changes.
@nvdk nvdk force-pushed the feature/optimized-filtering branch 2 times, most recently from 65ce8d9 to 1854db3 Compare January 23, 2025 15:16
Niels V added 2 commits January 23, 2025 16:19
this tries to optimize filtering and match detection in two ways:
- by grouping on match pattern: this means we only do detection and filtering
once for a given match pattern (takes the pattern and sendMatchesOnly into
account)
- by doing matching before origin filter, since the latter seems more costly
@nvdk nvdk force-pushed the feature/optimized-filtering branch from 1854db3 to 34004ff Compare January 23, 2025 15:33
Niels V added 3 commits January 23, 2025 17:00
this is not the prettiest of solutions, but it does achieve the same thing.
bonus is it only happens once on startup
it's mentioned in the expressjs best practices (and elsewhere) that process.env should be used sparingly:

| If you need to write environment-specific code, you can check the value of NODE_ENV with process.env.NODE_ENV. Be aware that checking the value of any environment variable incurs a performance penalty, and so should be done sparingly.
https://expressjs.com/th/advanced/best-practice-performance.html#set-node_env-to-production

it seems this is because process.env is a getter that processes the ENV array each time
}
} else {
if (process.env["DEBUG_DELTA_SEND"] || process.env["DEBUG_DELTA_NOT_SENDING_EMPTY"])
if (DEBUG_DELTA_SEND || DEBUG_DELTA_NOT_SENDING_EMPTY)
console.log(`Changeset empty. Not sending to ${entry.callback.method} ${entry.callback.url}`);
Copy link
Member Author

Choose a reason for hiding this comment

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

I kept this, but I don't think this situation can occur.

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

Successfully merging this pull request may close these issues.

1 participant