Hello all!
As I like to do something useful when I learn a new language, I decided to do a
backup system.
I obviously chose to use the integrated database engine to store the meta-data.
Unfortunately, the timings I get are starting to frighten me:
# Backup returns the number of +File insertions
# Before each run, I removed the database dir and exited pil, in order to ensure
no interference.
: (bench (Backup "/tmp/pico"))
0.303 sec
-> 322
: (bench (Backup "/tmp/pico"))
2.252 sec
-> 644
: (bench (Backup "/tmp/pico"))
7.677 sec
-> 966
: (bench (Backup "/tmp/pico"))
18.238 sec
-> 1288
: (bench (Backup "/tmp/pico"))
35.535 sec
-> 1610
: (bench (Backup "/tmp/pico"))
64.718 sec
-> 1932
: (bench (Backup "/tmp/pico"))
107.136 sec
-> 2254
: (bench (Backup "/tmp/pico"))
163.182 sec
-> 2576
: (bench (Backup "/tmp/pico"))
227.789 sec
-> 2898
: (bench (Backup "/tmp/pico"))
316.216 sec
-> 3220
As you can see, given the progression, it will soon take more time to store the
meta-data than processing the data itself.
Does anybody see if I made a mistake in my code?
(class +Chunk +Entity)
(rel cs (+Need +Number)) # checksum of this chunk
(rel files (+List +Joint) chunks (+File)) #
(class +File +Entity)
(rel pth (+Need +Ref +String)) # file path
(rel size (+Need +Number)) # file size
(rel accessTime (+Need +Number)) #
(rel modifyTime (+Need +Number)) #
(rel changeTime (+Need +Number)) #
(rel inode (+Need +Ref +Number)) #
(rel links (+Need +Number)) #
(rel uid (+Need +Number)) #
(rel gid (+Need +Number)) #
(rel accessRights (+Need +Number)) #
(rel target (+String)) # target of the softlink (if any)
(rel chunks (+List +Joint) files (+Chunk)) # list of chunks (if any)
(rel backups (+List +Joint) files (+Backup)) #
(class +Backup +Entity)
(rel name (+Ref +String)) # name of this backup
(rel startDT (+Need +Ref +String)) # start datetime of this backup
(stamp T)
(rel endDT (+String)) # end datetime of this backup
(empty if not finished)
(rel exclusions (+List +String)) # exclusion flags
(rel inclusions (+List +String)) # inclusion flags
(rel basePath (+Need +List +String)) # paths considered for this backup
(rel hostName (+Need +Ref +String)) # name of the host being backup'd
(rel files (+List +Joint) backups (+File)) #
(dbs
(0)
(0 +Chunk)
(0 +File)
(0 (+File pth inode))
(4 +Backup)
(0 (+Backup name startDT hostName)) )
(let pa "/tmp/test_db"
(ifn (info pa) # if it does not already exists...
(call 'mkdir pa) ) # create the path to store the DB
(pool (pack pa "/") *Dbs) ) # open the DB
# fake...
(de addFile (Bk P)
(let o
(request '(+File)
'pth P
'size 0
'accessTime 1
'modifyTime 2
'changeTime 3
'inode 4
'links 1
'uid 1001
'gid 1002
'accessRights 766 )
(put!>
o
'backups
(append (; 'o backups) Bk) )
o ) )
(de Backup (rootPath)
(let obj1
(request '(+Backup)
'name (stamp)
'startDT (stamp)
'basePath rootPath
'hostName (host "localhost") )
(put! *DB 'currentBackup obj1)
# now, walk the path
(let Dir rootPath
(recur (Dir)
(for F (dir Dir)
(let Path (pack Dir "/" F)
(addFile obj1 Path)
# note: change this test: it considers a link to a dir as a
dir!
(if (=T (car (info Path)))
(recurse Path) ) ) ) ) )
(length (get obj1 'files)) ) )
Thanks for your time.
Regards,
--
Laurent ARTAUD
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe