GithubHelp home page GithubHelp logo

optimalization about pi-hole HOT 12 CLOSED

pi-hole avatar pi-hole commented on April 27, 2024
optimalization

from pi-hole.

Comments (12)

ttr avatar ttr commented on April 27, 2024

oops (forgot) - all those are in gravity-adv.sh file

from pi-hole.

jacobsalmela avatar jacobsalmela commented on April 27, 2024

I have only used awk for basic parsing, printing single columns, etc. Could you explain how your awk command works?

from pi-hole.

jacobsalmela avatar jacobsalmela commented on April 27, 2024

So I ran it using /run/shm instead of /tmp and it was about 2-3 seconds faster overall on my Pi. Using /dev/shm yielded similar results.

I would still like to understand your awk command in detail

from pi-hole.

ttr avatar ttr commented on April 27, 2024

Running in shm also reduce usage of SD card.

Now awk... well (g)awk is more complex tool then printing certain fields from lines (feel free to look up any tutorial).
In my example it does condition check (if (...) ) and

  • check if first and second field is not starting with certain characters (# or / which can be comments)
  • if line is not empty ($0 match whole line)
  • if 2nd field not empty
    there is logical and for each of those conditions, as when they all are true, it will print second field.
    This should reduce need to use all those grep (and not sure why you need those sed in there?). I did not check how this will behave in case of white-space in beginning of line but that should not be a problem.
    Reason to do so is to limit amount of sub-calls (and pipes) as each of it will take some time and CPU cycles to execute.

Also - side note (and quite separate thing): if you do checksum comparison of old and new file (i.e. md5sum of $eventHorizion and then same for /tmp/andLight.txt before mv) and trigger dnsmasq restart when files (checksums) are different, you can put this as cronjob (i.e. every day) so lists will be always up to date but dnsmasq will be restarted only when there was update.

from pi-hole.

jacobsalmela avatar jacobsalmela commented on April 27, 2024

Thanks for explaining it. It makes more sense now. I always knew awk was much more, but have never really utilized it. I love open source for this reason as I learned something and your skill will be able to make the code better and try things I never even thought about.

I will mess around with implementing this and see what I can come up with.

from pi-hole.

jacobsalmela avatar jacobsalmela commented on April 27, 2024

You are definitely right that it does not need the sort on each line. I did some testing with it using the time command and it seems a little faster only using it on the last line. In my brain, I was thinking it would be easier for the computer to sort a few sorted lists, but I guess the computer doesn't care (it's smarter than me)!

There is also a slight improvement in using RAM as opposed to the SD card, so that will make it in, too.

I'm still looking into your other suggestions.

from pi-hole.

jacobsalmela avatar jacobsalmela commented on April 27, 2024

Using my Mac as a test machine, the average time I can run the existing gravity-adv.sh script is 20-30 seconds. I will use that as the baseline for determining speed improvements.

from pi-hole.

jacobsalmela avatar jacobsalmela commented on April 27, 2024

I have made some significant improvements based on your suggestions. After some more testing to ensure it works, I will commit them.

from pi-hole.

ttr avatar ttr commented on April 27, 2024

Cool.
(was on longer holidays so did not reply before)

from pi-hole.

jacobsalmela avatar jacobsalmela commented on April 27, 2024

I am on vacation at the moment and will have to look at this in a couple of weeks.

from pi-hole.

jacobsalmela avatar jacobsalmela commented on April 27, 2024

I implemented your suggestions in another branch, that will be merged with the master soon.

from pi-hole.

jacobsalmela avatar jacobsalmela commented on April 27, 2024

Your suggestions were implemented in the release this evening.

from pi-hole.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.