NoitaMP icon indicating copy to clipboard operation
NoitaMP copied to clipboard

If you do it quick'n'dirty, your code quality will suffer!

Open Ismoh opened this issue 1 year ago • 15 comments

Yoo, dependency hell led me to use lua globals. Guess what?! Performance sucks so much!

I try to do a quick test comparing performance and continue on reworling code, if performance increases.

My tasks

  • [ ] Draft task
  • [ ] update contributer file afterwards
  • [ ] https://github.com/octo-org/octo-repo/issues/45

Ismoh avatar Aug 17 '23 18:08 Ismoh

Create the branch based on #67

Ismoh avatar Aug 17 '23 18:08 Ismoh

LuaJIT profiler works!

It's findings: from frame 2060: 73% | local encodedBase64 = self.base64.encode(self.np.SerializeEntity(entityId))

but still as you guys mentioned: 67% | local exists = os.rename(absolutePath, absolutePath) and true or false it all the time above 60%

Ismoh avatar Oct 17 '23 23:10 Ismoh

Fix constructor dependency injection!

Worth testing passing dependencies as parameters on functions?

Best would be to have locals in init.lua and then passing those to classes, like: class:new() then class:requireDependencies(...) per class. When there is any foo is nil, then extend function above. Otherwise it will be p.i.t.a. maintaining it..

Ismoh avatar Oct 17 '23 23:10 Ismoh

~~Get rid of EntityCache?! It was used in the past for old serialization?!~~

Nope! It is also used to check, if an entity somehow changed and needs to be synced. But worth improving it. Gut feeling tells me, cache clean up, isn't 100% reliable.

Ismoh avatar Oct 30 '23 11:10 Ismoh

Debug setting for multiple instances to avoid unecessary resource/performance usage. Save pid in file. New settings file.

Edit: Double checked yesterday, looks fine for now!

Ismoh avatar Oct 30 '23 21:10 Ismoh

Chop of NULL byte from NoitaPatcher serialized binary string, when adding to VSC, like NoitaPatcherUtils:prepareForVSC(binaryString), which returns the modified string. Otherwise we cannot store it in VSC, but we need the NULL byte for Deserialization.

Ismoh avatar Nov 04 '23 11:11 Ismoh

Chop of NULL byte from NoitaPatcher serialized binary string, when adding to VSC, like NoitaPatcherUtils:prepareForVSC(binaryString), which returns the modified string. Otherwise we cannot store it in VSC, but we need the NULL byte for Deserialization.

I am not able to do this and won't do it. If there is any contributer interested in go for it, but it's waste of time. Base64_ffi is fast enough.

Ismoh avatar Nov 04 '23 18:11 Ismoh

Add toggle setting for pprint and pformat. It's executed each frame and is not necessary, when log level is off.

Ismoh avatar Nov 29 '23 23:11 Ismoh

Add checks before sending wrong network data. Some mandatory tables are nil now and then. Leads to wrong assumptions.

Ismoh avatar Nov 29 '23 23:11 Ismoh

If an entity was serialized and sent to anyone and then it got deserialized, it can happen, that the deserialized entity is the same as on the other peer. Sounds awesome? Yes and no. When Minä got synced, it's a huge problem.

Therefore double check when an entity was deserialized and a similiar one was found, whether nuids are matching, if not check the owner and guid are the same, if not create a new entity and do not reuse existing entities.

Ismoh avatar Nov 30 '23 08:11 Ismoh

Chop of NULL byte from NoitaPatcher serialized binary string, when adding to VSC, like NoitaPatcherUtils:prepareForVSC(binaryString), which returns the modified string. Otherwise we cannot store it in VSC, but we need the NULL byte for Deserialization.

I am not able to do this and won't do it. If there is any contributer interested in go for it, but it's waste of time. Base64_ffi is fast enough.

Maybe @aaptel can help me with this? We can have a discord call, when you are free!

Ismoh avatar Nov 30 '23 08:11 Ismoh

Wise double checking this? Assign package.loaded["Classname"] = nil when the class was loaded, to make it free for garbage collections.

Ismoh avatar Nov 30 '23 08:11 Ismoh

Chop of NULL byte from NoitaPatcher serialized binary string, when adding to VSC, like NoitaPatcherUtils:prepareForVSC(binaryString), which returns the modified string. Otherwise we cannot store it in VSC, but we need the NULL byte for Deserialization.

I am not able to do this and won't do it. If there is any contributer interested in go for it, but it's waste of time. Base64_ffi is fast enough.

Maybe @aaptel can help me with this? We can have a discord call, when you are free!

I'm missing a lot of context here. I don't see prepareForVSC in NoitaPatcherUtils.lua

aaptel avatar Nov 30 '23 16:11 aaptel

Use GitHub Copilot for generating unit tests. Is there a cli copilot version?

YES

Ismoh avatar Dec 05 '23 22:12 Ismoh

White- instead of blacklisting entities.

Ismoh avatar Dec 13 '23 23:12 Ismoh