-
Notifications
You must be signed in to change notification settings - Fork 150
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
Support HostItemFlags.DirectAccess for .NET objects #161
Comments
Hi @Nir1812, The script control limits itself to COM, whereas ClearScript concerns itself with .NET, whose type system is significantly richer (e.g., it supports statics, generics, constructors, extension methods, etc.).
For Windows script engines (JScript and VBScript), ClearScript supports This feature is currently restricted to COM objects, but we've just confirmed that it also works for any .NET object as long as it's Thanks! |
Thank you for the answer. |
Hi @Nir1812,
In the meantime, if you're building ClearScript yourself (we've noticed your fork), you can simply remove the Good luck! |
Thank you for the direction. |
…Hub Issue #160); fixed 64-bit V8 initialization on Azure App Service (GitHub Issue #166); enabled DirectAccess for ComVisible .NET objects (GitHub Issue #161); added ScriptEngine.ExposeHostObjectStaticMembers (GitHub Issue #152); added ScriptEngine.UndefinedImportValue and made Undefined.Value public (GitHub Issue #154); enhanced ExtendedHostFunctions.typeLibEnums to pull in external enumerations; added thread affinity enforcement in WindowsScriptEngine.Dispose; eliminated KeyNotFoundException when checking for system documents (GitHub Issue #169); enabled the use of the application's root folder as a backup for its local data folder (GitHub Issue #171); reduced minimum CPU profile and heap size sampling intervals to 125 ms; updated deployment and API documentation, resolving GitHub Issues #158 and #159. Tested with V8 8.1.307.28.
Version 6.0.1 expands |
I'm having a slow issue as well (using the V8 engine with ClearScript version 7.1.5). It seems like the speed is also related to the number of properties/methods on the .net object. I set up the same readonly property on two objects, one had just 1 property and the other one is a giant library we use with ... 50,000 properties and methods? (it's a rather large library)... The library with just one property can run about 10,000 marshals per second, where the giant library could only run about 1,000 marshals per second, given the same property. I could not find much of a difference in speed with the DirectAccess flag enabled or not. Both .NET classes have the ComVisible(true) attribute. Something is definitely amiss here. Any suggestions? |
Hi @Brain2000, Sorry, just trying to make sure we understand, you’re adding this property to an object that has 50,000 others? Thanks! |
I believe I have narrowed it down to the class size, though perhaps it could be something else. Here is the test in more detail: The two classes:
The setup:
The output:
Note that the big class took around 7 seconds and the tiny class took around 1 second, to retrieve the speedtest property 20,000 times. |
Running the CPU diagnostics against the process yielded this as the function taking all the time:
|
It looks like it is using reflection to retrieve all members, and then enumerates through them all using the Linq "FirstOrDefault" to find the property (i.e. in this file: https://github.com/microsoft/ClearScript/blob/041b5b4ca5395c5ba63ef7a4f3215d433074e941/ClearScript/Util/COM/DispatchWrappers.cs) What do you think of putting all the members into a dictionary? Perhaps something like this in DispatchWrapers.cs:
|
Hi @Brain2000. We've confirmed the slowdown and are tracking it as Issue #281. ClearScript supports scenarios that necessitate enumerating the entire property set, but we believe it should be possible to optimize that away for simple cases that don't involve indexed or renamed properties. In the meantime, consider exposing a wrapper that provides access to a subset of the main object's properties. To be honest, we've never tested with a type that comes anywhere near 50,000 properties. Our first attempt to reproduce your issue failed, as no current .NET runtime seems to support 50,000 get-set properties. We got it working by converting the properties to get-only. By the way, Thanks for reporting this issue! |
Thank you! I will check Issue #281. Also, you are correct. This is a large foundation class that our dev department has been adding to for the last 15 years. I thought it had closer to 50,000 properties/methods, but after double checking the class itself has less than 10,000. The rest are in subclasses, which I should not have been counting. |
I have spent 3 days converting my application to successfully use ClearScript instead of the old MSScriptControl (which is limited to 32 bit).
Unfortunately, after sending my application to the QA team, I have found out that the ClearScript engine is MUCH slower than the MSScriptControl!
Take a look at the profiler output, which shows the amount of CPU it takes for all the reflection calls.
Is there any way to bypass these checks?
And for comparison: Same application, same script but using MSScriptControl:
The script code that runs on both engines use a while loop over a recordset with 3000 records, and calls a method in a host object for each record.
The text was updated successfully, but these errors were encountered: