surieux
  •  surieux
  • 78.8% (Friendly)
  • YAF Lover Topic Starter
2009-11-03T04:34:21Z
Hello,

After some days of intensive work I have YAF 1.9.4 integrated in my portal at 90%.
And my constatation is that amongst the large part of good ideas and features some dev choices seem to slow down YAF in 1.9.4 and limit its portability.

I have to struggle with a pratice spread amongst code: reflexion.
This is slowing down code and limiting choice of integration to the Web Site model.

Unfortunately I was needing a Web Applcation model and when I converted code, lot of internal process stop working because they were build on the assertion that assemblies where generated on the fly.
For exemple I loosed the list of html editors because it was implemented using reflexion with code like this

		YafEditorModuleManager()
			: base("YAF.Editors", "YAF.Editors.IBaseEditorModule")
		{
			if ( ModuleClassTypes == null )
			{
			       // re-add these modules...
		               base.AddModules( BuildManager.CodeAssemblies);
		           }
		}


BuildManager is very slow and no more gives the correct assemblies when App_Code has diseappeared.
Here, it would have been better to simply have a static list with editors modules present in the code.
Reflexion is a beautifull and 'sexy' concept bring out by .net, but very very slow and for Web App it is clearly not a choice.
Activator.CreateInstance should be reserved for special conditions, when you can't have a select with a new for each different case.
I must add that without documentation, the YAF code is especially uneasy to read due to this practice.

Second point the Ajax/JQuery features.
My portal code uses Microsoft Ajax and the main page is automatically loading JQuery, it seems that when I load YAF as a control in my module, it load again JQuery, eventually with a different version (I will check this).
Pages take some 10 seconds to load in totallity from a local server, one user, one topic, one forum... and I have often javascript errors detected by IE8 (and I don't speak of IE6....), I have not tested with FireFox or Chrome.

In YAF, JQuery is bring by DNA libraries, their controls seem good but will they be enough portable and extensible to support current evolutions of .Net versus JQuery. I don't think.
I admit the problem is not simple fo an open source software.
To limit problem, there should be some way to say : 'Hey the JQuery is already loaded by Ajax.net, don't send it again to page and uses the already loaded version'

Last Point: using YAF under another Portal
This is done by a direct code hard modifications, just as in this method

		static public IUrlBuilder UrlBuilder
		{
			get
			{
				if ( HttpContext.Current.Application[UrlBuilderKeyName] == null )
				{
					string urlAssembly;

					if ( IsRainbow )
					{
						urlAssembly = "yaf_rainbow.RainbowUrlBuilder,yaf_rainbow";
					}
					else if ( IsDotNetNuke )
					{
						urlAssembly = "YAF.Classes.DotNetNukeUrlBuilder,YAF.Classes.Utils";
					}
					else if ( IsMojoPortal )
					{
						urlAssembly = "yaf_mojo.MojoPortalUrlBuilder,yaf_mojo";
					}
					else if ( IsPortal )
					{
						urlAssembly = "Portal.UrlBuilder,Portal";
					}
					else if ( IsPortalomatic )
					{
						urlAssembly = "Portalomatic.NET.Utils.URLBuilder,Portalomatic.NET.Utils";
					}
					else if ( EnableURLRewriting )
					{
						urlAssembly = "YAF.Classes.RewriteUrlBuilder,YAF.Classes.Utils";
					}
					else
					{
						urlAssembly = "YAF.Classes.UrlBuilder";
					}

					HttpContext.Current.Application[UrlBuilderKeyName] = Activator.CreateInstance( Type.GetType( urlAssembly ) );
				}

				return (IUrlBuilder)HttpContext.Current.Application[UrlBuilderKeyName];
			}
		}
	}

or this one
		protected static string TreatPathStr( string altRoot )
		{
			string _path = string.Empty;

			try
			{
				_path = HttpContext.Current.Request.ApplicationPath;

				if ( !_path.EndsWith( "/" ) ) _path += "/";

				if ( !String.IsNullOrEmpty( altRoot ) )
				{
					// use specified root
					_path = altRoot;

					if ( _path.StartsWith( "~" ) )
					{
						// transform with application path...
						_path = _path.Replace( "~", HttpContext.Current.Request.ApplicationPath );
					}

					if ( _path[0] != '/' ) _path = _path.Insert( 0, "/" );
				}
				else if ( Config.IsDotNetNuke )
				{
					_path += "DesktopModules/YetAnotherForumDotNet/";
				}
				else if ( Config.IsRainbow )
				{
					_path += "DesktopModules/Forum/";
				}
				else if ( Config.IsPortal )
				{
					_path += "Modules/Forum/";
				}

				if ( !_path.EndsWith( "/" ) ) _path += "/";

				// remove redundant slashes...
				while ( _path.Contains( "//" ) )
				{
					_path = _path.Replace( "//", "/" );
				}
			}
			catch ( Exception )
			{
				_path = "/";
			}

			return _path;			
		}



This could be easily remplaced by a general HostingPortal Provider that we could parameter from Web.config rather than doing direct code change always prone to errors and portability.


I think that decision should be taken to change actual orientation in 1.9.4 for these 3 points.
These concerns are only a small part of YAF code which remain a solid foundation for a Forum tool.

Thanks for attention.


CS
Sponsor
Mek
  •  Mek
  • 100% (Exalted)
  • YAF Developer
2009-11-03T08:01:42Z
1) /shrug not played around with the BuildAssemblies, will discuss with Jaben.
2) Bit of a pain, because a) Jquery version differences, b) Determining where the portal has loaded JQuery (ScriptManager, RegisterClientScript, MasterPage).
3) Fully agree with you and have discussed this already with Jaben, its a prime example for a provider.


Thanks for the constructive feedback.

UserPostedImage 

"It's a case of RTFM.. the only problem being we don't have a manual!"

When I post FP:Mek in a topic, I'm leaving my footprint there so I can track it once I get into coding/supporting. (Yes I stole this off Ederon 🙂 )
surieux
  •  surieux
  • 78.8% (Friendly)
  • YAF Lover Topic Starter
2009-11-03T09:10:05Z
Thank you for answering,

As I am not born speaking english, could you detail point 1 ?

For JQuery, I agree with you.
As I am using Telerik, I have also posted the same question on their side.
Here is the code needed by Telerik:

<telerik:RadScriptManager ID="ADNScriptManager" Runat="server" EnableScriptGlobalization="true" EnableScriptLocalization="true"  EnableTheming="True">
<Scripts>
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
</Scripts>
</telerik:RadScriptManager>


I am not a JQuery expert but may be there is a way to avoid double loading.
( I just noticed that JQury is under MIT and GPL license ??? )

For 3 I could help.

Best regards

CS

surieux
  •  surieux
  • 78.8% (Friendly)
  • YAF Lover Topic Starter
2009-11-03T09:33:50Z
More on the JQuery question, I found this code in 1.9.4
		public void RegisterJQuery( Control element )
		{
			if (!PageElementExists("jquery"))
			{
				bool registerJQuery = true;

				string key = "JQuery-Javascripts";
				// check to see if DotNetAge is around and has registered jQuery for us...
				if ( HttpContext.Current.Items🔑 != null )
				{
					var collection = (HttpContext.Current.Items🔑 as System.Collections.Specialized.StringCollection);

					if ( collection != null && collection.Contains( "jquery" ) )
					{
						registerJQuery = false;
					}
				}
				else if ( Config.IsDotNetNuke )
				{
					// latest version of DNN (v5) should register jQuery for us...
					registerJQuery = false;
				}

				// load jQuery from google...
				//const string jQueryLoad = "<script type=\"text/javascript\" src=\"\"></script>";
				if ( registerJQuery )
				{
					element.Controls.Add(
						ControlHelper.MakeJsIncludeControl( "http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" ) );
				}

				AddPageElement( "jquery" );
			}
		}


I suggest as a temporary solution o have a web.config switch ShouldRegisterJQuery.

May be implementing a Hosting Provider as I suggested could take care of asking the HostingProvider if it has loaded JQuery....


Regards
CS
Jaben
  •  Jaben
  • 100% (Exalted)
  • YAF Developer
2009-11-06T17:15:46Z
jQuery is MIT and GPL -- so is DotNetAge.

The only major issue is #1 -- the other things could be fixed with an hour or two of coding.

But, I disagree with you on the "speed" issues with the reflection. The reflection is done once per application load. That is hardly a massive performance problem and provides huge benefits. Admittedly, the build assemblies issues is there, and I plan a fix.

If you make a hosting provider, that would be excellent. I'm sure the YAF project would benefit.
surieux
  •  surieux
  • 78.8% (Friendly)
  • YAF Lover Topic Starter
2009-11-08T05:16:43Z
Ok,

I will have less time for YAF until 15th.
If I realize something I will send it.

Regards
CS
cct
  •  cct
  • 58.4% (Neutral)
  • YAF Forumling
2009-11-15T01:47:32Z
I have run into the same issue as #1.
Is there a quick work around to this perhaps?

Edit: Seems to work when I manually added the App_Code directory with just the editors folder and classes.
surieux
  •  surieux
  • 78.8% (Friendly)
  • YAF Lover Topic Starter
2009-11-15T03:56:43Z
Hello cct,
I have done a quick and dirty modification of code to have it working but it can't be accepted as a solution.

		YafEditorModuleManager()
			: base("YAF.Editors", "YAF.Editors.IBaseEditorModule")
		{
			if ( ModuleClassTypes == null )
			{
                System.Reflection.Assembly[] asmb   =   AppDomain.CurrentDomain.GetAssemblies();
                Trace.WriteLine(string.Format("YafEditorModuleManager Ctor asm null: {0}",asmb == null ));
                if ( asmb != null )
                {
                    List<System.Reflection.Assembly> lst    =   new List<System.Reflection.Assembly>();
                    foreach ( System.Reflection.Assembly ass in asmb )
                    {
                        if ( ass.FullName.ToLower().StartsWith("yaf,") )
                        {
                            Trace.WriteLine(string.Format("YafEditorModuleManager Ctor assembly: {0}",ass.FullName));
                            lst.Add(ass);
                        }
                    }
                    if ( lst.Count > 0 )
                        base.AddModules(lst);
I nammed YAF the assembly generated by the main YAF project and parsed this assembly for correct types....
Playing with reflection is not a good practice, the best should be coming back to something easier to maintain with static values, because finally, reflection rely also on static values as it reads into some assemblies the types it need. Should be easier to put this in a string array or an enum....
This practice ranks down yaf.
Hope this change will be done in next versions, coming back to a more efficient code in term of maintenance and speed.


CS
Jaben
  •  Jaben
  • 100% (Exalted)
  • YAF Developer
2009-11-16T02:00:34Z
surieux wrote:

Hello cct,
I have done a quick and dirty modification of code to have it working but it can't be accepted as a solution.

Quote:


YafEditorModuleManager()
: base("YAF.Editors", "YAF.Editors.IBaseEditorModule")
{
if ( ModuleClassTypes == null )
{
System.Reflection.Assembly[] asmb = AppDomain.CurrentDomain.GetAssemblies();
Trace.WriteLine(string.Format("YafEditorModuleManager Ctor asm null: {0}",asmb == null ));
if ( asmb != null )
{
List<System.Reflection.Assembly> lst = new List<System.Reflection.Assembly>();
foreach ( System.Reflection.Assembly ass in asmb )
{
if ( ass.FullName.ToLower().StartsWith("yaf,") )
{
Trace.WriteLine(string.Format("YafEditorModuleManager Ctor assembly: {0}",ass.FullName));
lst.Add(ass);
}
}
if ( lst.Count > 0 )
base.AddModules(lst);


I nammed YAF the assembly generated by the main YAF project and parsed this assembly for correct types....
Playing with reflection is not a good practice, the best should be coming back to something easier to maintain with static values, because finally, reflection rely also on static values as it reads into some assemblies the types it need. Should be easier to put this in a string array or an enum....
This practice ranks down yaf.
Hope this change will be done in next versions, coming back to a more efficient code in term of maintenance and speed.

CS


Glad you found a solution to your specific needs. I don't see that other users have similar needs at this time (no one else has complained about speed issues with reflection). But, I appreciate your feedback and your thoughts will be noted for future revisions.

Please note that any changes to YAF are licensed under GPL. And since YAF is GPL v2, that includes ANY plugins or modules as well.
surieux
  •  surieux
  • 78.8% (Friendly)
  • YAF Lover Topic Starter
2009-11-16T02:53:23Z
Hello Jaben,

Quote:

Glad you found a solution to your specific needs. I don't see that other users have similar needs at this time (no one else has complained about speed issues with reflection). But, I appreciate your feedback and your thoughts will be noted for future revisions.


I was only answering to cct. I agree that on my side, I was just testing YAF and speed was not on my roadmap, I just indicated my personnal though from experiences on heavy loaded asp.net process were a frequent 'high level' reflection function taking 3 to 5 time the time for a direct call was too costly.

I have seen many people having the same request as me: having YAF provided as a Web Application.
And for this, the code I have tested for 1.9.4 doesn't works due to some code placed in App_Code rather than in a satellite assembly, so I had to do a quick fix to have the Web Application working.
Ideally suppressing reflection here could provide also with same code and better portability between Web Site and Web Application.
As I said I was just indicating to cct a temporary solution to this problem.
What do you mean by
Quote:

Please note that any changes to YAF are licensed under GPL. And since YAF is GPL v2, that includes ANY plugins or modules as well.


??

We had a clear private talk about this ?

Best regards

CS
Jaben
  •  Jaben
  • 100% (Exalted)
  • YAF Developer
2009-11-16T13:19:21Z
surieux wrote:


We had a clear private talk about this ?

Best regards

CS


We discussed interest in other licensing for YAF. But our talks ended there. YAF is GPL v2 only.

As it stands: If you decide to distribute the modified YAF project: you need to provide a link to download the modified source for your customers and the YAF community.
Jaben
  •  Jaben
  • 100% (Exalted)
  • YAF Developer
2009-11-16T13:51:13Z
surieux wrote:

I was only answering to cct. I agree that on my side, I was just testing YAF and speed was not on my roadmap, I just indicated my personnal though from experiences on heavy loaded asp.net process were a frequent 'high level' reflection function taking 3 to 5 time the time for a direct call was too costly.


I completely disagree with your view on this topic.

You'd have to produce performance data (how long does it take with and without) to prove that it's worth even a millisecond of my time.

We're talking about incredibly fast operations done VERY few times. If it were calling CreateInstance MILLIONS of TIMES, it might be something to focus on. As it stands, it's being called less then 30 times per page load. And it's only slow compared to calling direct new Object(); But new Object is VERY, VERY fast.

http://aspnetresources.c...insstantiation_perf.aspx 

But he is testing on 1 million object creation.

Anyway, I don't see how your argument holds much water. But you are welcome to prove me wrong by showing me that the app would be much faster without that code.
surieux
  •  surieux
  • 78.8% (Friendly)
  • YAF Lover Topic Starter
2009-11-16T16:45:07Z
Hello Jaben,

Let me apology if I have offended any technical and justified pride you could have about YAF's code.
This was not my intention.

Quote:


We discussed interest in other licensing for YAF. But our talks ended there. YAF is GPL v2 only.
As it stands: If you decide to distribute the modified YAF project: you need to provide a link to download the modified source for your customers and the YAF community.



As I have said we don't want to distribute something now.
I will have another test with a more mature version 1.9.4 than the one I have been using. But later.
I simply regret that we couldn't have a same code for 2 models of building : Web Site and Web Application.

Quote:

I completely disagree with your view on this topic.
You'd have to produce performance data (how long does it take with and without) to prove that it's worth even a millisecond of my time.


To build performance data and compare, I would need a version of YAF without all ... the reflection staff.

On our side, in our product, we have 2 versions of the same method: one using activator and one using a select/case and there are no comparisons.

But, again, I don't want to introduce some misunderstanding here, speed is not the main grief against reflection, my problem has been with Web Application not working due to constraints introduced by reflection, and the fact that code is very unclear when reflection is associated with the no-doc option.

I am quite sure that for the majority of situations YAF behaves correctly.

http://aspnetresources.c...nsstantiation_perf.aspx 


No I was not knowing about this, only my own experience on real projects.

I don't totally understand the 'boogie man' expression, certainly a funny one :)


Best regards
CS

bbobb
  •  bbobb
  • 100% (Exalted)
  • YAF Developer
2009-11-16T17:49:30Z

WebApplication allows to adapt it for Mono.
The Mono project never implemented the Web Site model in MonoDevelop as useless and causing problems.

MS practically threw away web site model when they had began there MVC project. They
added Web Application project type to Visual Web Developer Express Edition 2008 SP1.

Impossible to create `real` MojoPortal module as the modules are WebApplications. In 1.9.8.1 it was easy to integrate it.
surieux
  •  surieux
  • 78.8% (Friendly)
  • YAF Lover Topic Starter
2009-11-17T02:25:53Z
YAF team has to receive evidences like yours to accept this so small move.
Only actual problems are the placement of some classes in App_Code where they could reside in some assemblies like Classes.xxx.fll and the way reflection is used.
Concerning Mono, do you know if Telerik RadControls for Ajax.net works with it ?

Regards
CS

About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button

Project Twitter Updates

Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved