Amazon EC2 Instance IDs - Why XOR? - amazon-ec2

According to Guy Rosen and RightScale the Amazon EC2 instance IDs contain two XORs against the first and second half of the "Inner ID" and all three against their own constant.
I understand that we won't know exactly why Amazon does this. However, from a general perspective, has anyone implemented or seen this sort of XOR and why would this XOR be implemented?
Is the only purpose to help obfuscate the ID?

Obfuscation via a straightforward binary operator seems a little silly considering how little it apparently worked to prevent people from figuring it out. I would assume that Mr. Rosen stumbled across one possible use for it, the only other I can think of is some form of resource tracking.
Of course, until someone from Amazon tells us this will all be pure idle speculation.

Related

AlphaGo Improving Itself

I've read a couple news articles about AlphaGo and they all mention that AlphaGo became better from first playing human games, then playing games against itself. One thing I am curious about is, how did AlphaGo improve itself? Does it modify variables in the code? Or does it change it's code completely writing it itself? Or did the creators add it? How does it actually learn? A generalised answer is fine as it's just for my general knowledge.
Maybe I'm misunderstanding the whole concept, news articles tend to give a broad and sometimes misinformed understanding. Some clarity would be great or links to useful information.
AlphaGo uses machine learning.
In Machine Learning you have a function (say ax +b) that gives you a result and you tune the parameters of that function (a and b) so that the result matches more and more the examples you have. In the case of AlphaGo they had 2 functions, one to pick the next move and and one to say who is winning, and both are very complex with many thousands of parameters.
When they played a game between two instances of AlphaGo they would record the result and use it as an example to train the functions, so that the next version plays even better.
There are great tutorials on the web on how machine learning works if you want to know more.

What is the appropriate name for this hardware multiplier? Also, where can I find documentation on it to understand what is going on?

We're doing some work on a CPU in logism in class. We're going over the ALU, and need now need to know different ways multiplication can take place. Our professor gave us two examples, one called the "Five Add Time" and the "31 Add Time" (although I do not believe these are the official names of the algorithm), shown here:
And Here
What are the proper names for both these algorithms, and is there any documentation that would allow me to better understand what's going on here? I'd google it, but I am really not sure on the specific term I should look up.
Thanks

How does VirtualBox CALCULATE how many virtual CPUs are available?

