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

98% cpu usage due to recursion #263

Open
hippalus opened this issue Mar 16, 2021 · 2 comments
Open

98% cpu usage due to recursion #263

hippalus opened this issue Mar 16, 2021 · 2 comments

Comments

@hippalus
Copy link

The dfs recursive method in the WordSegmenter class causes high CPU usage in some scenarios.
See below screenshot of JVM profiler and CPU profiler.

2021-03-16  21 06 18

image

@ahmetaa
Copy link
Owner

ahmetaa commented Mar 16, 2021

Yes, WordSegmenter uses a bad algorithm that works ok in most cases but fails miserably in some cases. It should have been using a dynamic programming approach but sadly it is not. Unfortunately I do not have much spare time to fix this, I would advise using a different algorithm for this.

@ahmetaa
Copy link
Owner

ahmetaa commented Mar 16, 2021

One idea that may alleviate this issue is to split input from spaces before processing with this. Also please provide an example that may cause this bad recursion.

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

2 participants