From: Jerry Coffin on
In article <bsknq5hljapktqgdi8uji3vtt3mhrrebun(a)4ax.com>,
newcomer(a)flounder.com says...

[ ... ]

> Sadly, if we look at everything from Enron to the latest set of
> bank failures, ethics was not a priority in business schools.
> "Screw everyone, as long as YOU win!" seems to have been the
> message instead.

I'm not sure these can be blamed entirely (or even primarily) on the
schools -- at least not the post-secondary schools. I'm reasonably
certain behavior like this is (at least mostly) learned and
thoroughly ingrained long before people reach college age.

These are people who wouldn't have blinked an eye at passing their
ethics courses by downloading papers off the 'net, getting their frat
brother to write their final paper, or even faking up an ID card to
let somebody else take the final test for them.

Granted, it's not clear that the colleges even tried. Worse, the
companies involved seem to have not only tolerated, but even
encouraged the worst behaviors. Nonetheless, I think college is too
late to do much good in this respect. By college age, about the most
you can reasonably hope for is putting a basic sense of right and
wrong into a larger framework.

I think most of the people involved in these scandals would have
treated an ethics course as little more than guidance about what
kinds of things they could to blatantly, and what things they'd need
to be sneaky about.

--
Later,
Jerry.
From: Peter Olcott on

"Liviu" <lab2k1(a)gmail.c0m> wrote in message
news:eQk%23NMwzKHA.5348(a)TK2MSFTNGP02.phx.gbl...
> "Peter Olcott" <NoSpam(a)OCR4Screen.com> wrote...
>> "JustBoo" <Boo(a)boowho.com> wrote...
>>> On 3/23/2010 9:09 PM, Peter Olcott wrote:
>>>> Personally I really hate dealing with tedious little
>>>> details, [...]
>>>> I really can't stand debugging my own code, that is why
>>>> I take very
>>>> extreme measures to prevent bugs from occurring in the
>>>> first place.
>>>> I carefully design every single line of code, and check
>>>> the design
>>>> many times before I even try to compile it. Most of the
>>>> code that I
>>>> write mostly works the first time with only the most
>>>> trivial logic
>>>> errors.
>>>
>>> Ding! Check Please! [...]
>>
>> Just because a statement may be unbelievable does not
>> logically
>> entail that this statement is not a verifiable fact, time
>> will tell.
>
> Just curious, but how long a time would one expect before
> it "tells"?
>
> Looking at the recent "memory read speed test" code you
> posted in this
> thread, and referring strictly to the "most trivial logic
> errors" (not
> the deeper confusion of what you were trying to measure
> and match)

> but... it took two painfully obvious corrections before
> the thing even
> ran.

Factually incorrect, It ran before I posted it and I posted
it from cut-and-paste.

> Then, you had a couple more naivetes which just happened
> to
> cancel out, writing a loop with no side effects, but
> forgetting to
> "#define _SECURE_SCL 0" so that the loop wasn't optimized
> away
> altogether (but then contained std::vector bounds checking
> code which
> did not belong in a "raw speed' test). Later, there was at
> least one
> other correction from another group where you posted a
> followup,
> about that odd rand()*rand() idea.
>
> And the above doesn't even begin to nitpick on "boring
> details" such
> as whether you think that your latest "GetRandom" really
> returns a
> random uint32 (hint: no, just the lower 30 bits are
> random), or that

Sufficient for its intended purpose. It was modeling a
process with widely dispersed memory access patterns, not
random access patterns, thus the lack of true randomness
misses the point.

> "(double)(Max * 4)" might overflow, and what you really
> wanted was
> "(Max * 4.)". But of course, I trust that you were well
> aware of these,
> and the other hardcoded constants in the code were
> carefully and
> purposely chosen to work regardless. Also, that your "real
> code"
> never ever has any such problems, and you are just
> routinely teasing
> the newsgroups to check whether anyone was paying
> attention ;-)
>
> Liviu
>
>

The quick and dirty program provided the response time
curves related to size of memory allocation sufficiently for
its intended purpose.


From: Hector Santos on
Jerry Coffin wrote:

> In article <bsknq5hljapktqgdi8uji3vtt3mhrrebun(a)4ax.com>,
> newcomer(a)flounder.com says...
>
> [ ... ]
>
>> Sadly, if we look at everything from Enron to the latest set of
>> bank failures, ethics was not a priority in business schools.
>> "Screw everyone, as long as YOU win!" seems to have been the
>> message instead.
>
> I'm not sure these can be blamed entirely (or even primarily) on the
> schools -- at least not the post-secondary schools. I'm reasonably
> certain behavior like this is (at least mostly) learned and
> thoroughly ingrained long before people reach college age.


I'm sure people had to have some level of molding, but during the 70s,
80s, for MBA track people, it was all about short term profits. Long
term planning was out the door. It was about the service industry and
less of the manufacturing industry.

I think I got my first job with Westinghouse because I was able to
articulate with my the final plant interview, the division directory,
about short term and long term issues, how it was affecting society
and the manufacturing base. I understood both, but with an ethical
social engineering mindset.

Unfortunately, we didn't have much of that thinking and in reality not
even the Westinghouses, who like most of the rest, lost most of their
manufacturing base or moved it to cheap labor countries.

The irony of Software development is that by design, its purpose is to
reduce labor, to automate, and to more and more to think for people.

> These are people who wouldn't have blinked an eye at passing their
> ethics courses by downloading papers off the 'net, getting their frat
> brother to write their final paper, or even faking up an ID card to
> let somebody else take the final test for them.


This predated Joe and I days, but we saw it coming as the net grew.

One year, I made $15-20 a pop for a punch case based Fortran
scheduling program - give me the courses you wanted or needed to take
and it will produce 2-3 schedules to pick. I remember when there were
a few conflicts for some people, so *I* decided who should get
preference. :) I did only for about 10 people or so before I began to
do it for free and stopped for whatever reasons. I intentionally did
not want to advertise it or go further with it, but the it stopped
because someone stole the punch cards. :)

In another similar punch-card thief incidence, it effected me for the
rest of my life - never deal with people you feel can stab you in the
back. It gave me a negative prejudice against a certain culture of
people in this world. I will never deal with them or if I had to, I
will be because I became very desperate and don't care. This is a
problem today with many businesses who are desperate for business.
They don't think or care about the consequences.

> Granted, it's not clear that the colleges even tried. Worse, the
> companies involved seem to have not only tolerated, but even
> encouraged the worst behaviors. Nonetheless, I think college is too
> late to do much good in this respect. By college age, about the most
> you can reasonably hope for is putting a basic sense of right and
> wrong into a larger framework.


This really ought to begin at early age. At least at the 7-12 grade
level. But more importantly at the home. Today it is be done because
this generation parents know about this. They didn't back in 70, 80s
it was too new. I remember far too many parents buying PC for kids
and really didn't know what to tell them on how to use it and how NOT
to use it - or even thought about that idea at all. They took it for
granted it can not be used for evil or even that their kid was even
capable of being challenged with such things.

I remember as a 7-8 year old, going into a Bodega (spanish grocery
store), the owner was behind the counter yapping on the phone looking
over occupied. I tried to sneak some candy into my pocket and suddenly
he stopped talking on the phone and say and in spanish "Put that
back!" and went back to yapping on the phone. I was shocked like a
deer in headlights. I put it back and walked out. I never again even
thought about shop lift or stealing anything. I was the family
computer geek and a few cousins asked if I can steal from ATMs, break
into tv cable boxes, etc. They stopped asking knowing how I would
never think about doing it.

> I think most of the people involved in these scandals would have
> treated an ethics course as little more than guidance about what
> kinds of things they could to blatantly, and what things they'd need
> to be sneaky about.

I think you can say this for the worst kind. But I think it would of
provided guidance for most because most people do have a heart, and
most people will think twice, if only because of they recall the fun
class ethic debates they had. For others, its come too late, they
learn after they get caught. And sure, for a few, it doesn't matter.
But I guess, it only takes a few to create the worst disasters.

--
HLS
From: Hector Santos on
Peter Olcott wrote:

>> And the above doesn't even begin to nitpick on "boring
>> details" such
>> as whether you think that your latest "GetRandom" really
>> returns a
>> random uint32 (hint: no, just the lower 30 bits are
>> random), or that
>
> Sufficient for its intended purpose. It was modeling a
> process with widely dispersed memory access patterns, not
> random access patterns, thus the lack of true randomness
> misses the point.


Probably the only sensible statement you made, based on what I told
you for simulation stress for memory.

Peter, is one was going be more accurate here, your RNG would be at a
page level. In other words:

nTotalMemoryRead / dwPageSize

where dwPageSize is obtained from GetSystemInfo() which basically says
you have a +/- 4K address hit. So when you hit an address within a
page, that entire page is now in your working set. For that page, you
will not lose in access time.

Example, 1.5GB ---> 393216 4K pages

So your RNG is from 0 to 392315 or

Address = RNG(0,392315) * 4096

Why is this an important understanding? not RNG, but the page size?
See below.

> The quick and dirty program provided the response time
> curves related to size of memory allocation sufficiently for
> its intended purpose.


Yes, this simulation is a good start, and the RNG just need to a
good/crude jumping bean. But I also told you other things that will
provide a better test.

First, you need to rethink of usage of std::vector. You might be stuck
with that because that is how the code you obtained has it, but it
should be rethought.

Since you have a READ ONLY file, you can use a MEMORY MAP FILE VIEW
with maximum memory access throughput. The reason why it works well
is because of the pre fetched page loading. So you are not hitting
the disk at the rate you think. The MMF provides you with the VIEW
SIZE you want so when you hit a certain address, the rest of the VIEW
is preloaded.

Now, it also works very fast when memory is aligned with the WORD size
of the CPU and also the cluster sizes of your hard drive.

This is one of the problems with 64 bit - SLACK SPACE. While you can
load more, you can have huge slack space (memory that isn't used).

I don't know how big if each of your elements. You been using 1 byte
sizes. To improve this, you want to use sizes that align perfectly
with memory and your hard drive.

From what I see in the std++ source code, it uses the Heap Manager,
but I am not sure it is uses a block approach. But overall, that
means you will be under the OS VM full control

You can modify it but can also explore if the std:;vector offers an
operator to return the beginning pointer of the entire allocated
memory block(s).

I know CArray() will do this because I used it with qsort().

Second, which brings it back to a MMF.

By using an MMF, this overs your two engineering designs:

- Single Proces, Multi-threaded sharing a process shared memory
- Multiple Processes, single thread, sharing a MMF DLL

The reasons for each depends on how your scaling needs and you can't
won't truly know if you tried both.

If you need 100 TPS, with a 100 ms response time, that means that you
with have loading potential requirement of atleast 10 current threads.

In other words, that is your Active Worker Pool Size. You will need
at least 10 workers on call at ALL times available to be called.

Example, setup with be:

Maximum Workers: 20
Active Workers: 10

What that means, you would create 20 worker threads, they all start a
sleep (started in CREATE_SUSPENDED mode). Then as each request comes
in, you start (resume) a worker thread. When the request load reaches
10, then you now has to decide how to slow it down or you start one
from the other 10, but no more than 20.

This is whats called scaling and load balancing for performance. You
want a 100 TPS. You don't want to overload it because you will slow
it down.

Finally, you can do this for single process/one thread per core vs
multi-threads. You do have process exe loading overhead, but at 100
TPS levels, you will not see this loading overhead. It depends on many
factors. On the other hands, if you see your work pool size is 10 or
some other value around 10, TRUST me, this is really LOW for modern
client/server systems - this is why I always said you are over
estimating your design requirements because you had lost focus with
the memory issue.

In our SMTP server, we have a similar setup:

Maximum Accept Connections : 0 (Waiting Workers)
Maximum Accept Load : 0 (Active Workers)

The above values is the new defaults today which means, let it fly,
handle them as they come, a new worker as they come in. We set it at
zero because today's multi-core hardware and OS is fast.

But it use to be:

Maximum Accept Connections : 15 (Waiting Workers)
Maximum Accept Load : 10 (Active Workers)

which means that the server was allow to process 10 emails at a time,
putting 5 on hold (FIFO queue). For each email transaction, the RFC
3531 specifications provides a 5 to 10 minutes IDLE wait period per
state of the conversation:


WELCOME 5 mins - client connects, waits for WELCOME
EHLO/HELO 5 mins - client waits for response
MAIL FROM 5 mins - client waits for response
RCPT TO 5 mins - client waits for response
DATA 10 minutes - servers allow 10 minute idle
QUIT 5 minutes - client waits for response

In other words, the RFC in theory says that its possible to have a 35
minute transaction time. That isn't reality of course.

So our SMTP allows for 10 active threads ready to serve incoming SMTP
clients. When the 11th to 15th requests comes in, up to 5 addtional
works are started. At the 16th, it has to wait at least 5 minutes to
see the welcome which is done when one of the already 15 active
threads take over the session.

What the Microsoft IOCP plus Worker Pool technology is about is that
it does the above old traditional listening server/worker pool thread
design for you for you. Its recommendations for setting it up (i.e,
programming) is based on take advantage your multiple cores.

For example, the recommendations is 2 threads per CPU. So if you have
a QUAD, MS recommends 8 threads under IOCP design.

There are literature like Bains, suggest a MAXIMUM 10 threads per CPU,
but it all depends on your loading requirements.

The key is how you load your memory and how you share it.

Honestly, you have a very simple design requirement. There is really
nothing special about your needs. Its all been done using traditional
methods plus those that MS has to optimized their OS and machine.

Either way, the only difference is how you tune it for your needs.

I think you need to look at your program in how it works with its
memory loading in a shared memory. Put away the notion that it will
be too slow for you. The reality is that YOU will be too slow for the
OS and machine. That is the reality and you are underestimating the
power of OS and machine.

--
HLS
From: Hector Santos on
Hector Santos wrote:

> I don't know how big if each of your elements. You been using 1 byte
> sizes. To improve this, you want to use sizes that align perfectly with
> memory and your hard drive.
>
> From what I see in the std++ source code, it uses the Heap Manager, but
> I am not sure it is uses a block approach. But overall, that means you
> will be under the OS VM full control
>
> You can modify it but can also explore if the std:;vector offers an
> operator to return the beginning pointer of the entire allocated memory
> block(s).
>
> I know CArray() will do this because I used it with qsort().


I forgot to note the reason I was mentioning the need to get the
address, so you can explore using either

- VirtualLock
- AWE

but I don't think you will need it, especially if the negatives come
into play with the fixing the working set which is not a guarantee.
AWE gives you more of want you want. You should explore it too, but
then again, do you need it.

Ideally, you should encapsulate the loader with a abstract class so
that the interface does not change when you explore various memory
loading implementations.

class CMetaDataAbstract {
public:
virtual const TMetaData & Get(const size_t i);
virtual size_t Put(const TMetaData &);
virtual size_t Add(const TMetaData & );
virtual bool Delete(const size_t i);
};

Now you can create sub-classes for:

Pure raw data array memory,
std++ collections
MFC collections
Memory Map Files


--
HLS