The Notebook Review forums were hosted by TechTarget, who shut down them down on January 31, 2022. This static read-only archive was pulled by NBR forum users between January 20 and January 31, 2022, in an effort to make sure that the valuable technical information that had been posted on the forums is preserved. For current discussions, many NBR forum users moved over to NotebookTalk.net after the shutdown.
Problems? See this thread at archive.org.

    FireWatcherSSD

    Discussion in 'Acer' started by inteks, Dec 9, 2009.

  1. inteks

    inteks Notebook Evangelist

    Reputations:
    168
    Messages:
    374
    Likes Received:
    0
    Trophy Points:
    30
    for all SSD users with Ramdrive and Firefox >= 3.5 :cool:

    this tool took the sqlite-journals (really many small writes) and put them on the ramdrive and create symlinks.
    why this tool ? firefox deletes this files on close and the symlinks are lost. this tool recreates them ;)


    usage:
    "FireWatcherSSD.exe profiledir"
    i.e.
    FireWatcher .exe "C:\Users\you\AppData\Roaming\Mozilla\Firefox\Profiles\xxgg2233.default"

    sourcecode :)
    Code:
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Threading;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;
    namespace FireWatcherSSD
    {
        class Program
        {
            [DllImport("kernel32.dll")]
            static extern bool CreateSymbolicLink(string lpSymlinkFileName, string lpTargetFileName, int dwFlags);
    
            private const string FileExt = ".sqlite-journal";
    
            private static  List<string> _journals;
    
            private static string Profiledir;
    
            static void Main(string[] args)
            {
                if (args.Length == 0 || !Directory.Exists(args[0])){
                    MessageBox.Show( "pls provide firefox profiledir thru commandline");
                    return;
                }
    
                Profiledir = args[0];
    
                _journals = new List<string>{"downloads","cookies","places"};
                foreach(var journal in _journals) CheckJournal(journal);
                
    
                var watcher = new FileSystemWatcher(Profiledir, "*.sqlite-journal") {EnableRaisingEvents = true};
                watcher.Deleted += WatcherDeleted;
                Thread.Sleep(Timeout.Infinite);
            }
    
            private static void CheckJournal(string Journal)
            {
                var orgFile = Path.Combine(Profiledir, Journal + FileExt);
                var ramFile = Path.Combine(@"R:\",Journal + FileExt );
    
                if (!File.Exists(orgFile ) || (new FileInfo(orgFile).Attributes & FileAttributes.ReparsePoint) == 0){
                    if (!File.Exists(ramFile))File.Create(ramFile).Close();
                    if(File.Exists(orgFile))File.Delete(orgFile);
                    CreateSymbolicLink(orgFile , ramFile, 0);
                }
                
            }
    
    
            static void WatcherDeleted(object sender, FileSystemEventArgs e)
            {
                var journal = e.Name.Replace(FileExt, "");
                if (!_journals.Contains(journal)) return;
                CheckJournal(journal);
            }
        }
        }
    
     
  2. mogolfiero

    mogolfiero Notebook Consultant

    Reputations:
    11
    Messages:
    193
    Likes Received:
    0
    Trophy Points:
    30
    I got no idea what you are talking about :p

    Could you care to explain a little more?

    I got an SSD and i`m looking around for new tips tweaks!

    Cheers
     
  3. inteks

    inteks Notebook Evangelist

    Reputations:
    168
    Messages:
    374
    Likes Received:
    0
    Trophy Points:
    30
    1. SSD writing = wearout. so avoid writing
    2. SSD writing of small blocks are slow.
    if you want to write 4k to ssd the ssd read a 512k block into memory
    then it replace the 4k you want to write within this block in memory
    then it erase the 512k on the ssd (write zeros)
    and then the ssd write the new 512k block back to ssd.
    so avoid writing small block !!!

    firefox use sqlite for cookies and places. (cookies.sqlite)
    sqlite use a transaction file for rollback. (cookies.sqlite-journal)
    sqlite really often writes 4k blocks to those journals !!
    from time to time sqlite put this journal into the main sqlite file this is a 1024k write this is ok ;)

    so i thought putting these journalfiles to ramdisk is an good idea :)