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

Disassembler: ContextCache is unperformant for multithreaded analysis #6649

Closed
sad-dev opened this issue Jun 18, 2024 · 0 comments · Fixed by #6650
Closed

Disassembler: ContextCache is unperformant for multithreaded analysis #6649

sad-dev opened this issue Jun 18, 2024 · 0 comments · Fixed by #6650
Assignees
Labels
Status: Internal This is being tracked internally by the Ghidra team
Milestone

Comments

@sad-dev
Copy link
Contributor

sad-dev commented Jun 18, 2024

Is your feature request related to a problem? Please describe.
The code for ContextCache.getWords is shown below:

	private BigInteger lastContextValue;
	private int[] lastContextWords;

	private synchronized int[] getWords(BigInteger value) {
		if (value.equals(lastContextValue)) {
			return lastContextWords;
		}
                ...
		lastContextValue = value;
		lastContextWords = words;
		return words;
	}

As SleighLanguage is mapped one-one with a LanguageID, so is the underlying ContextCache. Thus any Disassembler returned by getDisassembler(Language language,...) will also go through the lock. This severely affects the performance of scripts that run multiple Disassembler instances (or decompiler threads that may also need to disassemble) in parallel.

Describe the solution you'd like
I'm deeply skeptical how much utility the getWordscaching brings, but if it must be preserved I would recommend the use of a concurrent collection plus some size limit or an atomic. Otherwise I would simply do away with it altogether.

Describe alternatives you've considered
Allow clones of the disassembler/sleighlanguage ? Or add bogus copies of each language ?

@ghidra1 ghidra1 added the Status: Triage Information is being gathered label Jun 24, 2024
@ryanmkurtz ryanmkurtz linked a pull request Jun 27, 2024 that will close this issue
@ryanmkurtz ryanmkurtz added Status: Internal This is being tracked internally by the Ghidra team and removed Status: Triage Information is being gathered labels Aug 8, 2024
@ryanmkurtz ryanmkurtz added this to the 11.2 milestone Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Internal This is being tracked internally by the Ghidra team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants