Skip to content

[Fix #192]: Add a new "Export to TXT for AI" button - #193

Open
kgibm wants to merge 3 commits into
eclipse-mat:masterfrom
kgibm:issue192
Open

kgibm wants to merge 3 commits into
eclipse-mat:masterfrom
kgibm:issue192

Conversation

@kgibm

@kgibm kgibm commented Jun 30, 2026

Copy link
Copy Markdown
Member

Fixes #192

  1. Add a new API AIDetailsProvider class that may be optionally set in a query's getResultMetaData.
  2. Bump MAT to 1.18.0 for the new API.
  3. Add an AIDetailsProvider to the ThreadOverviewQuery so that 2 depths of the tree are exported including all stack frames and all stack frame locals.
  4. Add a new AITextOutputter and associated export button (Export to TXT for AI...). Uses the extension .text to differentiate it from the old TextOutputter that uses .txt. AITextOutputter inherits from TextOutputter and is largely the same with the addition of a prefix to help prompt AI consumers by explaining the format of the output (e.g. nesting with pipe character prefixes) and optionally an additional prefix through AIDetailsProvider to further prompt AI consumers by explaining the output.
  5. The other differences between AITextOutputter and TextOutputter are dictated by the logic in ExportActions: the totals row is suppressed as that adds a lot of fluff especially with expanded rows, and, most importantly, check if the ResultMetaData includes a non-default tree export depth. By default, we don't expand trees. Unlike the TextOutputter, the AITextOutputter ignores current expansion in the Tree and always has a uniform output.
  6. I installed a fresh Eclipse 2026-06 and after loading the project and without doing anything, lots of Eclipse .project, .classpath, .prefs, etc. files were updated. I reviewed the updates and they seemed benign/reasonable, so I guess since we're still keeping Eclipse project files checked in, I'm guessing it's reasonable to commit all of these changes. I'm not sure why Eclipse changed org.eclipse.jdt.core.compiler.release from enabled to disabled.
  7. Add a test that checks that the AITextOutputter works and includes the thread overview query prefix in its output.

@kgibm
kgibm requested review from jasonk000 and krumts as code owners June 30, 2026 20:21
@kgibm

kgibm commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

@jasonk000 @krumts Hey guys, if you have a chance, please review.

Example output (snippet):

List of all known threads and key metadata such as the thread name, if available in the dump. In addition, if available in the dump, nested below each thread is a list of the stack frames of the thread at the time of the dump and below each stack frame, each stack frame local actively referenced by that stack frame.

The result is printed in an ASCII table form with rows and columns. There is a header line with columns separated by a pipe character, followed by a dividing line, and followed by each row of the output with columns separated by a pipe character. If the result is a tree, then the level of nesting is represented by the number of times a row is prefixed by a pipe character.

Object / Stack Frame                                                                                                                                                                                                                                                                                                 |Name                                                                                | Shallow Heap | Retained Heap | Max. Locals' Retained Heap |Context Class Loader                                          |Is Daemon| Priority |State                                                 | State value
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
java.lang.Thread @ 0xfe144cd8                                                                                                                                                                                                                                                                                        |Default Executor-thread-2                                                           |          112 |        61,040 |                            |org.eclipse.osgi.internal.framework.ContextFinder @ 0xe01f13f0|true     |        5 |[alive, in object wait, waiting, waiting indefinitely]|       0x191
|- at java.lang.Object.wait(J)V (Object.java(Native Method))                                                                                                                                                                                                                                                         |                                                                                    |              |               |                            |                                                              |         |          |                                                      |            
|- at com.ibm.ws.threading.internal.BoundedBuffer.waitGet_(J)V (BoundedBuffer.java:189)                                                                                                                                                                                                                              |                                                                                    |              |               |                         16 |                                                              |         |          |                                                      |            
|  |- <Java Local> com.ibm.ws.threading.internal.BoundedBuffer$GetQueueLock @ 0xfe144e48                                                                                                                                                                                                                             |                                                                                    |           16 |            16 |                            |                                                              |         |          |                                                      |            
[...]

@kgibm

kgibm commented Jun 30, 2026

Copy link
Copy Markdown
Member Author
image

kgibm added 3 commits July 1, 2026 08:04
1. Add a new API AIDetailsProvider class that may be optionally set in a query's getResultMetaData.
1. Bump MAT to 1.18.0 for the new API.
1. Add an AIDetailsProvider to the ThreadOverviewQuery so that 2 depths of the tree are exported including all stack frames and all stack frame locals.
1. Add a new AITextOutputter and associated export button (Export to TXT for AI...). Uses the extension .text to differentiate it from the old TextOutputter that uses .txt. AITextOutputter inherits from TextOutputter and is largely the same with the addition of a prefix to help prompt AI consumers by explaining the format of the output (e.g. nesting with pipe character prefixes) and optionally an additional prefix through AIDetailsProvider to further prompt AI consumers by explaining the output.
1. The other differences between AITextOutputter and TextOutputter are dictated by the logic in ExportActions: the totals row is suppressed as that adds a lot of fluff especially with expanded rows, and, most importantly, check if the ResultMetaData includes a non-default tree export depth. By default, we don't expand trees. Unlike the TextOutputter, the AITextOutputter ignores current expansion in the Tree and always has a uniform output.
1. I installed a fresh Eclipse 2026-06 and after loading the project and without doing anything, lots of Eclipse .project, .classpath, .prefs, etc. files were updated. I reviewed the updates and they seemed benign/reasonable, so I guess since we're still keeping Eclipse project files checked in, I'm guessing it's reasonable to commit all of these changes. I'm not sure why Eclipse changed org.eclipse.jdt.core.compiler.release from enabled to disabled.
1. Add a test that checks that the AITextOutputter works and includes the thread overview query prefix in its output.

Signed-off-by: Kevin Grigorenko <kevin.grigorenko@us.ibm.com>
Signed-off-by: Kevin Grigorenko <kevin.grigorenko@us.ibm.com>
Signed-off-by: Kevin Grigorenko <kevin.grigorenko@us.ibm.com>
@jasonk000

Copy link
Copy Markdown
Contributor

@kgibm , I haven't looked in detail yet - but I suggest we name it "Export to Markdown (.md)" or similar, and emit standard markdown. Markdown is lingua franca standard text format for AI tooling.

@kgibm

kgibm commented Jul 2, 2026

Copy link
Copy Markdown
Member Author

That seems reasonable although will require some larger changes. I don't think Markdown has a concept of nested tables (for IResultTree) which is the main thing needed for the threads export. I guess we could do a nested bulleted list, with each bullet item having all non-blank column values as a comma separated list with column name prefix, e.g.:

  • Object / Stack Frame: java.lang.Thread @ 0xfe144cd8, Name: Default Executor-thread-2, Shallow Heap: 112, Retained Heap: 61,040 [...]
    • Object / Stack Frame: at java.lang.Object.wait(J)V (Object.java(Native Method))
      • Object / Stack Frame: com.ibm.ws.threading.internal.BoundedBuffer$GetQueueLock @ 0xfe144e48, Shallow Heap: 16, Retained Heap: 16

@jasonk000 jasonk000 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Mostly, looks OK - only question is are we missing a null check at at result.getMetadata(), and should the file list include .txt?.

@@ -0,0 +1,4 @@
activeProfiles=

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This and related files, to 1.18 bump, are required for this PR?

Comment thread parent/.project
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should be different PR, not blocking.

org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.compiler.release=enabled

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We could align these across all plugins -- any reason not to? Not sure if J9 impact.

eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Similar here, we could make them all 21 for consistency unless there is a blocker.

@Override
public void embedd(Context context, IResult result, Writer writer) throws IOException
{
AIDetailsProvider aiDetailsProvider = result.getResultMetaData().getAIDetailsProvider();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Null check required here for result.getResultMetadata().

{
ExportDialog dialog = new ExportDialog(control.getShell(), //
new String[] { Messages.ExportActions_PlainAiText }, //
new String[] { "*.text" });//$NON-NLS-1$

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is a bit odd to me, should be .txt, or both .txt and .text? :)

@jasonk000

Copy link
Copy Markdown
Contributor

re: Markdown nested. Good point that it does not support nested tables. I looked online, this stackoverflow says that we should put html inside md table cell, but that does not seem like an improvement in end user readability.

@kgibm

kgibm commented Sep 23, 2026

Copy link
Copy Markdown
Member Author

Thanks @jasonk000 for the review. I do still plan on converting this PR to markdown but just haven't found the cycles yet. Do you think it's okay to use nested bulleted list to simulate the table? HTML tables would work but one of the use cases I wanted for this was a simple, human-readable output (as well as LLM readable).

@jasonk000

Copy link
Copy Markdown
Contributor

one of the use cases I wanted for this was a simple, human-readable output (as well as LLM readable).

Yes I think bullets are a good choice. If it is for human + LLM consumption (vs structured like CSV!) then we have flexibility too. The structure can be tweaked over time as well, since the reader (human or LLM) can adapt.

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.

Add a new "Export to TXT for AI" button

2 participants