-
Notifications
You must be signed in to change notification settings - Fork 238
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
Issues with caching (discussion) #61
Comments
Hi Oleg, I finally found the root cause! It's not the file's extension (only partly as I am just describing) and not the logic behind By the way, as you can see from the screenshots below, I am now able to step into CSScript source code :-) The only thing had to change was explicitly setting the .NET 2.0 runtime compiler: Here's the details: As described in #50 the exception happens here: The exception is caused by the mismatching versions of my host application's assembly (v1.10.6338.21060 -vs- .21479 = same version but different build stamp). I have then drilled down into the details of the source code and came to the conclusion that It is. As soon as I disable the altering of the assembly's file timestamp, all works fine! So the .NET runtime must get confused by the 'old' timestamp. If the timestamp of the resulting What was the reason for changing the timestamp? If I remember correctly, that change was done quite recently, and I later posted #32 requesting to keep the
PS1: CSScript actually stamps files with PS2: https://github.com/oleg-shilo/cs-script still refers to the outdated |
Great, at least we know what is triggering it. There are a few points in your post I need to reflect on.
I cannot be sure but it looks like it was the discrepancy between script and host assembly target runtime. And your
As a small work around (not to fix problem but to make it less frequent). You may want to avoid using auto-versioning (e.g.
The code fragment you are asking about was in the codebase for many many years :) The purpose of timestamping is caching. It's timestamp based so the equality of script and compiled script timestamps constitutes a valid cache. While a specific file timestamp may or may not affect .NET runtime caching (shadow copying), it certainly shouldn't. Changing the file timestamp has nothing to do with assembly probing. However there is no warranty that CLR may not have some undocummented feature that is compromised if a timestamp is changed. I don't feel right about changing CS-Script to just accommodate some undocumented/ununderstood CLR behavior. However having an optional alternative script compilation seems an adequate compromise. But before I proceed with the changes can you please check for me if commenting out pdb-related code brings the same benefit: if (scriptFile.Exists && asmFile.Exists)
{
asmFile.LastWriteTimeUtc = scriptFile.LastWriteTimeUtc;
//if (options.DBG && pdbFile.Exists)
// pdbFile.LastWriteTimeUtc = scriptFile.LastWriteTimeUtc;
} |
Commenting out Two things to consider:
Regarding the assembly versioning, I am somewhat cautious to drop the |
I expected that. Just wanted to check. Thxs. The conditional time stamping has already been implemented and will be delivered with the very next release (on this weekend): CSScript.GlobalSettings.SuppressTimestamping = true;`
This is not a problem at all as timestamped assemblies are cached scripts that are not to be accessed (or dealt with) by user but by CS-Script runtime only.
This is actually a very good work around idea. The reason why time is set as a file attribute is performance. Reading the attribute is much faster than reading the file content. Though I am not convinced that difference would make any practical effect. Will need to access the impact of the potential change on the codebase.
While this is a violation of semantic versioning it is still acceptable. What is not acceptable is the automatic increment of the last version segment on every build. It leads to the paradox when two assemblies are considered by CLR as different while being built from the same code. It may seem like a small thing but it's not. Imagine that you lost and need to rebuild an assembly in all its glory. You cannot. The version will be different even if you use the same code as for the original assembly. In .NET/VS at least it can be controlled but in WiX you have to go very deep to disable so called |
Thanks for the background info. Looking forward to integrating the upcoming release :-) I understand that a file time stamp is much more effective than having to read its content. Since the time stamp was used as an input parameter for the caching algorithm, will caching become less efficient or even be disabled with
I don't fully agree on that. I understand that this is the CS-Script's default behavior. But my hosting application actually compiles the assemblies to the very same path where the user's script is located, i.e. Reasons for this: Possibility to reuse the assembly (not only reuse the script).
|
- Added support for resolving NuGet packages from the `netstandard` lib subfolders - Added defaultRefAssemblies exchange in InitExecuteOptions() - .NET Core support (wip/RC) - Issue #61: Issues with caching; Sample: `CSScript.GlobalSettings.LegacyTimestampCahing = false;` (default is `false`) - Added support for `//css_ac_end` to allow Extension methods in classless scripts - Implemented caching for InMemory script assemblies - Fixed collapsing spaces in the DefaulrRefAssemblies settings value
- Added support for resolving NuGet packages from the `netstandard` lib subfolders - Added defaultRefAssemblies exchange in InitExecuteOptions() - .NET Core support (wip/RC) - Issue #61: Issues with caching; Sample: `CSScript.GlobalSettings.LegacyTimestampCahing = false;` (default is `false`) - Added support for `//css_ac_end` to allow Extension methods in classless scripts - Implemented caching for InMemory script assemblies - Fixed collapsing spaces in the DefaulrRefAssemblies settings value
Done: Release v3.25.3.0 |
Minor: |
Verified, works :-) Thanks once more! |
Txs. Fixed now. |
Cool. Txs for testing. |
Actually, |
Oh, yes, you are right. Txs. |
Migrated (Issue 1 topic) from broad discussion #50
Assembly stamping is done for preserving all script execution context inside of the assembly file. Thus if the script engine finds already compiled script it can compare the current execution context with the embedded one and make a decision if the script needs recompilation or the compiled script can be executed straightaway.
Conceptually execution context is very similar to the file timestamp. Though it covers more than a time of the compilation (e.g. dependency assemblies).
CS-Script only injects execution context info into
*.compiled
assemblies but never into dll/exe.The implementation can be found in
csscript.MetaDataItems.StampFile(file)
andcsscript.MetaDataItems.ReadFileStamp(file)
.The text was updated successfully, but these errors were encountered: