AdaptiveConsulting / Aeron.NET

Efficient reliable UDP unicast, UDP multicast, and IPC message transport - .NET port of Aeron
Apache License 2.0
484 stars 94 forks source link

Make Bounds Checking a Runtime Toggle #91

Closed JPWatson closed 5 years ago

JPWatson commented 5 years ago

Moved from https://github.com/real-logic/simple-binary-encoding/issues/492 (@juddgaddie)

Like Java, C# (unlike c/c++) is typically not compiled from sources for that reason I think the bounds checking would be better served with a runtime toggle we could use system environment variables (the same approach as c or c++ code uses for runtime configuration).

I also would think the default build that goes to Nuget should have bounds checking enabled by default.

Example of what I mean here: https://gist.github.com/juddgaddie/eeafbbb195a332bf72808748cdcd4336

JPWatson commented 5 years ago

@juddgaddie Yep I'm on board with that in theory, I just have two reservations.

  1. Would like to make sure there is no performance penalty (i.e. the JIT correctly optimises).
  2. The environment variables for configuration is less idiomatic in .NET (but I can't think of any alternatives).
juddgaddie commented 5 years ago

As an alternative to 2. we could move Adaptive.Aeron/Config.cs into Adaptive.Agrona and then use the -D command line args. This would be more consistent with both the Java implementation and the .NET aeron port.