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

[Fix #192]: Add a new "Export to TXT for AI" button#193
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

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