Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[jit] Enable float32 by default. #1258

Open
wants to merge 822 commits into
base: unity-main
Choose a base branch
from

Conversation

Vincenz099
Copy link

@Vincenz099 Vincenz099 commented Feb 18, 2020

Dear unity team.

Currently many big projects including mine are based on mono, and we are unable to switch to ECS/DOTS at this time, yet we want more performance.

An easy source of a free lunch is that in mono all calculations that involve floats are actually done in doubles. this introduces a high performance cost, anything between 50 to 100% can be gained in float heavy situations by enabling mono to process floats as floats.
Here is an example of the hell this creates in your own math library:
public static float Dot(Vector3 lhs, Vector3 rhs) {return (float) ((double) lhs.x * (double) rhs.x + (double) lhs.y * (double) rhs.y + (double) lhs.z * (double) rhs.z);}

The mono project noticed this themselves in April of 2018 and made a series of commits to resolve this situation, read more about it here:
https://tirania.org/blog/archive/2018/Apr-11.html

I wish to propose to merge these changes to the unity fork of mono, they will improve performance for the products of all your clients that are currently shipping games or are planning to.

I would like to request you to merge these changes into the next itteration of 2018.4 LTS, because that is where I and many others are shipping their games from.

I made this pull request first of all for the basic change,
The source of these changes is:
mono#4731

If these things are to be accepted, I wish to make more pull requests that involve the following changes:
mono#7941

And importantly we should consider these changes, which solve any problems that might arise from this.
mono@b7db336

This actually solves bugs that are reported in unity for example:
https://issuetracker.unity3d.com/issues/doing-arithmetic-operations-in-mathf-dot-approximately-prevents-it-from-returning-a-correct-result

I am a unity pro customer and I'm sure many other Unity customers will benefit GREATLY from these changes, Please consider doing something about the situation that has arisen with you leaving mono in the dust for the last 2 years.

Yours,

Maxim.

jechter and others added 30 commits January 3, 2019 08:37
…d, so we can use barriers on both mono and il2cpp
…g sequence point until actually needed.

Brings use from ~20x slower to ~5x slower when debugger codegen is enabled vs no debugger codegen.
… per assembly table rather than in metadata binary file.

This is step towards per assembly conversion.
The Suspend debugger test was hanging intermittently on most platforms.
These seemed to occur because the codegen checks for
`g_Il2CppDebuggerCheckPointEnabled` were not getting the proper value,
and assuming the check point was not set, so the VM would not suspend.

This meant that the main thread could not be suspended when the debugger
was trying to exit, so the main thread kept looping forever, with out
allowing the debugger to exit it.
The Mono implementation of mono_runtime_try_shutdown does not actually
shut down the VM. Instead, it sets the flags to indicate the VM is
shutting down. The VM should actually shutdown in mono_runtime_quit.

In some cases, we see this code path taken when processing the
CMD_VM_EXIT command. This seems unlikely, but can happen when the code
above cannot find a suspended managed thread. If
mono_runtime_try_shutdown actually waits for managed threads to
complete, it will hang, as the main thread won't be suspended because
resume_vm is called just above mono_runtime_try_shutdown.

So for IL2CPP mono_runtime_try_shutdown doesn't do anything, but
mono_runtime_quit will actually shutdown the VM.
Since we run the Tiny profile on the libil2cpp backend, we don't need
any differences in this file.
* Ignoring the EventSets test because it tests exceptions.
* Fixing the vm.Exit() path that doesn't use System.Environment.Exit().
This reverts part of 78cc586d935f2009058602f2bd9adedca1442442, now that
`mono_runtime_try_shutdown` does not actually shut down, but instead
does nothing with IL2CPP.
The Mono implementation of mono_runtime_try_shutdown does not actually
shut down the VM. Instead, it sets the flags to indicate the VM is
shutting down. The VM should actually shutdown in mono_runtime_quit.

In some cases, we see this code path taken when processing the
CMD_VM_EXIT command. This seems unlikely, but can happen when the code
above cannot find a suspended managed thread. If
mono_runtime_try_shutdown actually waits for managed threads to
complete, it will hang, as the main thread won't be suspended because
resume_vm is called just above mono_runtime_try_shutdown.

So for IL2CPP mono_runtime_try_shutdown doesn't do anything, but
mono_runtime_quit will actually shutdown the VM.
Collect sequence points per assembly
Retrieve sequence point information per image
Write all debugger structures to a single file for each assembly
Write codegen and debugger structures as C code. This saves ~40% compile time on MSVC
Defines in the IL2CPP code should not be named for UNITY, as we want
IL2CPP to work independently. Clean up the names of the `UNITY_TINY`
defines then by renaming them.

This change should have no impact on runtime behavior or code size.
With IL2CPP, we don't have a good way to stop managed threads. So let's
just ignore that and exit the process.

This won't clean up and run finalizers, but the process it ending
anyway, so we don't care too much.
… macro invocation instead of looking up from index; hard code sequence point type into macro invocation
…port-status-to-github

Report CI status to Github
…ity-master-sync-il2cpp

Sync IL2CPP changes up to aebcd0f844270d5f407ec3d22f20a066d7028d36
joncham and others added 28 commits October 31, 2019 09:25
…ity-master-case-1194176

Avoid caching of System.dll image and types as they may be unloaded w…
…s in the background or the device is asleep."

This reverts commit d496518.
…ity-master-fix-libmono-dynamic-vcxproj

Fix vcxproj by removing non-existent file.
…ity-master-fix-1118285

Reintroduce fix for case 1118285.
…ity-master-case-1188987

Handle generic enums in custom attributes (case 1188987).
…ity-master-fix-1204409

Fix a regression introduced by e05343d
less native/managed transitions/copies & verification callback support
WIP: Fails various Unity Playmode TLs tests so far
Introduced by accident in last commit
Instead of cloning the mono-build-tools-extra and building the tools in
it, now get the binaries from Stevedore. These are only used on macOS
builds of Mono.
…itytls/custom-chain

Custom tls chain impl to fix callback issue and avoid copying
…no-build-tools-extra-stevedore

Obtain mono-build-tools-extra from Stevedore
…ead of jumping to the cleanup routine. This would leave init_list in a dirty state for subsequent calls leading to recursive type definitions being thrown incorrectly. (case 1191002)
…ity-master-fix-class-init-1191002

Fixes issue in mono_class_init where we would return immediately inst…
… is an enumerator. (mono#12368)

* [Debugger]  Debugger crashes when inside a class, there is an internal struct, with a field that is an enumerator.
files.myBucket.GetEnumerator().get_Current().Key
Fixes mono#10735

* [Debugger] Debugger crashes when there is a generic struct with a field that is an enumerator.
Example: files.get_Current().Key
A unit test that reproduces this crash was added too.
Fixes mono#10735

* Removing the extra space.

* UnityAlex cherry-pick modification: Removed tests
…x-debugger-crash-1210416

[Debugger] Fix crash when there is a generic struct with a field that…
This updates the mono-build-tools-extra repo to revision:

9de3c42ef81ec4f79b53e7db32d390227d8c43c4
…date-profile-stubber

Update the profile stubber to set HasThis on overrides (case 1210714)
…ity-master-fix-win32-exception-message-leak

Avoid using StringBuilder marshaling  Win32 (case 1211367).
Mono makes all float operations double operations, this costs a lot of performance.
This simple runtime flag solves this problem making all float operations a lot faster.
indent fix
@unity-cla-assistant
Copy link
Collaborator

unity-cla-assistant commented Feb 18, 2020

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
4 out of 8 committers have signed the CLA.

✅ AndreasReich
✅ ashwinimurt
✅ Vincenz099
✅ douglas-piconi
❌ lateralusX
❌ davidrogers-unity
❌ vargaz
❌ thaystg
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet