CSharpTest.Net.Collections icon indicating copy to clipboard operation
CSharpTest.Net.Collections copied to clipboard

Make LurchTable work on Xamarin.iOS

Open ste8 opened this issue 4 years ago • 6 comments

We are trying to run Lucene.Net 4.8 on a Xamarin.iOS app, but it doesn't work due to the fact that it depends on LurchTable, that uses some instructions not fully supported by Xamarin.iOS compiler.

In particular, the compiler seems to have problems with the structs that implement generic interfaces, and within LurchTable there are several of them.

This problem has been discussed here https://github.com/mono/mono/issues/7016 It seems that the guys at Mono tried to support these instructions, but I think it didn't work and in one of the last comments they say "The LurchTable was quite a complex code that was not necessary for the particular use. In fact it used so complex generics that it managed to break Mono AOT in some cases".

In Lucene.Net, LurchTable was preferred to other LruCache implementations because their performance weren't good enough, so it make sense to continue to use LurchTable, but we'd like to find a way to make it work on Xamarin.iOS as well (Lucene.Net is trying to support also this platform).

We made a test, converting the generic structs inside LurchTable with classes: the test worked, but we don't know if this fix is right, regarding both performance and correctness.

Can you suggest the correct way to make LurchTable work in Xamarin.iOS as well?

PS: just to be clear, LurchTable works on Xamarin.iOS when the app is compiled for iOS simulator, but it doesn't work when is compiled for the devices, using the AOT compiler.

ste8 avatar Nov 04 '19 06:11 ste8

@ste8

Any chance you could share the changes you made that fixed the error from happening when using LurchTable on Xamarin.iOS?

NightOwl888 avatar Dec 11 '19 08:12 NightOwl888

We only modified the struct "AddInfo", converting it to a class, and it worked for us... but it was just a simple test.

ste8 avatar Dec 11 '19 11:12 ste8

Thanks. Just out of curiosity, does it work on Xamarin.iOS if you de-nest the AddInfo struct and change its definition to the following?

struct AddInfo<TKey, TValue> : ICreateOrUpdateValue<TKey, TValue>

If that test works, I think we have a way forward without sacrificing any performance.

NightOwl888 avatar Dec 12 '19 09:12 NightOwl888

Do note that I am working on getting Lucene.NET beta00007 out within the next few days. We'd like to include a fix for this, if possible. I have attempted to do the above test myself, but it is much more involved than I thought it would be to get Xamarin.iOS up and running on Azure DevOps.

NightOwl888 avatar Dec 16 '19 19:12 NightOwl888

Great. We have confirmation the above fix will work @ LUCENENET-602

@csharptest - Are you still around to maintain this project? If I submit a PR with the fix, will you release it on NuGet?

Also, we will need to add targets for

  • .NET Standard 1.x
  • .NET Standard 2.0

to be completely compatible with our project.

NightOwl888 avatar Dec 17 '19 15:12 NightOwl888

Ping.

@csharptest - Any chance we can update this library to work with .NET Standard/Xamarin.iOS so we can remove LurchTable from our codebase?

There already is a clone here that upgraded the project to .NET Standard, but we would prefer to utilize the original library as a dependency, if possible.

It also doesn't look like you have strong named the assembly, which we will also need.

If you don't want to maintain the library anymore, could you please at least agree to give me permission to update the package on NuGet.org so I can maintain it from a fork?

NightOwl888 avatar Jan 23 '20 14:01 NightOwl888