July 10 2020 08:04:36
· Home
· CV
· Articles
· Links
· News Categories
· Media Gallery
· Search


Forgotten your password?
Request a new one here.
More SearchEngine goodness...
SoftwareI spent today tweaking and fixing issues (such as invalid hash collisions meaning loss of data in the indexes and word offsets not being added correctly). Perhaps of more importance, I added monitoring to the backend using my monitoring framework! This is the first time I've really been able to test the SearchEngine properly and here is how it looks! I've blurred out the content's because it's currently indexing the RuneScape knowledge base (hey, since I wrote Jagex's SearchTool libraries, I figured I'd use the same dataset for SearchEngine!). The data was all legally obtained via scraping their website with this little BASH script:
while [ $i -lt 9999 ]; do
   wget http://www.runescape.com/kbase/viewarticle.ws?article_id=$i -O $i.html
   i=`expr $i + 1`
So, how does it perform? Pretty well! It's not as fast as the implementation I wrote for Jagex (we used custom libraries which were a lot faster), however it's pretty close:
# Hash Fields: 2
    * [0] - Word count: 983
    * [1] - Word count: 10605
# Trie Fields: 2
    * [0] - Word count: 1249
    * [1] - Word count: 25428
# Average search time: 4ms
# Longest search time: 17ms
# Shortest search time: 0ms
# Search Count: 9
After only 9 searches, the average is down to 4ms (the longest average is always the first search since the JVM does initialisation when processing the first search). I believe the average search times at Jagex were on the order of 1.5ms, but I can't guarantee this figure. Not bad, though!

Today I realised that I have forgotten a pretty crucial part of the implementation - search logging! So that's what I'll be working on next.
Search Engine
SoftwareI finished my search engine yesterday. It didn't go as well as planned. The String Trie that I had written functioned fine, but as soon as it became loaded (with 40,000+ nodes) it became intolerably slow. I'm blaming this on Java's collection implementations because I had no such issues when I created the search engine for RuneScape. This means that I have omitted the trie from the implementation meaning that no wildcarded searches can be performed (not a _huge_ loss, but still frustrating). It still supports phrase searches, stray/ stemmed searches and "NOT" terms along with result highlighting. My original implementation for Jagex took about 4 weeks to complete so I'm quite pleased that it only took me 2 days this time around. Maybe if I feel the need for wildcarded searches I will write my only collection implementations but I'd rather not deviate from the Java libraries too much!

So, what next? I'm not too sure. I think I'll add web-based monitoring to the SearchEngine so I can view which words are indexed, average search times, number of searches etc... After that I might toy around with a system to send data in UDP packets between programs (kind of like RMI but simpler).


As a shot in the dark, I tried upping the heapspace available to the JVM and this fixed the problems of slowness when indexing with the StringTrie! I've just spent the past hour or so putting the StringTrie back in place and making persistence more efficient. I can do wildcarded searches on the entire works of Shakespeare in 19 milliseconds now! Initial indexing takes a little while (under a minute for all of Shakespeare's work), reloading from a persisted state takes about 9 seconds.
My Next Project...
SoftwareMy next project is to write a search engine (Why? Who knows - I just thought it might be something useful to have in a library/ portfolio). I've already begun on the development, so far I have a "StringTree" which lets me load in objects that encapsulate a result and a string. The object is indexed against the string. For example, if we had an object that contained the string "pinecones" and added it to the tree, nodes for 'p', 'i', 'n', 'e', 'c', 'o', 'n', 'e', and 's' would be made. The final node 's' is where the object would reside. With this structure one can search for whole strings easily as it is just a matter of traversing nodes and their childs until we reach a dead end or stop on a node. If there is a dead end, there is no result. If we stop on a node and it has a child, then we have a result! What's cool is that you can also do trailing wild card searches with this simple structure. For example "pin*" would traverse the tree to 'p', 'i', 'n' then ask the 'n' node "get me all of your results (if any) and all of your children's results (if any). So it might get "pine", "pinecone", "pinecones". Finally, what if we want to do leading wild card searches? Well, another index needs to be added to the root of the tree. The index required is one that points to ALL nodes in the tree but indexed upon character itself. For example, we have a collection of all 'a' nodes, all 'b' nodes, all 'c' nodes etc... Then, if we search for "*ine" what we're actually saying is "start from all 'i' nodes". So for each indexed 'i' node we traverse to 'n' then 'e' and aggregate the results thus we might find "wine", "dine" and "pine". Simple, no?

This may sound like quite a slow system having to traverse so many links, however I wrote a simple tester and got the following results:

Load time: 210ms
Loaded objects: 108729
Search time: 30ms
Results: 108729

So it takes 210ms to create 108729 objects and index them and a further 30ms to search for "*" thus traversing ALL nodes and returning ALL results. Pretty fast!

