Oren Eini

CEO of RavenDB

a NoSQL Open Source Document Database

Get in touch with me:

oren@ravendb.net +972 52-548-6969

Posts: 7,524
|
Comments: 51,158
Privacy Policy · Terms
filter by tags archive

I Yield, I Yield

time to read 1 min | 189 words

I am going over the ParallelFX code at the moment, and I run into this interesting method.

Platform.Yield(), which turn out to be a call to SwitchToThread(), which is a method I really should have known about. Turn out that this is a way to explicitly give up the current time-slice that the thread is executing (for the current CPU only).

This lead me to do some more discovery, and I found this, managed fibers implementations (I can't find the source for this, however, and I have the SDK). This is all part of my quest to get Erlang-like support for concurrency. By that I mean that I can do things like:

public void Process()
{
   var dbFuture = Spawn( AquireDataFromDB );
   var wsFuture = Spawn( AquureDataFromWS );

   YieldUntil(dbFuture, wsFuture);

   // do real processing here.
}

The key point is that the call to YieldUntil does not block the current thread, instead, it frees it to do start executing additional processing.

We can keep abusing the yield return approach, but that is starting to get old.

time to read 1 min | 186 words

This is an integration story. Once upon a time there was the need to integrate between two systems. A meeting (blah!) was scheduled and it was decided that web services are an appropriate integration technology. Fast forward some time, and now you get a strange situation where the other side has found that they are unable to use web services because of technical limitations in Java.

Sound suspicious to me, but whatever. How do you suppose we will integrate, then? Well, they know how to talk to a database...

So, they can't figure out web services but you want to talk to my database? I don't think so.

But you can add security and stored procedures and then they would not be able to do any harm.

So, because they are incompetent, I need to start managing security in the database layer? I don't think so.

create database Application_Integration;

Here is the user/pass, enjoy.

Abstraction is for more than just code.

Now I wonder how long it would take them to complain that I don't do any work because I have a single table in the database.

time to read 2 min | 268 words

Imagine this fictitious scenario, you are working on some functionality, and you are pretty pleased with what you have so far. Then, a new requirement come in, and it require something that is plain out not possible with the approach that you have taken so far. Then you start to investigate it a little further, and you find that if you do this, and push that, and maybe not look too closely at the end result, you can get what you want, without major changes to your code.

I have done this. I have done things to the GridView that should make it weep in shame, and there is a reason why I know the System.Web.UI.Calendar.Render() has a special case for Hebrew calendar and Cyclomatic Complexity of 42.

The problem with these types of solutions is that they are a Hack. As such, they may serve an immediate need, but they will prevent me from continuing to evolve the software in any meaningful way. This is getting into technical debt in a serious manner. I finally drew a line in the sand when I found out that I would need to do multi threading in javascript, and I actually had an idea about how to make it work (don't ask!).

Next time, I believe that I will draw that line much sooner. Better to cut my loses and build the functionality again than having to deal with the complexities of an inappropriate technical solutions and hacks on top of it.

 

time to read 1 min | 157 words

Here is an idea for a kick-ass Reflector plugin. We already have Reflector plugins for outputting entire projects out, but what I would really like to see is a plugin that takes it one (big) step further and generate the PDB as well.

A PDB file allows Visual Studio to debug, it contains the correlation between the compiled code and the source code, enabling stepping into the code. The important idea here is that Reflector is capable of producing botht he source code and the PDB, which would allow us to debug into assemblies that we don't have the source to.

The big benefit of generating the source and compiling ourselves is that we don't need to do it for the whole chain. The immediate use of this would be to finally see what black magic is making the view state put values in completely random places.

time to read 6 min | 1054 words

It turns out that you can do that quite easily with .Net:

static void Main(string[] args)

{

      Assembly executingAssembly = Assembly.GetExecutingAssembly();

      foreach (string manifestResourceName in executingAssembly.GetManifestResourceNames())

      {

            Console.WriteLine("File {0}:", manifestResourceName);

            if(Path.GetExtension(manifestResourceName)==".cs")

            {

                  Stream stream = executingAssembly.GetManifestResourceStream(manifestResourceName);

                  Console.Write(new StreamReader(stream).ReadToEnd());

            }

      }

}

This little magic is possible when you add this to the very buttom of your csproj:

<ItemGroup>

      <EmbeddedResource Include="@(Compile)" />

</ItemGroup>

Now I just need to figure out how to reference the currectly executing msbuild project and I would have the entire project in the binaries. Sadly, I understand that this is something that is required at times. (Usually deperatedly so :-) ).

I wonder if I can somehow make it a part of machine.msbuild, or something like that?

Give a new meaning to "ships with source code" :-)

FUTURE POSTS

No future posts left, oh my!

RECENT SERIES

  1. Challenge (75):
    01 Jul 2024 - Efficient snapshotable state
  2. Recording (14):
    19 Jun 2024 - Building a Database Engine in C# & .NET
  3. re (33):
    28 May 2024 - Secure Drop protocol
  4. Meta Blog (2):
    23 Jan 2024 - I'm a JS Developer now
  5. Production Postmortem (51):
    12 Dec 2023 - The Spawn of Denial of Service
View all series

Syndication

Main feed Feed Stats
Comments feed   Comments Feed Stats
}