to take advantages on the performance
This begs the question that the people who put "an existing OS" together were not concerned about performance, or that you understand it better than them (in which case you would not be asking this kind of question -- I'm not trying to belittle you, just stating the obvious). If people approached their cars the way they sometimes approach computers, we'd see a lot of stuff left up on blocks in the driveway and more blue smoke on the highways.
If you want to learn stuff, great. If you want to pretend you are going to supe up your Chevy the day you buy your first wrench, stop now. It is not a good mindset for trying to understand how something works. IMO.
I found that i must compile the kernel from scratch but this would take me a long time to understand the whole process
You don't have to unless you have a particular reason to. Configuring and compiling the kernel is pretty tedious stuff. I'm glad I know how to do it from time to time, but there's not a lot to learn coming at it that way. In fact I'd call it a complete waste of time in terms of educational value. None-the-less:
Configuring, compiling and installing a custom Linux kernel
Kernel .config necessary options
Install Custom Kernel
But instead, my advice if you are interested in how the operating system works (you will need to understand stuff like that before you set out creating one) is to learn about the init system. On current versions of Raspbian that is systemd. After you read those two things, you are ready to get a little more in depth; have a look at the Fedora wiki, since they were the ones who introduced it, and, since they provide the best documentation of any linux distro, the Arch wiki.
Debian, which Raspbian is a variant of, also produce some good documentation. This page is a decent explanation of what "init" is and an introduction to systemd "service files". Note pi OS's don't use an initramfs (they could, but there would not be much of a point since they require a custom kernel anyway,1 see #4 in the answer to that "Configuring, compiling, and installing..." question).
Beware there is a lot of stuff around about SysV init and the raspberry pi. This refers to /etc/init.d
and scripts that run from there, and commands like update-rc.d
(we have a lot of that here). While systemd supports this for backward compatibility, skip learning about it. It is history, and it is not coming back. You will see these two things distinguished in most of the above articles (in fact the fedora one is sort of for people who've got to know SysV -- this applies now to Raspbian, since it just switched over).
Also beware of falling into the trap of constantly including "raspberry pi" in your searches. A lot of people seem to believe linux and debian were invented yesterday for the raspberry pi, and/or that the raspberry pi represents some significant proportion of contemporary linux systems, and/or that there is something special about the Raspbian OS. All three of these things are very, very false. What's worse, some of these people have written atrocious blogs trying to explain things that have already been explained better elsewhere. I believe some of them do this literally because they figure recontextualing it in terms of the "raspberry pi" will help get them in google, since otherwise it would just be redundant, often poor quality, regurgitation.
There are also some very good pi pages around; it's up to you to decide between them (that's the internet). When in doubt, ask about it here. Questions such as "I read [this] [here] about the Pi. Does that mean _______?" are usually totally appropriate here, or on U&L.
The major hassle about learning how init works is it will require a lot of rebooting -- but then, so does compiling the kernel, and it is usually much more inscrutable when it does not work. The pi is sort of handy this way since you can easily sit with a laptop or whatever at the same time. Init systems are complex and may take a long time to understand, but if you want to start seriously customizing things, you can't pass go without it.
1. Although getting one to work to use to switch between operating systems, as I suggested here, would be a great educational project. Just be warned that starting from scratch, if you study this stuff full time, it will take you months to work out properly.