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

fix: mergeParser is registered twice #407

Merged
merged 1 commit into from
Oct 5, 2023

Conversation

hz1624917200
Copy link
Contributor

Hi,
I'm reading your source code recently. It's beautiful work that providing a unified platform for binary instrumentation. But I found a bug, which may significantly reduces the efficiency.

The mergeParser will register itself to reporter while being initialized in merge-file-parser.cc:66

	MergeParser(IReporter &reporter, const std::string &baseDirectory, const std::string &outputDirectory, IFilter &filter) :
			m_baseDirectory(baseDirectory), m_outputDirectory(outputDirectory), m_filter(filter)
	{
		reporter.registerListener(*this);
	}

However, it's registered manually in main.cc, which is deleted in this commit. This can be easily reproduced by adding INFO_MSG to g_kcov_debug_mask in util.cc:27, every REPORT line from the mergeParser will be duplicated, which means the mergePaser's callback function onLineReporter is called twice.

This will cause redundant callback when each line of source code is parsed by the parser. According to my test report, this will add about 30% overhead on parsing stage.

Thank you for your reading. I'm looking forward to your further feedback.

(ps: Sorry for my English, I'm not a native speaker.)

@SimonKagstrom
Copy link
Owner

Good catch, thanks a lot!

@SimonKagstrom SimonKagstrom merged commit 4581902 into SimonKagstrom:master Oct 5, 2023
6 of 7 checks passed
@hz1624917200 hz1624917200 deleted the bugfix branch October 5, 2023 04: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.

2 participants