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

Osgl performance issue - too many temporary objects generated with functional call chain. #236

Open
greenlaw110 opened this issue Mar 8, 2020 · 0 comments
Assignees

Comments

@greenlaw110
Copy link
Collaborator

Context

In a technical chat room, it was talking about use a Java program to simulate the following shell command:

cat *.log | grep 'Login' | sort | uniq -c | sort -nr

I have come up with a project to implement the function. After I get the function working logically, I start check the performance of the app and found issue with osgl-tool library.

Issue

I have generated 100 log files with each file got 2M lines. Then I run my code. What I found is when I change this line:

C.seq(bigLines).filter(s -> s.contains(keyword)).accept(lineCollector);

to

for (String line: bigLines) {
    if (line.contains(keyword) {
        lineCollector.accept(line);
    }
}

The performance has been improved from 12s to 10s. I use VisualVM to inspect what happened, and found there are lots of temporary objects created when we are using the functional programming style:

image

@greenlaw110 greenlaw110 self-assigned this Mar 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant