|
I have seen a similar quote attributed to Thomas Jefferson. I think it is less about government per se, but more about the scale of government.
|
|
|
|
|
+1 for this suggestion. Performance is much, much better than using the managed classes for memory mapped files. (I remember we clocked this being around 5x faster). We used this approach to store multimedia fingerprint data.
Here is a small snippet of code showing how we initialized the memory mapped file using C++/CLI - The data is accessible through the _pData (UInt32*) member.
Int32 StationHashStorage::Open() {
msclr::lock lock(_syncRoot);
if( _isOpen )
return 0;
String^ fileName = GetFullFileName();
_szInBytes = ComputeFileSizeInBytes(fileName);
String^ mapExtension = GetFileExtension();
String^ mapName = String::Format("{0}{1}_{2}", _stationId, _date.ToString("yyyyMMdd"), mapExtension);
marshal_context context;
LPCTSTR pMapName = context.marshal_as<const TCHAR*>(mapName);
{
msclr::lock lock( _openLock );
_hMapping = OpenFileMapping(FILE_MAP_READ | FILE_MAP_WRITE, FALSE, pMapName);
if( !_hMapping ) {
LPCTSTR pFileName = context.marshal_as<const TCHAR*>(fileName);
_hFile = CreateFile(pFileName,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
if( !_hFile )
throw gcnew IOException(String::Format(Strings::CreateFileFailed, GetLastError(), _stationId));
_hMapping = CreateFileMapping(_hFile,
NULL,
PAGE_READWRITE | SEC_COMMIT,
0,
_szInBytes,
pMapName);
if( !_hMapping )
throw gcnew IOException(String::Format(Strings::CreateMappingFailed, GetLastError(), _stationId));
_usingSharedFile = false;
} else {
_usingSharedFile = true;
}
}
_pData = (UInt32*)::MapViewOfFile(_hMapping, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
if( !_pData )
throw gcnew IOException(String::Format(Strings::MapViewOfFileFailed, ::GetLastError(), _stationId));
Int32 dummy = 0;
for( int i = 0; i < _szInBytes / sizeof(Int32); i+= 1024 ) {
dummy ^= _pData[i];
}
_isOpen = true;
return 0;
}
void StationHashStorage::Cleanup() {
if( !_disposed ) {
if( _pData ) {
if( !UnmapViewOfFile(_pData) )
LOG_ERROR(Strings::UnmapViewOfFileFailed, ::GetLastError(), _stationId);
_pData = NULL;
}
if( _hMapping ) {
if( !CloseHandle(_hMapping) )
LOG_ERROR(Strings::CloseMappingFailed, ::GetLastError(), _stationId);
_hMapping = NULL;
}
if( _hFile ) {
if( !CloseHandle(_hFile) )
LOG_ERROR(Strings::CloseFileFailed, ::GetLastError(), _stationId);
_hFile = NULL;
}
_disposed = true;
}
}
modified 19-Sep-19 12:37pm.
|
|
|
|
|
So write an unmanaged assembly with C++ to do the heavy b-tree lifting...
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
There's already a ton of B+ trees in C++
I was going for a managed code version that would run on any .NET capable platform.
I have one that's in memory. I just need to make it diskable, but it's easier said than done.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
You do know about the System.IO.MemoryMappedFiles namespace, right?
MemoryMappedFile Class (System.IO.MemoryMappedFiles) | Microsoft Docs[^]
If you have a C++ version of your app, you could run them side-by-side and compare performance.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Yes, though it was added to .NET after my initial attempt at using mem mapped files from C#.
Besides all that is is a wrapper like the one i had written years ago.
It doesn't change the basic problem which is:
var foo = new int[1000000]; //backed by disk, paged automatically, in C/C++
it's mainly because you can't use pointers in C#, and even if you use unsafe, you cannot pin objects to specific addresses in memory
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
honey the codewitch wrote: it's mainly because you can't use pointers in C#, and even if you use unsafe, you cannot pin objects to specific addresses in memory
Yes, and that's by design.
|
|
|
|
|
I'm aware of that. I worked on the Visual Studio team at microsoft. I know a little about .NET
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
I'm not sure why you feel the need to tell me that you worked at Microsoft. If you were trying to imply that it adds credibility to what you say, I've go to tell you that I've met some real nimrods who came from Microsoft to those MVP summits I used to go to.
I'm sure that a number of exceptionally talented people work or have worked at Microsoft, but there are also these nimrods (who thought they were exceptionally talented). A random sample could belong to either camp.
Because you had to say that, I had to say this.
|
|
|
|
|
No I'm telling you i don't need your lectures about the very basics of how .NET works.
I don't care if you find me credible because your opinion doesn't matter to me. If that were to change, we'll talk.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
honey the codewitch wrote: No I'm telling you i don't need your lectures about the very basics of how .NET works.
I responded to you with a couple of one liners, and you term those as "lectures"?
honey the codewitch wrote: I don't care if you find me credible
That's probably why you tried desperately to establish that you're sooo good with announcing your "Microsoft backgroundz"? Geez, try and make some sense occasionally.
honey the codewitch wrote: your opinion doesn't matter to me.
Ha, we finally have something in common.
honey the codewitch wrote: If that were to change, we'll talk.
No, thank you.
|
|
|
|
|
Rajesh R Subramanian wrote: No, thank you.
Nobody made you respond to me. Now I'm not listening to this anymore. Have good day.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
honey the codewitch wrote: Nobody made you respond to me.
If you're a nobody, then yes.
honey the codewitch wrote: Now I'm blocking you so I don't have to listen to this anymore.
TMI - I don't need to know what you are doing on the internet.
|
|
|
|
|
No reason to be an asshole.
#SupportHeForShe
Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson
You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
|
|
|
|
|
You don't seem to be taking your own advice seriously - I see you deem it fit to be an unreasonable a**hole by starting a discussion with someone by calling them an a**hole.
|
|
|
|
|
Get a clue and take a hike.
#SupportHeForShe
Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson
You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
|
|
|
|
|
Go ahead, I'll follow your lead. In other words, don't preach what you don't practice. Or simply, follow your own advice.
|
|
|
|
|
You started this buddy by being a complete dick and jerk to another member here. You can finish it by just saying "I'm sorry -- won't happen again." Not to me, but to the other member. Or you can just sod-off. Until then expect to be treated by me like I see you treating others.
#SupportHeForShe
Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson
You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
|
|
|
|
|
TheGreatAndPowerfulOz wrote: ou started this buddy by being a complete dick and jerk to another member here
That's what you did, not me.
TheGreatAndPowerfulOz wrote: You can finish it by just saying "I'm sorry -- won't happen again." Not to me, but to the other member. Or you can just sod-off.
I had an argument with another member (admittedly heated), and we're through that, and that's that. If you don't like that, you can sod-off (follow your own advice).
TheGreatAndPowerfulOz wrote: xpect to be treated by me like I see you treating others
I should care? I might have had to take you seriously if you had anything to show as your own contribution to this community, like an article or a few awards. And you're trying to act like you've some business with how two other members have discussed, trolling on a two day old thread.
modified 20-Sep-19 13:28pm.
|
|
|
|
|
Rajesh R Subramanian wrote: That's what you did, not me.
I had an argument with another member (admittedly heated), Contradicting yourself. Typical sign of faulting thinking.
Rajesh R Subramanian wrote: I should care? I might have had to take you seriously if you had anything to show as your own contribution to this community, Yeah, you should care. As if you have anything to show yourself. Awards or no awards, doesn't matter. You should care how you interact with others. Be human. Not an animal.
#SupportHeForShe
Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson
You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
|
|
|
|
|
Let me see if I could start it on a clean slate with you.
Your primary accusation is that I started off by being rude to this other member. This is untrue, because my first two messages (on different parts of the thread) were:
1. A suggestion that a native programming language is more suitable for performance oriented tasks (not to mention the "should work across platforms" requirement).
2. The op pointed out some "flaws" with the .NET framework, which I said were basically not flaws, but by design. (how could one have raw pointers that could be used for manipulating memory on a framework that promises to automatically manage memory for you?!)
The other person basically responded to me telling something amounting to "I worked for microsoft and I therefore don't need you telling me about .NET", which I did not like. I pointed out that working for microsoft doesn't automatically make someone very intelligent.
The discussion went downhill from there, and the OP had some condescending stuff to say as well. A bit of back and forth, and the OP said they don't like me and that they will block me. I thought that was fair enough as we had had a heated exchange.
But then you show up and falsely accuse me of "starting out by being a jerk" and here we are.
|
|
|
|
|
|
pinning does not solve this problem. I don't need a random pointer .NET produced from the GC heap.
The only thing i could do with that is throw it away. It's useless for this
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
If you want to do this in the dotNet framework and have it cross platform you're going to want to use one of the newer frameworks anyway as the older ones are not generally cross platform. I don't see the problem here.
|
|
|
|
|
a newer framework doesn't change the landscape though. I'm using the latest stuff anyway.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|