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

Performance issue with the redundancy operations #293

Closed
yyzdtccjdtc opened this issue May 27, 2022 · 4 comments
Closed

Performance issue with the redundancy operations #293

yyzdtccjdtc opened this issue May 27, 2022 · 4 comments

Comments

@yyzdtccjdtc
Copy link

x: &(Option<LineNumber>, Option<LineNumber>),
y: &(Option<LineNumber>, Option<LineNumber>),

The struct LineNumber store a usize which is 8 byte. But under normal circumstances, it is very unlikely that a file will have more than 2^32 (4,294,967,295) lines of code. If we replace LineNumber with u32, we can reduce the redundant loading of 0's of the 4 high bytes then improve performance.

According to my tests, if we replace all the LineNumber within hunks.rs file with u32, the average execution time decreased from 4.2s to 3.8s, which is a 10% speedup.

Hope this information helps!

@Wilfred
Copy link
Owner

Wilfred commented May 28, 2022

Agreed, this seems like a worthwhile change.

Which files did you benchmark on? The diffing logic usually takes the majority of the time.

@Wilfred
Copy link
Owner

Wilfred commented May 28, 2022

I tried this: 23f6a9f and I only saw a ~0.3% improvement, measuring on elisp_before.el, load_before.js and Session_before.kt.

Would love a PR if you're doing something different :)

@yyzdtccjdtc
Copy link
Author

Thanks for your reply! These are the two cpp files I used for the benchmarking(Since github wouldn't let me upload .cpp format, I switched them to txt format.). I'll try to create a PR later for you to test.
test2.txt
test.txt

@Wilfred
Copy link
Owner

Wilfred commented May 28, 2022

FWIW I also noticed that column numbers could be u32.

Wilfred added a commit that referenced this issue Jun 13, 2022
It's reasonable to assume that a single column won't exceed four
billion, and this is a small speedup (1% instruction count reduction
on the sample file in #293).
Wilfred added a commit that referenced this issue Jun 15, 2022
This function is hot for textual diffs, such as the sample files in
issue #293. For those files, this produces a 21% reduction in
instruction count.
Wilfred added a commit that referenced this issue Jun 15, 2022
This is a small performance reduction (0.2% increase in instruction
count for the file in #293) but simplifies the code and ensures we're
splitting with the same logic everywhere.
Wilfred added a commit that referenced this issue Jul 4, 2022
This file pair exposed a bunch of perf issues, so it's useful to keep
it around.
Wilfred pushed a commit that referenced this issue Mar 16, 2023
* Fix C# raw_string_literal

* Add test for C# raw string literal
Wilfred pushed a commit that referenced this issue Jun 13, 2023
SYNTAX_COMPLEXITY_CEILING=1300
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