Friday, February 25, 2022

A call to democracy

 Democracy versus autocracy is the big fight that always haunts mankind. Democracy and freedom is something I hold very dear and I have it because my ancestors fought to acquire it.

I am a Swede and I am proud of that, I am proud of how my ancestors worked hard to establish a democracy in the Swedish territory. Now that democracy is under threat both from within and without in many countries I think it is important to consider our options here.

Sweden as most other countries have had many dictators in the form of kings and queens. Some of them good, some of them not so good. Sweden even had a time when we were a great military power between 1630 and 1720.

I am very interested in genealogy, my ancestors comes from all parts of Sweden (Norrbotten, Skåne, Östergötland, Småland, Blekinge and Gotland). I can trace most of them down to early 1600s and some of them down to 1400s. I can also see what they have been doing all the way down to the 800s.

All my ancestors are either farmers and/or militaries. The farmers were sometimes poor and sometimes extremely wealthy. But living in Sweden meant hard work, particularly for my mother's ancestors living in the northern parts of Sweden. However one reason to settle in the north parts of Sweden was definitely the freedom it gave. No kings, no sirs and such thing. Each family had its freedom to choose their way in life.

My ancestors have been involved in global trade for more than one thousand years.

This changed with kings coming to power in Sweden around 1520. Some of the development during those kings was very good for Sweden. However the rise to military power was very costly to the Swedish population.

As part of my genealogical research I went through each and every death recorded in the parish of Luleå between 1696 and 1754. The statistics of this research is very telling for the cost of being a military power in an autocracy.

In those years there were 2200 deaths in Luleå. The number of women that died was 1400, the number of men were 800. Thus a simple calculation shows that 600 men didn't die in Luleå, but elsewhere.

In those years when you died outside your home parish it meant that you died at war, either fighting or more likely through some sickness acquired in the military camp. The number of women dying implies that about 25 males should be born each year.

So what happened in those years in Sweden. Sweden had peace between 1679 and 1700. Then Sweden was attacked from 3 countries at the same time, Denmark, Poland and Russia. After that Sweden was involved in wars until 1718. Those years cost the population in Sweden 25 years of males, thus more than half of the males in those years died from the wars.

This is the true cost of rising to military power. This can be seen all over the world, there is a high cost to conquering other nations for gain. Those that want to do that are fully willing to sacrifice more than half of their population for their egoistic aims.

In Sweden the people got sick of kings with dictatorial powers after that. The move to full democracy in Sweden was a long story that started with "hattar" and "mössor" in the 1720-1770s. Then a short new period of dictatorship came back. Again the king decided to start a war and cost about 50.000 people their life. At least 3 of my ancestors died as part of that war. The last swedish king that was a dictator was removed when he lost Finland. Sweden still has a king, but he has now more of a ceremonial position and no political power.

After a short war with Norway after that Sweden has now had more than 200 years of peace and has used this peace to continue establishing the democracy.

Everyone knows that democracy is not perfect. But the reason humanity strives for democracy is that it is so much better than the alternative of dictators. Democracy requires patience and it does require military force to protect the democracy from external forces. At the same time a democracy can only survive if the people respects their choosen politicians and with free press that provides protection against corruption sneaking in.

Mankinds largest challenge is our own egoism. I have noted that in the family division and fights starts immediately when one part is being egoistic. Surely the same thing happens in the political world.

Tuesday, February 25, 2020

Sense and Sensibility and Experiments

The title is an extension of the name of a novel by Jane Austen. Sensibility
and feelings might be more what I want to discuss in this blog.

What I want to provide some viewpoints in this blog is the relationship
between sensibility and feelings.

A life with only feelings is dangerous, feelings without the restraint of
sensibility can lead a person astray and on wild tours. I think most persons
have experienced this at some point in their life.

So let's consider life with only sensibility.

Oftentimes one considers science to be based on sensibility and that one
can only find truths with hard facts. This is not my experience in life. Hard
facts and scientific reasoning can get us very far for sure. But there is a limit
to this. There are many things that are so complex that it is impossible to
(at least for me) understand things fully. This is quite obviously true in many
human relations, but also true in trying to understand complex systems.

I remember that I once had a benchmark setup where I tested a highly parallel
update benchmark in a very large cluster setup. What I saw in benchmark
numbers was a strange wave. The performance in the cluster varied between
70M reads per second and 140M reads per second, but it was never stable.
It behaved somewhat similar to a sinus curve with a frequency of a few minutes.