I've tried to get an answer to this question in VB IRC channel, I've looked around stackexchange, stackoverflow, superuser, and elsewhere. Answers come close, but not what I am wanting to know.
This is a curiosity question only, not one of necessity. I just want to know how things work. It has nothing to do with any bug, enhancement request, or security issue. If you feel this forum is not the place to get an answer to this, please refer me to the proper venue. Thanks. (Although it is hard for anyone to imagine that VBox's own forum could be the wrong place, I did not see an answer to my specific question or a place to post to an appropriate category.) Whatever happens, please don't close my question without at least pointing to a better resource (I hate when that happens!). Thanks again.
Now, the question: How does virtualbox's host driver calculate the total number of virtual CPU's to provide?
(Please note I will not respond to answers from people who did not really read the question, or at least first ask for more clarification. I think this is a VERY straight-forward question.)
Let me break the question down so as to be as precise and concise as possible as to what I am really asking. I am curious to know how the VirtualBox HOST software (whatever portion that may be) determines how many VIRTUAL CPUs appear on the configuration interface where the user selects how many VCPUs they would like to apply to a specfiic VM.
What I am NOT asking: I am NOT asking about the miracle of virtualization hardware, etc., in general; I understand multiple cores and multiple threading, VTx, etc. I am NOT asking how many I should use for a specfic VM or application. I am NOT asking for help in configuring any specific VM in my question. I am NOT asking anyone to ask ME why I need to know -- I told you already; I am merely curious. If my specific question does not interest you, that's fine. Again, this is just a simple, straight-forward question: How does VBox arrive at the number?
What I already know: It is true that, at least generally, the answer is 2x as many as physical CPUs; OK, if so, why 2x and not 3x or some other multiplier? (I know fractional amounts won't work for odd-number of cores or threads; I am just being as general as I can be.) For instance, on my Phenom II X6, VirtualBox presents me with up to 12 VCPUs. If the answer is the threads, well, that can't be since my particular Thuban does not have threads (some Thubans do, some don't). What my Thuban DOES have, though, is hypertransport, but not hyperthreading. Likewise, my old Phenom II X2 will allow 4 VCPU's in Virtualbox.
I have already read the numerous responses on the sites mentioned above admonishing users NOT to use more than one VCPU per VM because it adds overhead (for one thing, you must run the IOAPIC, which introduces a performance hit). I've also read posts where the question sounds like mine, but they do not ultimately give an answer to this.
Is the answer some kind of sigma sum or logarithmic formula? Is it complex enough to exceed this forum's formatting capabilities? Hard to imagine why it is so difficult to get an answer to this, which I figure would have been asked and answered many times over. I really want to know why it seems to be 2x usually; why that is the "magic" number. If I read the source code (assuming this is available), will the comments explain why?
I will really appreciate and admire the soul(s) who read and answer this question, and not some other question not being asked. I also hope you will not redirect me to the dark and hostile channels of IRC; there are some very sociopathic entities on IRC whose remarks remind me of some of the unsubs on Criminal Minds. Note that I said "some" -- there are helpful people there also. Not meaning to antagonize; I just hate going to IRC anymore. If you know of a specfic helpful nick on IRC with this, I'd appreciate that also.
BTW, I have been googling for answers to this and other questions and reading SO, SE, and SU boards and I see where some people respond with answers that are totally irrelevant. That's the reason for what may sound like a harsh tone by me. This is my first post, and I hope the response will be more positive than a few of my experiences on IRC.
It seems you are asking "How does the VirtualBox GUI calculate the available range for the Processor(s) slider under the System settings?"
Because VirtualBox is open source (and very clean, well written source) it isn't too hard to dig into the code and research out the answer. Digging down into the /src/VBox/Frontends/VirtualBox/src/settings/machine folder you can see all the UI* files that comprise the settings UI elements. The specific file that will have your answer is UIMachineSettingsSystem.cpp. Starting on about line 45 (as of revision 43459), you can see the following code:
/* Setup constants */
CSystemProperties properties = vboxGlobal().virtualBox().GetSystemProperties();
uint hostCPUs = vboxGlobal().host().GetProcessorCount();
mMinGuestCPU = properties.GetMinGuestCPUCount();
mMaxGuestCPU = RT_MIN (2 * hostCPUs, properties.GetMaxGuestCPUCount());
The mMinGuestCPU variable and associated GetMinGuestCPUCount() method (and mMaxGuestCPU / GetMaxGuestCPUCount()) should be relatively straightforward - typically it will be 1 for the min and the max will be the number of physical/logical cores available on the host.
Thus, to answer your question - the scale for the slider is typically 1 through two times the number of cores available. I would strongly encourage you to download the source code and dig into the methods that calculate those numbers and see for yourself how they are calculated and the nuances that are involved. Specifically the vboxGlobal().host().GetProcessorCount() method.

Text search question about implementation

Can someone explain me how the text searching algorithm works? I understand its a huge field but am trying to understand it from high level so that I can look up academic papers on it.
For example, Spelling mistakes is one problem that is tough to solve and of course Google solves it. When I search for a term and misspell it on Google, it automatically suggests the correct spelling. How is indexing done for it? Using MapReduce I can see they index various entities. What do they or some one else index and store? May be I am looking for a practical implementation of MapReduce if I am thinking in the right direction at all.
Pav
I'm afraid this question really is too big, which probably explains why it has not seen an answer yet. As far as Google's spell-checker is concerned, Peter Norvig explains how it is done: How to Write a Spelling Corrector
The exact implementation in productive use at Google surely looks quite a bit different and way more complicated, but this might get you started.

How does a programmer think? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
This may be a hopelessly vague question. But I am interested to hear whatever logical thought processes people go through when learning a new concept or trying to get their brain around code they might not have ever seen before.
Basically, what general steps does one take to to break down problems and what does it take to "get it"? If you were to diagram a flowchart of how your mental process works when you look at code or try to solve a problem what might it look like?
What common references, tips, and mental assumptions do you find useful in problem solving?
How is this different between different domains? For example in what ways is a web programmer's thought process similar or different from a traditional desktop app developer's process?
I'm a big believer that no matter what type of application you're looking at for the first time, may it be a web app, a desktop app, a device driver, or whatever else, there are three steps one developer usually follows in order to understand how it works:
Get the big picture :
What kind of app is this (web, desktop, ...)?
How is it layered (standalone, client-server, n-tier, ...)?
What is the app's purpose? What is it supposed to do?
Who is the app made for?
See how it works :
What language(s) is (are) used?
How is the code structured?
How is the data structured?
Understand (or at least try to) the way the app has been thought through:
Has it been thought through at all?
Is the app clearly optimized? (For performances? For readability?)
Is the app finished? Or is there room for evolutions?
Are there signs of multiple releases?
etc...
The 1st and 2nd steps are purely technical, while the 3rd MUST be as untechnical as possible... it's more about psychology and understanding how the app has been built. It obviously requires experience, but as long as you think hard enough and don't waste your brain's time with technical details, you'll eventually get it.
This whole process shouldn't require the use of a keyboard. You're only supposed to read, think, and take notes on a paper (I'm not kidding: pen and paper!).
Ho ho, good luck with this one. It's a great question and I'm sure you'll get a ton of answers. Although I have to say I cannot give a satisfactory answer to this - the last thing I would describe my thought processes as is a flow chart - I don't think there is any golden formula for this.
The only tip in problem solving I can recommend is discussing it with somebody else. In those times when you hit a brick wall, going through it with a colleague is invaluable. Quite often, as well, they will actually not even add much to the discussion - in the process of getting all your thoughts out in the open, the solution can become clear.
People are notoriously bad at examining their own thought processes, but I'll give it a whirl. I test very high for visuo-spacial ability in IQ tests, medium-to-high for verbal skills, and moderate for mathematical skills (explains my A-level Maths grade, I suppose). amd when I start to design software, I think in terms of shapes and the connections between them. When it comes to describing these thoughts to others (or clarifying them for myself), I use simple block diagrams or the object diagrams taken from Jacobson's Objectory method - NOT the over complex stuff that UML suggests. I sometimes write textual descriptions of complex things, mostly as reminders to myself, but never use numbers or maths.
Of course this is just me - I've worked with maths whizzes who were just as good or even better programmers than myself.
I don't think... I process.
This is actually less flip than it sounds. I always break down tasks into their components and then break these down further, and that doesn't just go for writing software! Much like #Mark Pim U go through things sequentially.
My wife gets really annoyed when I make dinner because I take so long to get started.
Divide & Conquer
I start by trying grasp the entire problem as it is, and then start to find patterns I can recognize, and do the same for them in a kind of recursive process, until I have a broken down solution I can implement and follow more easily.
This is one of the rare times I would answer with "it just works." I learn things by steamrolling through them. I don't have gimmicks, or devices to help me. Took me some time to learn PHP, but after that Javascript was much easier. Once you tackle one thing, the next items become cumulatively-easier.
Personally, I conduct an internal dialogue with myself 'OK so we need to loop over this list of integers.' 'But we can break when we find the value we want.' 'OK, will the list definitely be initialised when we start?'
I'd be interested to see if any psychological research had been done on problem solving techniques.
Similar to Jonathan Sampson - it kind of just works.
When I'm attacking a real problem, I try and think of the most logical way of getting through it is.
Then, when everything goes wrong (as it usually does), I have to make hundreds of sidesteps to get things done. Just keep focusing on that end goal, that logical way and you'll get there.
Eventually though, it decides to work for me and I end up with a finished product that is usually nothing like I planned it out to be. As long as the customers are happy, I am!
Personally, I see code in my head pictorally rather than textually (like Neil Butterworth) - it's a bit hard to describe since (quoting STIV) "there's no common frame of reference."
My main skill is identifying similarities between models or systems I already know about and the task at hand. The connections between some of these can seem quite abstract; the key is to spot the connections. This leads to the abstraction of common patterns and approaches which are widely applicable. Related to this, the most important thing I learnt about algorithms was that the problem is never 'come up with a smart algorithm to solve X'. It's 'model problem X such that it can be solved by existing smart algorithm Y'.

Resources