I've also taken and cleaned up the Snowball stemming system (taken out the needless use of reflection - yuck) and put it into my libraries. This will make searching better for single "stray" terms as "horse", "horses" and "horsing" will all resolve to the same stem of "hors" so will essentially be treated as the same word. It will also reduce the memory overhead as less objects in total will be required when indexing.

(No idea what my fascination with pinecones is, sorry!)
SoftwareSo I've spent the past week developing a modular system monitoring interface for my software that plugs into SlXHTTPd. Since I already had my bot partially written I decided it would be a good place to try it out. Here's how it looks. The interface also supports paginating data with a rotating page selection carousel.

I've refactored the script compiler out of the HTTPd and made it into a generic in-memory compiler so that SlXBot can take advantage of it and recompile/ reload it's modules on-the-fly without rebooting and losing connection.
SoftwareI've added proxy support! This means that I could visit http://*.somedomain.com and have SlXHTTPd forward all requests to http://*.someotherdomain.com - handy when I want to run two webservers from the same box and have both accessible via port 80 (For example, http://slx.cc is forwarded to http://localhost:6700).
SoftwareSince I've had quite a bit of spare time lately I've put most of it to use in developing my personal projects (as you can see, I've been posting about SlXHTTPd). During this development I have made lots of reusable code, so I've decided to make my own libraries! I've called them cc.slx (after my slx.cc domain). If I ever get to the point where I feel they are stable, I'll release them! For now, I've split out all of the reusable code from SlXHTTPd and SlXBot (my IRC bot) into the library. This has lead me to make SlXHTTPd a library. Rather than just running as a standalone server, it can now be placed into any Java project and can serve anything (not just files). It does this by using a "RequestHandler". When a request is made, it gets passed to the root request handler. The request handler can then decide what to do (e.g. based off of the requested page name). This pretty much gives limitless potential and really fine-grained control of the HTTPd within the code. My plan now is to expand on the web-enabled features of SlXBot to demonstrate what can be achieved. The past two months have seen me go through quite a productive phase - I've written 14476 lines of Java in my library, HTTPd and IRC bot!
SlXHTTPd... again!
SoftwareSo, the trial went very well - no one reported any errors. However, I'm back to using Apache simply because it is the "standard". I will only use SlXHTTPd for bespoke projects.
SoftwareSo, I spent all of today coding and managed to add Vhost support, HTAccess and HTPasswd support along with tweaks to CGI execution throttling. I've also done a lot of refactoring and tidying. In fact, It's about as feature complete as I need so I've decided to put it to the test and set it loose! It's serving this very page! Depending on how it goes, I may replace apache with it.
SoftwareAside from my IRC bot (SlXBot), I've been working on a new version of my HTTPd. Originally, my HTTPd was called "ShAPAChE", which seemed a little corny. It was coded in C++ as a university project (it was barely object oriented because, sadly, my lecturer on the subject was not a great OO programmer - more of a hacker). Anyway, since then I have finished university and had some real-world experience with OO programming in Java... so I decided to re-write it in, yes, Java! It's going very well. I've hit several milestones:

It can run PHP and CGI,
It has its own language, which is a mixture of HTML and Java and is compiled dynamically in memory when a page is requested meaning that pages do not have to be precompiled,
It has speed limiting and connection limits,
POST works fully,
Redirection works,
Directory listings work,
Inbound header sizes can be limited to avoid people posting large data to the server,
It has full logging,
It has configurable mimetypes,
It has a configurable ban list,
Options are configurable via a config file,
It supports keep-alive,
It supports chunked transfer encoding...

I plan to add a few more features to it such as vhosts, .htaccess support and .htpasswd support (and maybe even gzip support if I find myself with nothing to do). After this, I may consider dumping Apache and using SlXHTTPd full-time!

The architecture of SlXHTTPd is pretty interesting. By itself, it can be run as a stand-alone server. However, it can also be "plugged" into any Java project which can communicate "Arguments" to the HTTPd to be rendered or used in the processing of a page. A plan I have for the future is to integrate SlXHTTPd with SlXBot so that statistics may be viewed in a web browser along with channel logs etc...

This leads me onto my next project which will be a way for programs to communicate without needing to be linked (i.e. they will not need to be part of the same program). Instead, data could be communicated between programs using UDP packets. Anyway, more on that later!
NewsAll of the content from the old site is now up!
New Site!
NewsHello everyone and welcome to the new ShALLaX.com website. The old site was rather outdated (the last news post was made in 2004!) so I figured I'd put together a new one using a CMS system to save me having to edit HTML by hand all the time! Anyway, I'll be adding all of the old content back to this site over the next few days.
811,371 unique visits