The cluster had about 100 computers and about 5000 CPUs. Thus the cluster
was mathematically a very complex model with thousands of queues that
were interconnected and affected each other. In addition service times in
those queues were dependent on the queue size (TCP/IP messages are handled
more efficiently with bigger packet sizes).

Thus to try to understand this model mathematically could potentially be possible
to some extent, but it was outside of my competence level and I have studied
mathematical models of queueing networks at a Ph.D level so would consider
myself as fairly competent in this area.

The other option to analyse this model would be to perform a simulation that
is close enough to the reality and thus be able to get a better understanding of
the system behaviour. This was a possibility but would probably be an
undertaking of at least a few months.

So what is one to do then in lack of a sensible approach to solving the problem.

This is where I think feelings comes in an important part of understanding the
world around you. My thinking process in those situations is to think about
the system and basically just think and think and contemplate what is going on
in the system.

My thinking about it like this came up with an idea. I started thinking about
traffic jams in a major city and how they can behave the same way where you
go from very slow to very fast in a similar fashion with a similar frequency of
a few minutes.

I concluded that traffic jams are often caused by people trying to drive too fast
and thus causing too many cars to enter a limited section of the road and thus
causing a jam in that section. After that section has been passed the traffic will
usually flow nicely again. Sometimes those traffic jams disappear without any
reasons why they would disappear.

The solution to the traffic jam is that every car has to slow down also in the
areas where there is no traffic jam.

So the question is then, could this approach also work in the computer system
that I worked with.

Obviously this was a theory that I came up with, it was not based on clear
evidence, it was not necessary a sensible approach that things will go faster
by slowing down. I refer to this as a feeling, a hunch that things could be
in a certain way.

So what does one do then when there is no sensible solution, but there is a
feeling that one might have a solution. This is where experimentation comes
in.

In this case I developed a new feature in NDB Cluster that implemented a
new configuration parameter MaxSendDelay. What this feature does is that
it delays sending messages until they have queued for some time.

The effect of this is that more packets to the same destination can arrive
and thus packet sizes can increase and we can improve the flow through
the system.

I implemented this and it worked, the performance jumped to 200M reads
per second and the performance was stable.

So now that I have tested and verified that the solution worked, is the
solution now sensible. Well, it is sensible to use the solution since it
at least works in this particular experiment. Have I thereby understood
all the reasons behind why it behaves as it does? No, I have not, I am still
unable to prove or fully explain why this approach solves the problem.

So sensibility got me a bit on the way, but to move on from the sensible
approach I needed to use feelings. After applying feelings I needed to
perform experiments to verify that my feelings was correct. But even
after applying an experiment to my feelings I still have  lots of work
to find the reasons behind why it works as it does.

So in my work I have found that I need to use this three-thronged approach
to extend my understanding.

First learn everything there is to learn through other's experience, thus
ensure that all the sensible approaches in the area is known to you.

When you face an issue where there are no known sensible solutions. Apply
your feelings and contemplate and consider what could be the solution.
Consider the problem using a mind model in your brain and look for other
similar problems that you might have experienced and at least found theories
of how it works.

Once you decided on a theory, apply experiments to verify your theory.
If the experiment is successful then at least you have started to understand
the issues at hand. But there is still more work ahead to turn it into a sensible
model that can be used by others to extend their understanding.

Now this model has worked for me in my work life. Actually it has worked
well for me also in my religious life.

I came across the Church of Jesus Christ of Latter-Day Saints more than
30 years ago. I met a number of missionaries that presented their faith to
me.

I followed the above principles in evaluating their message. I started by reading
a lot about their religion, trying to understand whether their approach to life
seemed sensible.

Obviously as with any religion there is a point that one has to apply faith in order
to move on. This is actually true in work life as well, but the faith required to
change your life is a bit more than the faith required to try out an experiment on
a software system.

Thus the feelings required in a decision about religious matters need to be a bit
more profound. In my case it was a very clear feeling that what I read about was
true. This feeling was very convincing.

Armed with this strong feeling of conviction one can wonder if all is done?
For sure not, the step of experimentation is still ahead. Every commandment
in a religion comes with two parts. One part is the commandment, the second
part is the promised blessing from the commandment.

Thus every commandment in a religion can be experimented on. When such
an experiment brings you the blessings you have gained some understanding.
But the road is still long ahead to understand everything fully.

