Jump to content

Recommended Posts

Posted

Hi out there,

 

with Minecraft 1.8 BlockPos was introduced to keep game coordinates x, y and z including its operations for easier developement and (as told) easier modding. Nevertheless, the great people from optifine found out that minecraft became much slower because of heavily using such constructors. I tried to find a better solution for the BlockPos way and found out that using an int[] with 3 fields (0 = x, 1 = y, 2 = z) is much faster. But how could this information help?

 

I set up a forge clone on my computer and tried some experiments, finding real performance boosts and could make Minecraft smooth playable again on my computer. Now I'm trying to share this solution, maybe one of you knows what to do with this. I'd like to see my changes in forge main branch, but I suppose this change is too big for forge to accept it. But maybe someone is interested in this, I give reports from time to time on my homepage for this topic: http://jottyfan.de/minecraft/blockpost/. In the end, there is a download of the generated patch files, if anyone wants to try this on his own computer.

 

Could be that I didn't do things right, so be careful - I didn't want to do some harm, just to make the minecraft world a bit better as this is still the greatest game that I know. This way, I'd like to give sth. back to all of you modders that created really fantastic extensions.

 

Regards

Posted

The optifine people who started the smear campaign against BlockPos are not worth listening to.

Tho your page is interesting it's not something I didn't already know. Your timing system is also off a bit. It doesn't take into account some of the eccentricities of how the jvm class system works.

 

However, it is definitly not worth it to re-write the entire Minecraft codebase to do it.

I've toyed with the idea of writing a generic class transformer that attempts to translate the use of BlockPos to ints at runtime but couldn't get anything that was worth the effort.

 

It's all a balance of how much do I want to edit the core Minecraft engine.

How much work in development and future support will I need to do for it.

What impact it has on modder usability.

vs

What is the actual performance benefits are.

 

And in this equation it's costs far outweigh its benefits. Unless someone can come up with a magic solution I don't see forge doing anything this radical.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

Well, thanks for your comments, I think this is great for discussions, and maybe there are some better solutions. If so, I'd like to know, just post it here.

 

If values types comes to Java one day, the BlockPos class may be a good solution. But for now, minecraft original sources (1.8.3) are build against java 1.7.0_55 (currently we've got 1.8 ), and I wonder when the performance boost could come.

 

May it be that new Date() is bad for time measures, but I could also play much smoother after changing. And this is what I want to reach - make minecraft 1.8 playable again without lags. That was my intension, and waiting for a better release in the future is no solution for me.

 

About the vm: I'm using oracle java 1.8.0_31, and if this would be as smart as mentioned, why can I still see this big performance differences? Using an int[] instead of a new class is really faster, this is a fact.

 

Next topic: the optifine people. I didn't know about disagreements with them, their changes to minecraft have made really great performance boosts on old versions, and I think that their opinion should at least be heard. I wouldn't be able to do what they did.

 

@LexManos: if you still have found a better solution, where can I find it to try it out? Maybe it gives me the performance boost on my computer to make minecraft smooth again.

 

Well, if forge rejects to do something into this direction, any other project could do so. The time of minecraft's public boost seems to be over since Microsoft built it, but if it could become playable again (currently, in 1.8.3 native it isn't), I suppose it to be interesting again. Whatever Microsoft will do with the game, if they publish a new version, people will look at performance and mod compatibilities first - and this is why forge should care about such performance things.

 

Just my opinions, but I'm open for yours.

 

Regards

Posted

Ok, so if this is the case, I wonder why minecraft became so much slower in 1.8 compared to 1.7. I really cannot play 1.8 on a quad core i5 with 16 GB ram - because of lags. What other reason could it be?

 

Besides, I did the benchmark tests also and added a method

private static int getMetadata(int x, int y, int z)

to compare the real int values also, and this is the result:

 

t.m.BlockPosBM.blockPos    avgt      10  1,239        0,095  ns/op

t.m.BlockPosBM.intArr      avgt      10  1,242        0,068  ns/op

t.m.BlockPosBM.ints        avgt      10  1,187        0,038  ns/op

 

I'm not sure how to interpret this results - but it seems really not to make this big difference. But why is minecraft running smooth on my computer after the described changes and lagging if I use the original version? Maybe this benchmark test doesn't come close enough to reality?

 

I'm still confused...

Posted

BlockPos has nothing to do with your speed issues.

Had a second to look at your webpage and your test code. And I found out why your tests were showing 'instant' times for the int version.

 

Simplified it into these 3 lines of code, to see if you can spot the issue:

int x = 0;

for(; x < 100; x++);

for(; x < 100; );

 

See the problem? The second loop is never run, because the condition is satisfied by the first loop.

This is the same case with your 'benchmarks' on your webpage.

 

Point is, it's complicated, but int[] and BlockPos are almost identical. They are both roughly a 12 byte section of memory, they are pushed as pointers on the stack when calling through methods. On any modern system there field access times are almost identical. Last time I looked at the machine code generated for native field access it was a simple memory pointer.

 

The reason 1.8 is different then 1.7 is cuz a lot of shit related to rendering has changed.

A lot of shit related to a lot of things has changed.

The rendering changes arnt the best, could be a bit more performant on some systems, however, OVERALL it's a bit of improvement on the average system.

It is also a MAJOR benefit to the flexibility and functionality of the renderer {it's mojang so nothing is ever complete, but its a big step in the right direction}

 

So, basically what you should do is learn how to digest a flight recorder log, or jprofiler. Dig around and see where, for you, the game is eating up time and see if you can find a clue to what could be fixed.

There will not be any 'magic bullet', there is no way you can put everything on BlockPos's shoulders just doesn't fly. Everyone likes to throw out big numbers and complain about object churn. BlockPos is the EXACT type of Object Churn the JVM LOVES and is specifically designed to deal with without breaking a sweat.

 

So ya, basically, BlockPos isn't your prolem, and it's not as bad as everyone makes it out to be.

There is no need for Forge to re-write everything in Minecraft because people THINK they are bad.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

Thanks for your responses.

 

As far as I've understood, replacing BlockPos doesn't help to improve minecraft to run smoother. I can accept this due to the benchmark results. Maybe it's just forge itself that gave me the performance boost on minecraft 1.8. Then it would be fine enough for me.

 

I've tried this out by installing the latest version of forge and run minecraft 1.8.1 native and forge 11.14.1.1336, and found out that:

 

* with minecraft 1.8.1 I've got about 60 fps on flying around in creative mode

* with forge I've got about 70 fps on flying around in creative mode

 

So there seems to be a performance boost simply by using forge instead of vanilla only - this could be what I thought BlockPos replacement could have done.

 

For comparison: on 1.7.10 (vanilla) I got 55 fps on same settings - seems I've been too fastidious to realize reality.

 

Anyway, this is a good point to give up the migration project.

 

But - I've learned a lot about forge, and if there is something for me to help in making forge improve minecraft's performance, please let me know.

 

Regards

 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.