atlarge-research / opencraft

Other
5 stars 2 forks source link

Pulse optimization - [merged] #178

Closed jdonkervliet closed 4 years ago

jdonkervliet commented 4 years ago

In GitLab by @swabbur on Jun 11, 2020, 02:42

Merges feature/optimizations -> development

Resolves issue #105 and #112.

The main gameloop was quite messy and filled with code duplication, I've tried to clean it up as much as I could, using the Stream API to allow us to process parts of the loop in parallel.

jdonkervliet commented 4 years ago

In GitLab by @JimVliet on Jun 11, 2020, 10:02

Commented on src/main/java/net/glowstone/GlowWorld.java line 709

Do we have any indication as to whether the JVM can optimize this the same/better than a normal for loop?

jdonkervliet commented 4 years ago

In GitLab by @swabbur on Jun 11, 2020, 10:05

Commented on src/main/java/net/glowstone/GlowWorld.java line 709

I expect it to be harder to optimize, so finding an alternative would be crucial to ensure performance. Do you know a better way of doing this via the Stream API?

jdonkervliet commented 4 years ago

In GitLab by @swabbur on Jun 12, 2020, 01:31

Commented on src/main/java/net/glowstone/GlowWorld.java line 709

changed this line in version 2 of the diff

jdonkervliet commented 4 years ago

In GitLab by @swabbur on Jun 12, 2020, 01:31

added 1 commit

Compare with previous version

jdonkervliet commented 4 years ago

In GitLab by @swabbur on Jun 12, 2020, 01:33

added 1 commit

Compare with previous version

jdonkervliet commented 4 years ago

In GitLab by @swabbur on Jun 12, 2020, 09:25

added 1 commit

Compare with previous version

jdonkervliet commented 4 years ago

In GitLab by @swabbur on Jun 12, 2020, 09:40

added 1 commit

Compare with previous version

jdonkervliet commented 4 years ago

In GitLab by @swabbur on Jun 12, 2020, 11:56

added 1 commit

Compare with previous version

jdonkervliet commented 4 years ago

In GitLab by @swabbur on Jun 13, 2020, 10:07

added 2 commits

Compare with previous version

jdonkervliet commented 4 years ago

In GitLab by @swabbur on Jun 15, 2020, 18:01

added 13 commits

Compare with previous version

jdonkervliet commented 4 years ago

In GitLab by @swabbur on Jun 16, 2020, 17:48

added 2 commits

Compare with previous version

jdonkervliet commented 4 years ago

In GitLab by @swabbur on Jun 16, 2020, 18:02

added 1 commit

Compare with previous version

jdonkervliet commented 4 years ago

In GitLab by @JimVliet on Jun 16, 2020, 18:19

Commented on src/main/java/net/glowstone/GlowWorld.java line 761

The arguments should all be on different lines.

jdonkervliet commented 4 years ago

In GitLab by @JimVliet on Jun 16, 2020, 19:44

Commented on src/main/java/net/glowstone/chunk/ChunkIterator.java line 21

Might it be worth it to clone the area here, to ensure that mutating the area of interest does not break the iterator?

jdonkervliet commented 4 years ago

In GitLab by @JimVliet on Jun 16, 2020, 19:56

Commented on src/main/java/net/glowstone/GlowWorld.java line 709

Not really.

jdonkervliet commented 4 years ago

In GitLab by @swabbur on Jun 17, 2020, 14:12

Commented on src/main/java/net/glowstone/chunk/ChunkIterator.java line 21

The area class is immutable, all its fields are final. So, no copying is required anywhere.

jdonkervliet commented 4 years ago

In GitLab by @swabbur on Jun 17, 2020, 15:28

added 3 commits

Compare with previous version

jdonkervliet commented 4 years ago

In GitLab by @swabbur on Jun 17, 2020, 15:42

Commented on src/main/java/net/glowstone/GlowWorld.java line 761

changed this line in version 12 of the diff

jdonkervliet commented 4 years ago

In GitLab by @swabbur on Jun 17, 2020, 15:42

added 2 commits

Compare with previous version

jdonkervliet commented 4 years ago

In GitLab by @swabbur on Jun 17, 2020, 16:57

added 1 commit

Compare with previous version

jdonkervliet commented 4 years ago

In GitLab by @swabbur on Jun 17, 2020, 17:01

Commented on src/main/java/net/glowstone/GlowWorld.java line 761

I've fixed these lines. Must have been interrupted while refactoring it haha

jdonkervliet commented 4 years ago

In GitLab by @swabbur on Jun 17, 2020, 17:01

unmarked as a Work In Progress

jdonkervliet commented 4 years ago

In GitLab by @swabbur on Jun 17, 2020, 17:01

changed the description

jdonkervliet commented 4 years ago

In GitLab by @JimVliet on Jun 17, 2020, 17:02

resolved all threads

jdonkervliet commented 4 years ago

In GitLab by @larsdetombe on Jun 17, 2020, 18:27

I think you forgot to mention that this merge request also solves #112 right?

jdonkervliet commented 4 years ago

In GitLab by @larsdetombe on Jun 17, 2020, 18:31

Commented on src/main/java/net/glowstone/GlowWorld.java line 1677

Was this method unused? Or did we change other methods such that this method was not required anymore?

jdonkervliet commented 4 years ago

In GitLab by @larsdetombe on Jun 17, 2020, 18:33

Commented on src/main/java/net/glowstone/GlowWorld.java line 1687

Is the new Message[0] done on purpose? because before this was new Message[spawnMessage.size()]

jdonkervliet commented 4 years ago

In GitLab by @larsdetombe on Jun 17, 2020, 18:38

Was there a reason that the ChunkSpliterator and the ChunkIterator don't have a test class?

jdonkervliet commented 4 years ago

In GitLab by @swabbur on Jun 17, 2020, 18:59

Commented on src/main/java/net/glowstone/GlowWorld.java line 1677

The method was unused to begin with, but I know we had previously added it while working on the physics.

jdonkervliet commented 4 years ago

In GitLab by @swabbur on Jun 17, 2020, 19:02

Commented on src/main/java/net/glowstone/GlowWorld.java line 1687

Yes, passing an empty array to the toArray is a way to ensure that only one allocation happens (an array of size 0 doesn't allocate any heap memory, and the toArray will notice that the array size is too small and will therefore create his own array).

In this case, the original array would have been large enough, but doing it this way is more consistent with times where you aren't sure.

jdonkervliet commented 4 years ago

In GitLab by @swabbur on Jun 17, 2020, 19:03

Yes... I figured testing them would be a waste of time haha

I can still do so if you want me to, but I would prefer it to do it on a separate branch such that Julian can start experimenting.

jdonkervliet commented 4 years ago

In GitLab by @larsdetombe on Jun 17, 2020, 19:04

nah, was just curious tbh

jdonkervliet commented 4 years ago

In GitLab by @larsdetombe on Jun 17, 2020, 19:04

resolved all threads

jdonkervliet commented 4 years ago

In GitLab by @larsdetombe on Jun 17, 2020, 19:05

changed the description

jdonkervliet commented 4 years ago

In GitLab by @wubero on Jun 18, 2020, 12:03

merged

jdonkervliet commented 4 years ago

In GitLab by @wubero on Jun 18, 2020, 12:03

mentioned in commit 20c8373e6ae42666bbb8b7b9b3edb5e66713fdb3