Monday, February 11, 2019

Periods in life

Yesterday I watched a movie about how Händel's Messiah came about.
It was an interesting story, but what really hit me was the description of the
3 parts of the oratorium. I am not an expert in it, and still isn't, but the
description provided in the movie hit me as a perfect description of my life.

The first part was about faith and hope, the second part of suffering, the third
part about the redemption and salvation.

I have experienced in my life the conversion that brought so much faith and hope
into my life and into the life of my family. This period lasted a quarter of a century
for me, I was healthy, strong, my work life although challenging prospered (and
still does). I raised a family of healthy kids together with my wife.

A couple of years ago I started up the second phase in my life. In the footnotes of
a speech by Neil L. Andersen I read a passage that made all the sense in the world
to me.

Quote: After days of ‘suffering,’ you are tired. After weeks of ‘suffering,’ you are exhausted. After months of ‘suffering,’ you begin to lose your ground. After years of ‘suffering,’ you submit to the possibility that you’ll never get better again. Hope becomes the most precious, and elusive, of gifts.

I definitely did reach the phase where you submit to the possibility that you will never
get better again. At the same time I still knew what the path was and that the path
leads to this glorious third phase of redemption and salvation. I still have no idea
about how this miracle will happen, but I've seen so many times that what has
happened in my life is the will of God and that it teaches me lessons that I could
not have learned in any other way.

For those that read those words I hope that you can learn your lessons with less
painful experiences. But if necessary, submit to the suffering and keep your
hope and your faith and rest assured that the Lord is with you in every step
of the way. I learned a lot about how Jesus felt those last days in his life through
my sufferings and the Lord prepared me to be a better servant in his kingdom.

Monday, November 28, 2011

Selecting a soccer system in 11-player soccer

I have spent some time the last year helping out as a soccer coach.
As usual when I engage in any activity I like to delve deep into
the theoretical parts of the activity. My team has played 7-player
soccer this year and is now moving to the 11-player game on a full
soccer field.

So I spent some time analysing the various variants of 11-player soccer.
What I have found is that there really is only 3 players in the modern
soccer theory which has variable positions. The other 8 players are always
there. More or less all variants contain a goalkeeper, 3 defenders, 3 midfielders
(1 central and 2 side midfielders) and at least 1 forward. For a complete listing
of all used formations in classic and modern football see here.

The only exception is the 4-6-0 formation which is highly unusual, but was
used by Jose Mourinho in one of the games against Barcelona last year.

So this actually means that it is fairly easy to transform your play given
that all modern formations have so much in common. It also means that for
a coach like myself at a basic level for 12-15-year old boys one can use some
simple rules to select a system and can use some simple thoughts to adapt his
system according to the team that is on the other side of the field.

The remaining 3 players can be located as defenders, defensive central midfielders,
offensive central midfielder or as forwards. However placing all 3 as forwards
isn't really an option, the 3-3-4 isn't considered a modern formation although
it has been used historically.

So the question is how to wisely select to place the remaining 3 players.
How to place those players is really dependent on a number of things such
as the strength of the team, the types of players that one has at disposal.

Most of the successful teams with strong players add at least 1 more forward
in their formation. The most successful formation that doesn't use any extra
forward use 4-2-3-1, that requires however a team very strong in running and
an exceptionally good forward at the top.

On the level I coach it's good to have at least 2 forwards to have a better
offensive play. Personally I am also very fond of the offensive
central midfielder, this player makes it possible to come 3 players in a
triangle with the offensive midfielder holding the ball with 2 options to
pass in particular in quick turns of the game. If the offensive midfielder
is really good at dribbling it now becomes very hard to defend against these
3 players. This is the case even when the defensive is consisting of 4 defenders.
The offensive midfielder can choose to dribble if the defenders focus on cutting
off his passes and he can pass and create a 1-1 situation if 2 players focus
on stopping his dribbling.

In our first selection we placed the third player as a central defender which
meant that we played 4-4-2 with a diamond formation. Playing against a very
strong team this setup had some weaknesses. The main problem happens when
the side midfielders and the offensive midfielders is attacking and is slow
to return to defend. In this case the defense is formed as 4 defenders and
1 defensive central midfielder. This had the unfortunate cause that although
all defending players were strong players, it was very hard to stop the
offensive team from either doing deep passes or simply running very fast
through the defense.

