Skip to content

Improve speed at which language files are loaded - #914

Open
tiffit wants to merge 3 commits into
masterfrom
improve-lang-load
Open

Improve speed at which language files are loaded#914
tiffit wants to merge 3 commits into
masterfrom
improve-lang-load

Conversation

@tiffit

@tiffit tiffit commented Jun 1, 2026

Copy link
Copy Markdown
Member

Locale.class and StringTranslate.class have essentially the same method with some slight modifications. This PR targets both of those classes. From personal profiling, I noticed ~500-600ms faster launch time in GTNH.

remap = false))
private static Object[] split(Iterable<String> iterable, Class<String> type, @Local String s) {
for (int i = 0; i < s.length() - 1; i++) {
if (s.charAt(i) == '=') {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use indexOf?

at = @At(value = "INVOKE", target = "Ljava/util/List;iterator()Ljava/util/Iterator;", remap = false))
private static Iterator<String> createOffThreadIterator(List<String> instance,
@Local(argsOnly = true) InputStream input) {
return new OffThreadLineIterator(input);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait a moment, how does this work? Instead of performing blocking IO operations on the main thread, we create one new off-thread and block the main thread while the off-thread is performing IO operations?

The only possible benefit I see from this is being able to process the lines while the other thread is waiting on IO, but that's a pretty minor benefit assuming this process is IO-bound.

@RecursivePineapple

Copy link
Copy Markdown
Contributor

How much faster is this? I have a hard time believing that the thread dispatch overhead is lower than some basic string operations.

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.

3 participants