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

[Bug] Diff algorithm performance decrease #4834

Open
1 of 2 tasks
JonathanIcon opened this issue Feb 20, 2025 · 0 comments
Open
1 of 2 tasks

[Bug] Diff algorithm performance decrease #4834

JonathanIcon opened this issue Feb 20, 2025 · 0 comments

Comments

@JonathanIcon
Copy link

Reproducible in vscode.dev or in VS Code Desktop?

  • Not reproducible in vscode.dev or VS Code Desktop

Reproducible in the monaco editor playground?

Monaco Editor Playground Link

No response

Monaco Editor Playground Code

// Hover on each property to see its docs!
const editor = monaco.editor.createDiffEditor(document.getElementById("container"), {
	language: 'javascript',
	defaultEndOfLine: '\n',
	maxComputationTime: 1000000,
	maxFileSize: 10000000
});

let d0;
function start() {
	d0 = Date.now();
	return '';
}
function stop() {
	const elapsed_ms = Date.now() - d0;
	return elapsed_ms + 'ms'
}

async function setModel() {
	console.info('Fetching text...', start());
	const response = await fetch('https://raw.githubusercontent.com/dscape/spell/refs/heads/master/test/resources/big.txt');
	let value = await response.text();
	value = value.substring(0, 1000000);
	console.info('Fetching text...DONE', stop());

	console.info('Initializing...')
	const original = monaco.editor.createModel(value, 'text');
	const modified = monaco.editor.createModel(value.replace(/i/g, 'I'), 'text');
	console.info('Initializing...DONE', stop());

	console.info('Requesting diff...')	
	editor.setModel({original, modified});
	editor.onDidUpdateDiff(() => {
		console.info('Requesting diff...DONE', stop())
	});
}




setModel();

Reproduction Steps

No response

Actual (Problematic) Behavior

Image
Good morning, I've noticed a significant decrease of the diff algorithm performance.
Using exactly the same input v0.52.2 (7.2s) is more than twice slower than v0.37.1 (2.6s)
Moreover depending the size of the input the duration is not linear.
Using 5M characters instead of 1M (ajusting the 2 parameter of the substring value) v0.37.1 gives a diff within 122s and the v0.52.2 260s

Image

Expected Behavior

No response

Additional Context

No response

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

No branches or pull requests

1 participant