So to handle this it is clear that another defensive midfielder is needed. In
our team we also have a few good players that fit this role very well, so
clearly this is appropriate for our team.

However the issue is of course, which of the 3 players (forward, offensive
midfielder and an extra central defender) to remove. If we remove the forward
we come up with a 4-4-1-1 formation which in our case would not provide
sufficient attacking force to score sufficient amount of goals. If I remove
the offensive central midfielder I come up with the 4-4-2 system which is very
commonly used on this level in soccer. However this also removes a strong attacking
force and requires very stronger scorer. So the remaining
position to remove is the extra central midfielder. This is clearly an unusual
move, but it will create a more balanced 3-2 formation in quick turns of the
game when the other team attacks us and the side midfielders, offensive central
midfielder and the forwards still haven't made it back to the defense yet.
This formation is called 3-4-1-2 and is used by a number of italian teams.

Although this is clearly a more unusual set-up in Sweden where my team plays
we have found it an interesting formation to try. The reason is that in our team
we have quite a few players that run fast and can take care of the side
defender position and side midfielder position. These players became essential
in this formation since the formation relies on that these players can move
quickly back and forth on the field. I also have strong defensive and offensive
central midfielders. Also strong defenders. However to score our team requires a
team effort for it to happen. So by building my attack play on achieving formations
that are difficult to defend against and by creating numerical advantages on
midfield I can achieve goal scoring through a strong team effort. Many teams rely
on one or a few strong goal scorers and in our case we rather focus on making goals
a team effort.

To make a goals as a team effort requires a proper build-up play through many short and
a number of medium long passes. So we want to maintain ball possession.
So our system of play is targeted towards ball possession in the same manner
as Barcelona to move the ball into a dangerous spot. But our goal scoring
tactics is targeted towards passing the ball quickly to find a player that can
make the last run unattacked or at least in a 1-1 attack.

So as usual the 3-4-1-2 formation has to be adapted in the defensive, build-up
play and offensive. In the defensive position the side midfielders will move
down to become 2 extra defenders, thus turning the formation into 5-2-1-2 or even
5-3-2. Our forwards are part of the defense at least part of the way to aggressively
try to win the ball and possibly one of them can stay up in the last defending
position to ensure that the other team cannot move their defenders too high.
In the offensive position the side midfielders provide much of the attacking force
on the side field, the side defenders can move up a bit when attacking is done on
their side, but given that we play with a 3-player they need to be a bit more
cautious than what they can be in a 4-player defense. So something like a
2-3-3-2 is played in the offensive play or even 2-2-4-2 when we get a strong
possession of the ball.

Given that our system of play requires very careful build-up through many passes
we have focused very hard on the passing competence on all players in our team.
We hope this will bring us much of the ball possession even against strong teams
and this is also a good defense since it slows down those teams that often have
a number of very fast players.

Sunday, November 22, 2009

Testimony of a prophet

How does one receive a testimony of a prophet. Jesus gave us
the key in John 7:17 "If any man do his will, he shall know of
the doctrine, whether it be of God, or whether I speak of
myself".

President Gordon B. Hinckley admonished us to read the
Book of Mormon together as a family.

In our family we followed this advice and got a testimony that
President Hinckley was a prophet when he spoke those words.

Before we followed this advice we had for fifteen years gathered
our family to family prayers and all sorts of family activities.
Having many kids that everyone are intelligent, active and opinated
made those family gatherings sometimes an interesting challenge.

Now when we gather the family we still have as opinated and probably
even more intelligent kids (they got older and thus hopefully more
intelligent :)) but the family gatherings are friendlier, more
spiritual and a lot more fun and inspiring. This change in our family
came about as we started reading the Book of Mormon in our family on
a daily basis. Everyone in the family reads a few verses and then we
move on to the next family member and go around 2-4 rounds in the
family dependent on how many are at home.

So for us following this advice have been a great miracle and a
testimony of a prophet, Gordon B. Hinckley. I am sure that following
this prophetic admonition will bring blessings to any family willing
to abide by it.

You might find some challenges to get started with this in your family.
However as a child of heavenly parents you are entitled to have
personal inspiration about this, so ask your heavenly Father sincerely
and he will give you some simple ideas that will make it work in your
family. In our family my wife asked the Lord about this and got a very
simple message that would make the kids interested in it. After a while
no member in our family would need this extra stimulus. So now we
simply gather the family to family prayer and reading
the Book of Mormon and the spiritual feelings from this and being
together as a family is sufficient.

