Skip to content

Small enhancements to IndexWriter's InfoStream to support segment tracing #14837

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mikemccand
Copy link
Member

Some small fixes to IndexWriter's InfoStream logging, uncovered when working on the new segment tracing tool from luceneutil (example: https://githubsearch.mikemccandless.com/segments_15.html). I've been sitting on these changes in my main dev area and finally got around to making a PR before I lose track of them, phew!

Details:

  • KNN merging was logging "start/done" multiple times and then I realized it was for a different field each time, so I added field name
  • Thread name was duplicated in a single line at end of full flush
  • Defensive change: don't invoke merge-on-commit logic if merge policy returns empty list of merges
  • I enhanced merge-on-commit logging to state how many merges it will do, and whether all merges completed in the timeout window or not
  • TMP now also logs its deletesPctAllowed and forceMerteDeletesPctAllowed, and more details when it kicks off merge selection

when working on the new segment tracing tool from luceneutil
(example: https://githubsearch.mikemccandless.com/segments_15.html):
  * KNN merging was logging "start/done" multiple times and then I realized it was
    for a different field each time, so I added field name
  * Thread name was duplicated in a single line at end of full flush
  * Defensive change: don't invoke merge-on-commit logic if merge policy returns
    empty list of merges
  * I enhanced merge-on-commit logging to state how many merges it will do,
    and whether all merges completed in the timeout window or not
  * TMP now also logs its deletesPctAllowed and forceMerteDeletesPctAllowed, and
    more details when it kicks off merge selection
Copy link

This PR does not have an entry in lucene/CHANGES.txt. Consider adding one. If the PR doesn't need a changelog entry, then add the skip-changelog label to it and you will stop receiving this reminder on future updates to the PR.

@msokolov
Copy link
Contributor

Seems a bit weird to include a merge policy change in a PR that is mostly about changing logging, but OK. I think I would be happier if the PR was entitled "Don't invoke merge-on-commit logic if merge policy returns empty list of merges" and secondarily patched infoStream logging.

@@ -3724,18 +3724,25 @@ private long prepareCommitInternal() throws IOException {
maybeCloseOnTragicEvent();
}

if (pointInTimeMerges != null) {
if (pointInTimeMerges != null && pointInTimeMerges.merges.size() > 0) {
if (infoStream.isEnabled("IW")) {
infoStream.message(
"IW", "now run merges during commit: " + pointInTimeMerges.segString(directory));
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a TODO to deprecate segString(Directory dir), and indeed the directory is not used anywhere. We can simply use toString() instead. I just happened to find it as I wanted to make sure we log the number of submitted merges. We don't need to address it in this PR, in fact, it could be a good first issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

created #14899 as a "good first issue"

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @vigyasharma -- good idea!

@mikemccand
Copy link
Member Author

Seems a bit weird to include a merge policy change in a PR that is mostly about changing logging, but OK. I think I would be happier if the PR was entitled "Don't invoke merge-on-commit logic if merge policy returns empty list of merges" and secondarily patched infoStream logging.

Oh I can revert that part if you want? And break it into its own PR ...

My primary purpose here was to fix confusing issues with the InfoStream as I was trying to get segment tracing working, and then when I saw MOC logging a pointless/confusing message (now run merges during commit: followed by nothing) I wanted to fix that. But you're right -- it does a lot of addition (pointless) things (besides logging) inside that if...

@mikemccand mikemccand added the skip-changelog Apply to PRs that don't need a changelog entry, stopping the automated changelog check. label Jul 5, 2025
@mikemccand
Copy link
Member Author

OK I restored that if @msokolov -- so now if the MergePolicy returns empty list of merges it'll still run through all the MOC motions, logging empty messages, etc. I'll open a separate PR for that change ... now this PR is really just fixing up InfoStream logging. I plan to merge soon ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module:core/codecs module:core/index skip-changelog Apply to PRs that don't need a changelog entry, stopping the automated changelog check.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants