Author Topic: Fenton Webb's advice re "To dispose or not to dispose"  (Read 74672 times)

0 Members and 1 Guest are viewing this topic.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Fenton Webb's advice re "To dispose or not to dispose"
« Reply #60 on: August 08, 2012, 02:30:33 PM »
Thanks for the clarifiation Tony.
So, the 'good' way is as in the code I posted reply #21. :kewl:
Speaking English as a French Frog

fentonwebb

  • Guest
Re: Fenton Webb's advice re "To dispose or not to dispose"
« Reply #61 on: August 08, 2012, 02:44:27 PM »
Hey Gile

thanks for looking into that.

I personally consider that a bug... However, it looks like we can't address it really because 'fixing' it would risk logically affecting all that are using it (Disposing something that was not originally expected to be Disposed).

So anyway, back to my original point - call Dispose() on all objects that get created by you (what was I thinking advising otherwise) :-)

Hi ElpanovEvgeniy, I love your ideas, but the AutoCAD LISP Engine (an ObjectARX DLL) is laced with global variables and it's not thread safe.

Sorry guys, I have to get back to the ADNBlog - so if you have any further comments for me directly please add them to the relevant post there and I'll be glad to answer.

TheMaster

  • Guest
Re: Fenton Webb's advice re "To dispose or not to dispose"
« Reply #62 on: August 08, 2012, 02:51:29 PM »
My friend Alexander Rivilis said your name behind the nickname TT. I hasten to say, I really respect you for your contribution to programming. Indeed, the competition will be hot and fun!

ps. Yes, I will publish here all the sources. I hope you will too...

Thanks.

But, if your intention is to use AutoCAD Core Console as a form of parallel execution, I would not consider that to be a legitimate solution (that is technically multi-processing rather than multi-threading).

Since the LISP garbage collector is not capable of dealing with multiple threads, even if you did find some way to get an entry point on another thread, it would certainly fail given the appropriate stress-testing.


TheMaster

  • Guest
Re: Fenton Webb's advice re "To dispose or not to dispose"
« Reply #63 on: August 08, 2012, 03:03:57 PM »

Hey TT, What you say is totally true, but as I have mentioned before, AutoCAD is *not* thread safe, meaning that if you allow the GC to dispose of AutoCAD objects you run the risk of some AutoCAD code being executed on something otherthan the main thread, which it was never designed for - try it and see what happens - how many of you out there get random crashes happening that you cannot track down...? If you insist on allowing the GC to dispose your AutoCAD class objects, be sure to utilize my blog entry on gcConcurrent - that's my advice.


I think you misunderstood me  :wink:

We already know that managed wrappers whose finalizers execute code that's not thread safe, absolutely must be disposed of determinstically, or kaboom, so I wasn't referring to those cases, but rather the cases where Dispose() is unnecessary and/or pointless, the main one being database-resident DBObjects obtained from a transaction.  If you don't dispose them, their finalizers will run on the GC's thread, on another CPU core, and will have no impact on the performance of the code that uses those managed wrappers. 

I really don't agree with the advice regarding disabling concurrent garbage collection because that requires the application to wait for it to occur, and I seriously doubt you've investigated what kind of effect a GC can have during user-interactive operations like dragging, and so forth. Covering up a problem in way that impacts performance application-wide is not a professionally-responsible way of dealing with bugs (e.g., failure to Dispose() something).  If it is done only as a temporary stopgap measure, then fine, but otherwise, slowing down their application is not a legitimate solution.

Hey TT,

it happens 8-)

I agree with everything you say above.

In addition to your last paragraph, as I said in my blog, "Now, say you are at a customer site where they are experiencing random crashes with your app, or you are running behind schedule and just can’t seem to find the place where the random crash is happening then here’s a quick fix for you – try forcing the GC to run on the Main Thread…"

Again, my comments are not so much about whether your advice and comments are technically correct, but rather in how that advice and comments are presented and interpreted or misinterpreted. E.g. "quick fix" may be viewed as 'permanent' to some, especially if they don't understand or realize that it can have performance implications.

So while it is perfectly acceptable to disable concurrent GCs until the bugs are found and fixed, it should also be stressed that it is not acceptable as a permanent solution.

Communicating ideas, concepts, and skills in a way that is clear and well-understood by both experts and novices alike, is as much an art as writing the code that embodies the ideas, concepts and skills.

« Last Edit: August 09, 2012, 02:12:23 PM by TT »

Jeff H

  • Needs a day job
  • Posts: 6144
Re: Fenton Webb's advice re "To dispose or not to dispose"
« Reply #64 on: August 08, 2012, 03:24:07 PM »
If you were tasked for writing code to just run in the CoreConsole and knew it would never be used with acad.exe(I know does not make much sense) and normally would have a coreConsoles running for each core at the same time would that be good candidate for setting gcConcurrent flag and not worrying about disposing everything?
 
 

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Fenton Webb's advice re "To dispose or not to dispose"
« Reply #65 on: August 09, 2012, 01:56:59 AM »
My friend Alexander Rivilis said your name behind the nickname TT. I hasten to say, I really respect you for your contribution to programming. Indeed, the competition will be hot and fun!

ps. Yes, I will publish here all the sources. I hope you will too...

Thanks.

But, if your intention is to use AutoCAD Core Console as a form of parallel execution, I would not consider that to be a legitimate solution (that is technically multi-processing rather than multi-threading).

Since the LISP garbage collector is not capable of dealing with multiple threads, even if you did find some way to get an entry point on another thread, it would certainly fail given the appropriate stress-testing.

If you recall the story, the original lisp no one was interested, until the show concurrent execution in a network of computers. After that, two years later, was written specification language and the language was fully certified for any use, including defense.

You know Lisp. You should be clear that Lisp is the language of the lists. The meaning of the program - sequential passage through the list items and their computation. But in the lists may be other lists of data and programs. Each calculation can be performed at its core (thread or processor or computer).

Yes, I'm going to use the console AutoCAD.  :-)

The deal is really unfair?  :?

ps. To outperform existing codes on the arx. It should be very much to sweat...
You really do not want such an easy victory? Do you have a wide range of languages, I only lisp. Do you have a wide selection of tools for parallel computing, I have not.
The deal is really canceled?

TheMaster

  • Guest
Re: Fenton Webb's advice re "To dispose or not to dispose"
« Reply #66 on: August 09, 2012, 02:09:35 PM »

Yes, I'm going to use the console AutoCAD.  :-)


Well hey then, if that sort of solution is acceptable then why pussy-foot around? 

Why not just do it in the cloud ?  :lmao:

Sorry, no deal.

BlackBox

  • King Gator
  • Posts: 3770
Re: Fenton Webb's advice re "To dispose or not to dispose"
« Reply #67 on: August 09, 2012, 02:29:21 PM »

Sorry, no deal.

@TT -

Now that this challenge has been answered, I believe there is another challenge (or offer?) previously posed, that has gone unanswered  :? :

<snip>

So "TT" - how about you come to Autodesk University this year? We can do a special fun coding class - "Fenton Webb vs TT in AutoCAD .NET Coding Head to Head" - the audience chooses what we code, let's see who does the best job in the shortest time? Come on, it will be fun! I'm sure you will win

Pending any personal conflicts of course, would this be something you're willing to entertain?

... I'd very much be interested in the result of this sort of demonstration. Perhaps, if there's enough interest from other members, ADN would even step up, and fly you out?  :angel: Just saying.
"How we think determines what we do, and what we do determines what we get."

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: Fenton Webb's advice re "To dispose or not to dispose"
« Reply #68 on: August 09, 2012, 03:41:57 PM »

Yes, I'm going to use the console AutoCAD.  :-)


Well hey then, if that sort of solution is acceptable then why pussy-foot around? 

Why not just do it in the cloud ?  :lmao:

Sorry, no deal.

I'm lost, so this was going to be in native AutoLisp but just running in the command console instead of full blown AutoCAD?  Is he using multiple command consoles?  Wouldn't native code still be faster multithreading?
Revit 2019, AMEP 2019 64bit Win 10

TheMaster

  • Guest
Re: Fenton Webb's advice re "To dispose or not to dispose"
« Reply #69 on: August 09, 2012, 04:14:59 PM »

Yes, I'm going to use the console AutoCAD.  :-)


Well hey then, if that sort of solution is acceptable then why pussy-foot around? 

Why not just do it in the cloud ?  :lmao:

Sorry, no deal.

I'm lost, so this was going to be in native AutoLisp but just running in the command console instead of full blown AutoCAD?  Is he using multiple command consoles?  Wouldn't native code still be faster multithreading?

Yes, given comparable algorithms, native code is definitely faster, and may even be faster without parallelism.

Algorithms can be implemented in any language. In fact, most of the best algorithms were not implemented in LISP, and certainly not in AutoLISP, which lacks even the most-basic facilities like arrays. And, because most proven algorithms are developed using languages that do have things like arrays, hashtables, structs, and so on, they tend to be somewhat dependent on those languages.


TheMaster

  • Guest
Re: Fenton Webb's advice re "To dispose or not to dispose"
« Reply #70 on: August 09, 2012, 04:17:45 PM »

Sorry, no deal.

@TT -

Now that this challenge has been answered, I believe there is another challenge (or offer?) previously posed, that has gone unanswered  :? :

<snip>

So "TT" - how about you come to Autodesk University this year? We can do a special fun coding class - "Fenton Webb vs TT in AutoCAD .NET Coding Head to Head" - the audience chooses what we code, let's see who does the best job in the shortest time? Come on, it will be fun! I'm sure you will win

Pending any personal conflicts of course, would this be something you're willing to entertain?

... I'd very much be interested in the result of this sort of demonstration. Perhaps, if there's enough interest from other members, ADN would even step up, and fly you out?  :angel: Just saying.

Fenton has access to and is quite familiar with the AutoCAD and ObjectARX source code bases.

Maybe it's true that there's a sucker born every minute, but I ain't one of 'em :grin:


JohnK

  • Administrator
  • Seagull
  • Posts: 10603
Re: Fenton Webb's advice re "To dispose or not to dispose"
« Reply #71 on: August 09, 2012, 04:32:23 PM »
...
Sorry, no deal.
Se7en throws down his pop-corn and gets up to ask for a refund to the show. Damn!?

...
Maybe it's true that there's a sucker born every minute, but I ain't one of 'em :grin:
*lmao*  ...Fall off the turnip truck at least?
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

BlackBox

  • King Gator
  • Posts: 3770
Re: Fenton Webb's advice re "To dispose or not to dispose"
« Reply #72 on: August 09, 2012, 04:33:28 PM »

Sorry, no deal.

@TT -

Now that this challenge has been answered, I believe there is another challenge (or offer?) previously posed, that has gone unanswered  :? :

<snip>

So "TT" - how about you come to Autodesk University this year? We can do a special fun coding class - "Fenton Webb vs TT in AutoCAD .NET Coding Head to Head" - the audience chooses what we code, let's see who does the best job in the shortest time? Come on, it will be fun! I'm sure you will win

Pending any personal conflicts of course, would this be something you're willing to entertain?

... I'd very much be interested in the result of this sort of demonstration. Perhaps, if there's enough interest from other members, ADN would even step up, and fly you out?  :angel: Just saying.

Fenton has access to and is quite familiar with the AutoCAD and ObjectARX source code bases.

Maybe it's true that there's a sucker born every minute, but I ain't one of 'em :grin:

Well, I certainly was not suggesting that you were... Just thought it would make for an epic dual (with Tron Legacy music in the background).  :-)

Cheers, TT! :beer:
"How we think determines what we do, and what we do determines what we get."

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: Fenton Webb's advice re "To dispose or not to dispose"
« Reply #73 on: August 09, 2012, 05:04:49 PM »

Yes, I'm going to use the console AutoCAD.  :-)


Well hey then, if that sort of solution is acceptable then why pussy-foot around? 

Why not just do it in the cloud ?  :lmao:

Sorry, no deal.

I'm lost, so this was going to be in native AutoLisp but just running in the command console instead of full blown AutoCAD?  Is he using multiple command consoles?  Wouldn't native code still be faster multithreading?

Yes, given comparable algorithms, native code is definitely faster, and may even be faster without parallelism.

Algorithms can be implemented in any language. In fact, most of the best algorithms were not implemented in LISP, and certainly not in AutoLISP, which lacks even the most-basic facilities like arrays. And, because most proven algorithms are developed using languages that do have things like arrays, hashtables, structs, and so on, they tend to be somewhat dependent on those languages.

Thank goodness!  I thought that LISP had won and was gonna have to shoot myself in the head. :cry:
Revit 2019, AMEP 2019 64bit Win 10

TheMaster

  • Guest
Re: Fenton Webb's advice re "To dispose or not to dispose"
« Reply #74 on: August 09, 2012, 06:01:23 PM »
...
Sorry, no deal.
Se7en throws down his pop-corn and gets up to ask for a refund to the show. Damn!?

...
Maybe it's true that there's a sucker born every minute, but I ain't one of 'em :grin:
*lmao*  ...Fall off the turnip truck at least?

I refuse to entertain the sort of kludgery that the typical LISP die-hard is willing to resort to in order to justify their existence. :grin:

As far as Fenton goes, give me access to the same things he has access to and I'll clean his clock. :grin: