Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
5
Question by ArtemMakhno · Oct 26, 2021 at 11:36 AM · linuxc++nativelinux editor

[Linux] Bad PInvoke performance in the built application

Hi

We've written some wrappers around CGAL mesh boolean operations. It works perfectly in Windows, without any clues that something goes wrong.

There are some benchmarks (dotnet benchmark) connected to these wrappers. The main one checks union of two meshes in a single thread. The result using this tool is ok, from 8 to 9 seconds for an operation in Linux using the Embedded mono for 2021.1.26.f1.

Then we move demo meshes along with .cs wrapper code to the Unity3d application and create an empty scene with a single script object that unites meshes during the Start()

After pressing play, we measure the time it took to execute the method. 10 seconds. A bit more, but still ok. Switch scripts mode from Debug to Release. Wait a bit and play the same scene again. 8.5 seconds per operation. The same performance we've got in benchmarks.

Now, build the application using Mono backend and all default player settings. It's ready, the native .so library has been put to the Plugins directory and preloaded when the app is started.

When we run it, the single operation (there is nothing else in the app at all) of calling the native method takes not 8, but 100 seconds.

Approximately 10 times degradation. (the time is taken by the System.Diagnostic.Stopwatch)

 [DllImport("cgal_native", EntryPoint = "mesh_boolean")]
 private static extern MeshBooleanOut MeshBooleanNativeMethod(MeshBooleanParams parameters);

Both parameters MeshBooleanOut and MeshBooleanParams are simple structs and work just fine that is proved by benchmarks. These structures include simple fields int, double, int*, double*

The CLI is identical for the regular dotnet console app and built Assembly-CSharp.dll The LDD_DEBUG=libs shows the same path for libcgal_native.so dependencies. [SuppressUnmanagedCodeSecurity} is put to all methods, but I'm aware it's uselessness

What else can be a problem? What makes Unity3d work completely fine in Editor and so slow in the standalone application using the same scripting backend?

Thank you

OS: Ubuntu 20.04, reproduces in Ubuntu 18.04 and Ubuntu 21.11

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

137 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Need help compiling Unity Native Audio Plugins for Linux, got "multiple definition of" errors. 0 Answers

Unity build stand alone linux 0 Answers

How should I release a DirectX11 texture created in a native plugin? 1 Answer

Android Native Plugin (*.SO) 2 Answers

Equivalent of a void ** in from external library? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges