Insane lag spike for a few moments while starting game, cpu usage maxes out all of my 8 threads and ram usage constantly above 2GB, this makes my PC temporarily unusable until MC loads. This is incredibly annoying as I normally am doing something else while waiting for MC to load and my PC gets too laggy to do anything. The lag is mostly tolerable for vanilla, however this slows down load times and is especially apparent on modded clients with forge installed. I have no idea why this keeps happening as it didn't do this previously.
How to replicate:
This started happening to me when I started experimenting with commands, more specifically the /data modify command. I have no idea why this would affect performance while loading the game but apparently it does.
UPDATE 2022/07/03: I haven't touched this report since I made it in 2020 and I feel like I should have. As many people have pointed out in the comments this is indeed caused by the DFU. It still affects 1.19.1-pre2 although now that I am on a different system (Core i5-9300H with 8GB DDR4 and an SSD) this issue is less apparent, however on lower end systems this issue will probably be a lot more visible.
Linked issues
is duplicated by
Attachments
Comments


Confirmed also for macOS 10.14.6 with Oracle java: 1.8.0_77

I have a lag spike (high CPU usage) when
starting any Minecraft Version from the Launcher
starting any world from a running minecraft instance

This does happen, my pc freezes for a bit while loading the game or world, but I may have reasons for it happening

I believe this is most likely caused due to the amount of data fixes the game has to build when the game starts (which has gotten worse since 1.16), possibly related to (if not a duplicate of) MC-188163.

This ticket appears to have not been touched in a bit, aside from my ticket being linked as a dupe. Is there anything I can provide, or do to help diagnose this issue? As I am having similar troubles.

The ticket doesn't really make clear how this happens, you could do a benchmark with older versions to see when this really started happening, but i believe this is due to DFU load on startup, and to me it got worse on 1.16 since the game now almost freezes my OS when loading compared to 1.15.
On another note, i think this is mostly noticeable on low-end systems (like mine), and in my experience the game takes noticeably longer to load than 1.12 such that i need to rely on mods like LazyDFU to make the game playable.
I'm not really a technician, but if they were to make the same approach and load DFU rules when upgrading a world instead of loading everything on every game startup it would make a great difference, and won't make a waste of CPU on players that only play on multiplayer, but again i can't truly make a statement on this.

Can confirm in 1.17.1. Also causes the loading time to be unreasonably high. Opening 1.6.2 (actually, even 1.12.2) and 1.17.1 is a night and day difference. The CPU usage spikes at around 98% and drops to 15% after the world loads.

I did a benchmark with older versions. Start time is time elapsed since javaw.exe process creation until the main menu appears AND javaw.exe cpu usage dies down to 1-3%. CPU time is taken from Process Explorer. I have 6c/12t CPU, so for example 100% load for 10 s would be 120 s CPU time.
[media]
Can confirm in 21w44a.

Can confirm on 1.18 pre1.

Can confirm on 1.18 pre2.
With an older i7-860 it's taking about 55 seconds from launch to CPU usage returning to normal, and around 400 seconds of CPU time.

can confirm on i510300h
for 1.18 pre 4 super lag

think it the java garbage collector

I just want to point out the /data command is unrelated, this is just the case when booting the game. As i've already said a few comments back this seems to be DFU related, here's a comparison with 1.12, 1.18 and 1.18 with LazyDFU.
1.12, CPU usage just after the main menu screen shows up:
[media]
1.18, CPU usage after menu screen shows, can last for about minutes:
[media]
1.18 w/ LazyDFU, CPU usage after the menu shows, about the same as 1.12:
[media]
It'll probably get worse with every version, due to data conversion.

This is an important bug to us, but it is too broad to ever be closed properly. We will continuously work to improve performance. Thanks.

Ah yes, the classic "It's too complex to us to fix" resolution, nevermind that a simple mod that's only 22 lines long fixes it.

It's not "too complex" more that this report is too general, and knowing that Minecraft uses a large amount of the CPU at the start of the game doesn't give enough data to solve these issues. The only reasonable solution is to target main resource dump locations and optimize them while accepting that as Minecraft gets more complex, resource usage will continue to increase.

Yeah, there are lots of factors which contribute to the high cpu usage, seems like giving attention to this report wasn't the best option, as how the description and benchmarks don't say too much about what's the real issue.
In my last comment though, i've showed a comparison between vanilla and a mod that manages to only compile DFU rules until needed instead of every game startup, which alleviates most of the issue.
Sure, someone could do a report that talks specifically about this along with the same solution as this mod, but that wouldn't probably be valid as that'll be more of a change request rather than a bug report so i don't know. I guess we'll have to wait and see how mojang handles this sooner or later.

I assume that a new report could be valid if it points out the specific cause (something like "DataFixerUpper on startup causes excessive CPU usage") or something along those lines.

@Chava. Many thanks for mentioning LazyDFU, it lowered my startup thermals significantly.
I've noticed that minecraft's resource usage has been obnoxious since like v1.13 or something. Apparently that's also when DataFixerUpper came into existence (according to google).
If DFU's purpose is to update my old world then I don't understand why it would be initialized during startup... It isn't needed during startup. I have no worlds for it to update, so those resources are literally being wasted.
Every time minecraft launches to the title screen it puts my i9-9900K through a thermal-cycle stress test by quickly ramping up +40 Celsius and then right back down -40 C after the title screen is loaded 15 seconds later.
My friend's computer sometimes has a thermal shutdown. It's that bad. I don't know why they haven't gone in and optimized this yet. You don't need a new bug report in order to say to yourself "Hmm, we really should optimize the startup or implement an artificial slow-down to make it less intensive...". Especially if someone has already pointed out a major cause AND a fix.
This bug report just boggles my mind that nothing has been done with the information gathered in it (and its associated duplicates).
I took my liquid-cooling apart for maintenance and applied new thermal paste to my CPU just to make sure the problem wasn't on my end. It's not my cooling, it's minecraft's vanilla startup code.

This issue hasn't been resolved at all. It's still there. I've tried launching minecraft on 3 different PCs thinking it's just my PC and on all 3 it was the same, 100% CPU usage on startup. This is unacceptable.


It was resolved as "Invalid", not as Fixed.


I finally updated this with more info.

Can this be reopened? Is there still more info needed?

This ticket has already been resolved as Invalid, please create a new ticket for this issue.

Same here. Why takes 3 minutes to drop the CPU usage from over 90% to normal.
The game just stays in menu.

No longer affects 1.19.4-pre1+ as the datafixer has finally been patched for the client.
Please provide a screenshot of your game with the F3 debug screen enabled.