Sunday, November 15, 2009

Optimizing your personal life

A few weeks ago I visited a temple in our church. This gave me
the opportunity to ponder on how to balance the various
responsibilities I have in my life and how to be as effective as
possible in using my time. It's nice to sit for hours and have the
ability to simply ponder, consider and organize your thoughts. So it
took me almost four hours to realise what I thought was the most
important changes I could do in my life to improve it.

Since I work a lot with optimisations of computer programs in my
work, I thought it was fun to name this blog optimizing your
personal life. When practicing this new scheme in my life I've
been able to optimize my life by about 15-20% :)

In those four hours I organised all parts of my life which is of no
general interest. However the most important aspect on how to
improve my efficiency that I concluded was around the simple concept
of getting to bed earlier and getting up earlier. My natural
behaviour is similar to most programmers, that is I prefer late
nights and sleeping in the mornings. In my younger years I have at
numerous occasions tried to change this, however what I usually have
failed in is that I have been overzealous in trying to go to far. It's
also very tempting to cut in both ends, go up early, but still being
awake late.

In Doctrine & Coventants the Lord (88:124) instructs "retire to thy bed
early, that ye may be not weary; arise early, that your bodies and your
minds be invigorated". I have had many occasions to find this
admonishment to be true. However it requires a great deal of discipline
to implement in one's life.

In my pondering I felt what I thought was the right time to go to bed
and arise. For me this new routine has worked very well, I have been
able to get up early in the morning and have a few hours of work
already early in the morning when the mind is fresh and foremost
the stress level haven't started rising yet. I have also been able to
schedule some times for relaxing and for some parts in my life which
previously there wasn't any time for.

I have seen the Lord's hand in assisting me implementing this in my
life. I am sure I will meet many more challenges in this area in my
life, but I think the general concept of not trying to run faster than
your mind and body sustain is very wise and seems to be at least one
area where age has given me some more wisdom.

Tuesday, September 9, 2008

Achieving Perfection

One of my personal traits is that I strive for perfection
in what I do. Perfection however is something one very
rarely achieves and if it is achieved it takes a very
long time and hard work.

In my working life I can recall three moments of having the
feeling of achieving perfection. The first one was in
building a interrupt handler for a LAN device. The last
performance improvement that finally made the LAN device
completely stable in not losing data was when I removed the
first instruction after the interrupt (it was an instruction
that changed from decimal execution to binary execution in
case the user had turned on decimal execution. However after
checking through non-interrupt code I found that there was
no such code at all so it was a wasted instruction. This
meant 2.25% better performance which was enough to stabilise
such that I always handled RS232 interrupts on 19.2 kBaud
before they were overwritten by the next byte arriving.
The second was when building an interpreter and I finally
came down to a minimum of 7 SPARC assembler instructions
to handle the simplest interpreted instruction plus making
the interpreter pipelined in two stages. Quite interesting
design to make software in a similar manner to how hardware
is designed. The third was when I achieved linear scalability
on DBT2 for MySQL Cluster.

For me bringing something to perfection is beatiful and it
sort of turns on positive vibes in my soul. The path to
perfection is however full of agony, full of mistakes,
where we often think we're close to the solution, but
somehow there is another problem to resolve before
perfection is achieved.

In my personal life I experienced similar days of feeling
that I reached some level of perfection. However I'm
soon taken down from my lofty thoughts and shown what
more I can perfect before I'm done.

Jesus challenged us to become perfect as our Heavenly Father
is perfect. To me this means entering a path of constantly
striving for perfection in our personal lifes. It means
feelings of agony, it means experiencing mistakes, it means
days of feeling good about where you are and where you're
heading. I'm sure we won't reach perfection before this
life ends, but I'm sure eventually we can reach there and
it's a path that I know is worthy of following.

Another trait of reaching to perfection is prayer. For me all
of the above perfections came through a long series of
inspiration from above. One thing I noted about prayer is that
in order to receive the answer to your prayers for perfection
you have to work hard on your own to learn all the details
already known through books, other people and so forth. However
when you've done all that then answers to your prayers will
flow to you constantly. This happened to me at the end of my
Ph.D studies. I had a period of a little more than a year when
I almost on a daily basis had a flow of inspiration coming to me.

So my experience of the path to perfection is that one should
work hard, be prayerful, expect to be knocked down in all
senses of the word on the way and expect to find a lot of joy
also on the path to perfection.