Skip to content

Improve cursor performance#13

Merged
jrmajor merged 5 commits intojrmajor:masterfrom
hakastein:cursor-performance
Jun 6, 2023
Merged

Improve cursor performance#13
jrmajor merged 5 commits intojrmajor:masterfrom
hakastein:cursor-performance

Conversation

@hakastein
Copy link
Copy Markdown
Contributor

  1. Updated composer deps
  2. mb_substr replaced to mb_str_split
  3. Node version updated to actual
  4. phpunit.xml.dist updated to actual

Parser bench before:

+------+-------------+-------------------------+-----+------+------------+---------------+--------------+----------------+
| iter | benchmark   | subject                 | set | revs | mem_peak   | time_avg      | comp_z_value | comp_deviation |
+------+-------------+-------------------------+-----+------+------------+---------------+--------------+----------------+
| 0    | ParserBench | benchFirefoxPreferences |     | 10   | 4,622,672b | 368,879.500μs | -0.65σ       | -0.88%         |
| 1    | ParserBench | benchFirefoxPreferences |     | 10   | 4,622,672b | 366,646.000μs | -1.09σ       | -1.48%         |
| 2    | ParserBench | benchFirefoxPreferences |     | 10   | 4,622,672b | 370,244.100μs | -0.38σ       | -0.51%         |
| 3    | ParserBench | benchFirefoxPreferences |     | 10   | 4,622,672b | 373,931.200μs | +0.35σ       | +0.48%         |
| 4    | ParserBench | benchFirefoxPreferences |     | 10   | 4,622,672b | 381,093.800μs | +1.77σ       | +2.40%         |
+------+-------------+-------------------------+-----+------+------------+---------------+--------------+----------------+

After:

+------+-------------+-------------------------+-----+------+------------+--------------+--------------+----------------+
| iter | benchmark   | subject                 | set | revs | mem_peak   | time_avg     | comp_z_value | comp_deviation |
+------+-------------+-------------------------+-----+------+------------+--------------+--------------+----------------+
| 0    | ParserBench | benchFirefoxPreferences |     | 10   | 8,330,040b | 23,806.100μs | -0.93σ       | -1.03%         |
| 1    | ParserBench | benchFirefoxPreferences |     | 10   | 8,330,040b | 23,670.400μs | -1.43σ       | -1.60%         |
| 2    | ParserBench | benchFirefoxPreferences |     | 10   | 8,330,040b | 24,274.300μs | +0.82σ       | +0.91%         |
| 3    | ParserBench | benchFirefoxPreferences |     | 10   | 8,330,040b | 24,171.900μs | +0.44σ       | +0.49%         |
| 4    | ParserBench | benchFirefoxPreferences |     | 10   | 8,330,040b | 24,349.000μs | +1.10σ       | +1.22%         |
+------+-------------+-------------------------+-----+------+------------+--------------+--------------+----------------+

Its looks like we got memory usage x2, but adwantage in speed is more than 15 times. And on bigger files it becomes more significant. 204KB file in example:

Old:

+------+-------------+-------------------------+-----+------+------------+-----------------+--------------+----------------+
| iter | benchmark   | subject                 | set | revs | mem_peak   | time_avg        | comp_z_value | comp_deviation |
+------+-------------+-------------------------+-----+------+------------+-----------------+--------------+----------------+
| 0    | ParserBench | benchFirefoxPreferences |     | 10   | 7,377,128b | 4,960,811.400μs | -1.53σ       | -1.07%         |
| 1    | ParserBench | benchFirefoxPreferences |     | 10   | 7,377,128b | 4,997,625.000μs | -0.48σ       | -0.34%         |
| 2    | ParserBench | benchFirefoxPreferences |     | 10   | 7,377,128b | 5,062,494.200μs | +1.37σ       | +0.96%         |
| 3    | ParserBench | benchFirefoxPreferences |     | 10   | 7,377,128b | 5,011,520.200μs | -0.09σ       | -0.06%         |
| 4    | ParserBench | benchFirefoxPreferences |     | 10   | 7,377,128b | 5,040,271.900μs | +0.73σ       | +0.51%         |
+------+-------------+-------------------------+-----+------+------------+-----------------+--------------+----------------+

New:

+------+-------------+-------------------------+-----+------+-------------+--------------+--------------+----------------+
| iter | benchmark   | subject                 | set | revs | mem_peak    | time_avg     | comp_z_value | comp_deviation |
+------+-------------+-------------------------+-----+------+-------------+--------------+--------------+----------------+
| 0    | ParserBench | benchFirefoxPreferences |     | 10   | 20,932,768b | 84,057.700μs | +0.94σ       | +1.66%         |
| 1    | ParserBench | benchFirefoxPreferences |     | 10   | 20,932,768b | 84,720.500μs | +1.39σ       | +2.46%         |
| 2    | ParserBench | benchFirefoxPreferences |     | 10   | 20,932,768b | 82,237.600μs | -0.31σ       | -0.55%         |
| 3    | ParserBench | benchFirefoxPreferences |     | 10   | 20,932,768b | 80,988.300μs | -1.16σ       | -2.06%         |
| 4    | ParserBench | benchFirefoxPreferences |     | 10   | 20,932,768b | 81,439.900μs | -0.86σ       | -1.51%         |
+------+-------------+-------------------------+-----+------+-------------+--------------+--------------+----------------+

Execution time reduced by more than 60 times. And in our project its not biggest file.

All tests still passed

@jrmajor jrmajor force-pushed the cursor-performance branch from 11d9227 to a53d9ea Compare June 6, 2023 13:09
@jrmajor jrmajor force-pushed the cursor-performance branch from 9a2a7c4 to 32dbf7d Compare June 6, 2023 14:51
@jrmajor jrmajor changed the title Cursor performance Improve cursor performance Jun 6, 2023
@jrmajor
Copy link
Copy Markdown
Owner

jrmajor commented Jun 6, 2023

Wow, this is a significant improvement! Thank you, @hakastein.

@jrmajor jrmajor merged commit ea49d3f into jrmajor:master Jun 6, 2023
@hakastein
Copy link
Copy Markdown
Contributor Author

Thx. There will be more. Ill preparing units support

@hakastein hakastein deleted the cursor-performance branch June 6, 2023 15:24
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